Q.1

Which of the following statements is correct when a class is inherited privately?

  • Public members of the base class become protected members of derived class.
  • Public members of the base class become private members of derived class.
  • Private members of the base class become private members of derived class.
  • Public members of the base class become public members of derived class.
Q.2

Which of the following is the only technical difference between structures and classes in C++?

  • Member function and data are by default protected in structures but private in classes.
  • Member function and data are by default private in structures but public in classes.
  • Member function and data are by default public in structures but private in classes.
  • Member function and data are by default public in structures but protected in classes.
Q.3

Which of the following access specifies is used in a class definition by default?

  • Protected
  • Public
  • Private
  • Friend
Q.4

Which of the following statement is correct about the program given below?

#include<iostream.h> 
class IndiaBix
{
    static int x; 
    public:
    static void SetData(int xx)
    {
        this->x = xx; 
    }
    static void Display() 
    {
        cout<< x ;
    }
};
int IndiaBix::x =
int main()
{
    IndiaBix::SetData(22);
    IndiaBix::Display();
    return
}
  • The program will print the output 0.
  • The program will print the output 22.
  • The program will print the output Garbage.
  • The program will report compile time error.
Q.5

Which of the following statements is incorrect?

  • Friend keyword can be used in the class to allow access to another class.
  • Friend keyword can be used for a function in the public section of a class.
  • Friend keyword can be used for a function in the private section of a class.
  • Friend keyword can be used on main().
Q.6

What will be the output of the following program?

#include<iostream.h>
#include<string.h> 
class IndiaBix
{
    char str[50]; 
    char tmp[50]; 
    public:
    IndiaBix(char *s)
    {
        strcpy(str, s);
    }
    int BixFunction()
    {
        int i =j =
        while(*(str + i))
        {
            if(*(str + i++) == ' ')
                *(tmp + j++) = *(str + i);
        }
        *(tmp + j) =
        return strlen(tmp); 
    }
};
int main()
{
    char txt[] = "Welcome to IndiaBix.com!";
    IndiaBix objBix(txt); 
    cout<< objBix.BixFunction();
    return}
  • 1
  • 2
  • 24
  • 25
Q.7

Which of the following statement is correct about the program given below?

#include<iostream.h> 
class BixBase
{
    int x, y; 
    public:
    BixBase(int xx =int yy =    {
        x = xx;
        y = yy;
    }
    void Show()
    {
        cout<< x * y << endl;
    }
};
class BixDerived
{
    private:
        BixBase objBase; 
    public:
    BixDerived(int xx, int yy) : objBase(xx, yy)
    {
        objBase.Show();
    }
};
int main()
{
    BixDerived objDev(20);
    return
}
  • The program will print the output 100.
  • The program will print the output 200.
  • The program will print the output Garbage-value.
  • The program will report compile time error.
Q.8

Which of the following statement is correct about the program given below?

#include<iostream.h> 
class BixData
{
    int x, y, z; 
    public:
    BixData(int xx, int yy, int zz)
    {
        x = ++xx;
        y = ++yy;
        z = ++zz;
    }
    void Show()
    {
        cout<< "" << x++ << " " << y++ << " " << z++;
    } 
}; 
int main()
{
    BixData objData(3);
    objData.Show();
    return
}
  • The program will print the output 1 2 3.
  • The program will print the output 2 3 4 .
  • The program will print the output 4 5 6.
  • The program will report compile time error.
Q.9

Which of the following statements is correct?

  • Data items in a class must be private.
  • Both data and functions can be either private or public.
  • Member functions of a class must be private.
  • Constructor of a class cannot be private.
Q.10

What does a class hierarchy depict?

  • It shows the relationships between the classes in the form of an organization chart.
  • It describes "has a" relationships.
  • It describes "kind of" relationships.
  • It shows the same relationship as a family tree.
Q.11

Which of the following statements is correct about the program given below?

class Bix
{
    public:
    static void MyFunction();
};
int main()
{
    void(*ptr)() = &Bix::MyFunction;
    return
}
  • The program reports an error as pointer to member function cannot be defined outside the definition of class.
  • The program reports an error as pointer to static member function cannot be defined.
  • The program reports an error as pointer to member function cannot be defined without object.
  • The program reports linker error.
Q.12

Which of the following statement is correct with respect to the use of friend keyword inside a class?

  • A private data member can be declared as a friend.
  • A class may be declared as a friend.
  • An object may be declared as a friend.
  • We can use friend keyword as a class name.
Q.13

Which of the following keywords is used to control access to a class member?

  • Default
  • Break
  • Protected
  • Asm
Q.14

Which of the following statement is correct regarding destructor of base class?

  • Destructor of base class should always be static.
  • Destructor of base class should always be virtual.
  • Destructor of base class should not be virtual.
  • Destructor of base class should always be private.
Q.15

Which of the following two entities (reading from Left to Right) can be connected by the dot operator?

  • A class member and a class object.
  • A class object and a class.
  • A class and a member of that class.
  • A class object and a member of that class.
Q.16

Which of the following statement is correct about the program given below?

#include<iostream.h> 
class BixBase
{
    int x, y; 
    public:
    BixBase(int xx =int yy =    {
        x = xx;
        y = yy;
    }
    void Show()
    {
        cout<< x * y << endl;
    }
};
class BixDerived : public BixBase
{
    private:
        BixBase objBase; 
    public:
    BixDerived(int xx, int yy) : BixBase(xx, yy)
    {
        objBase.Show();
    }
};
int main()
{
    BixDerived objDev(20);
    return
}
  • The program will print the output 100.
  • The program will print the output 200.
  • The program will print the output Garbage-value.
  • The program will report compile time error.
Q.17

Which of the following statement is correct about the program given below?

#include<iostream.h> 
class IndiaBix
{
    int x; 
    float y; 
    public:
    void Function()
    {
        x =
        y = 2.delete this;
    }
    void Display()
    {
        cout<< x << " " << y;
    } 
}; 
int main()
{
    IndiaBix *pBix = new IndiaBix();
    pBix->Function(); 
    pBix->Function(); 
    pBix->Display(); 
    return
}
  • The program will print the output 4 2.5.
  • The program will print the output 4.
  • The program will report runtime error.
  • The program will report compile time error.
Q.18

Which of the following statements are correct for a static member function?

  1. It can access only other static members of its class.
  2. It can be called using the class name, instead of objects.
  • Only 1 is correct.
  • Only 2 is correct.
  • Both 1 and 2 are correct.
  • Both 1 and 2 are incorrect.
Q.19

How can we make a class abstract?

  • By making all member functions constant.
  • By making at least one member function as pure virtual function.
  • By declaring it abstract using the static keyword.
  • By declaring it abstract using the virtual keyword.
Q.20

Which of the following can access private data members or member functions of a class?

  • Any function in the program.
  • All global functions in the program.
  • Any member function of that class.
  • Only public member functions of that class.
0 h : 0 m : 1 s