1. Question: You want the data member of a class to be accessed only by itself and by the class derived from it. Which access specifier will you give to the data member?

    A
    Public

    B
    Private

    C
    Protected

    D
    Friend

    E
    Either Public or Friend

    Note: Not available
    1. Report
  2. Question: If input and output operations have to be performed on a file, an object of the _______ class should be created.

    A
    fstream

    B
    iostream

    C
    ostream

    D
    istream

    E
    None

    Note: Not available
    1. Report
  3. Question: State which of the following is true.

    A
    Function templates in C++ are used to create a set of functions that apply the same algorithm to different data types

    B
    Classes in C++ are used to develop a set of type-safe classes

    C
    C++ is useful for developing collection classes

    D
    C++ is useful for developing smart pointers

    E
    All

    Note: Not available
    1. Report
  4. Question: Consider the sample code given below and answer the question that follows.
    class SomeClass
    {
    int x;
    public:
    SomeClass (int xx) : x(xx) {}
    };
    SomeClass x(10);
    SomeClass y(x);
    What is wrong with the sample code above?

    A
    SomeClass y(x); will generate an error because SomeClass has no copy constructor

    B
    SomeClass y(x); will generate an error because SomeClass has no default constructor

    C
    SomeClass y(x); will generate an error because SomeClass has no public copy constructor

    D
    x(xx) will generate an error because it is illegal to initialize an int with that syntax

    E
    The code will compile without errors

    Note: Not available
    1. Report
  5. Question: Which of the following statements regarding functions are false?

    A
    Functions can be overloaded

    B
    Functions can return the type void

    C
    Inline functions are expanded during compile time to avoid invocation overhead

    D
    You can create arrays of functions

    E
    You can pass values to functions by reference arguments

    F
    You can return values from functions by reference arguments

    G
    A function can return a pointer

    Note: Not available
    1. Report
  6. Question: What does ADT stand for?

    A
    Accessible derived type

    B
    Access to derived type

    C
    Abstract data type

    D
    Abstract derived type

    E
    Accessible data type

    Note: Not available
    1. Report
  7. Question: A pure virtual function can be declared by _______.

    A
    equating it to 1

    B
    equating it to 0

    C
    equating it to NULL

    D
    the 'pure' keyword

    E
    the 'pure' keyword

    Note: Not available
    1. Report
  8. Question: Which of the following are true about class and struct in C++:

    A
    A class can have destructor but a struct cannot

    B
    A class can have inheritance but a struct cannot

    C
    In a class all members are public by default, whereas in struct all members are private by default

    D
    In a class all members are private by default, whereas in struct all members are public by default

    Note: Not available
    1. Report
  9. Question: What is the output of the following code segment?
    int n = 9;
    int *p;
    p=&n;
    n++;
    cout << *p+2 << "," << n;

    A
    11,9

    B
    9,10

    C
    12,10

    D
    11,10

    Note: Not available
    1. Report
  10. Question: What will be the output of the following code?
    #include<iostream>
    using namespace std;
    
    class b
    {
    int i;
    public:
    void vfoo()
    { cout <<"In Base "; }
    };
    
    class d : public b
    {
    int j;
    public:
    void vfoo()
    {
    cout<<"In Derived ";
    }
    };
    
    void main()
    {
    b *p, ob;
    d ob2;
    p = &ob;
    p->vfoo();
    p = &ob2;
    p->vfoo();
    ob2.vfoo();
    }

    A
    In Base In Base In Derived

    B
    In Base In Derived In Derived

    C
    In Derived In Derived In Derived

    D
    In Derived In Base In Derived

    E
    In Base In Base In Base

    Note: Not available
    1. Report
Copyright © 2024. Powered by Intellect Software Ltd