Professional Documents
Culture Documents
C++ Complex Question Set
C++ Complex Question Set
1. Statement I : All the non-private members of the base class can be accessed
from the derived class as if they were members of the derived class.
Statement II : The protected data members can be accessed in the same class
or in its derived class.
1. Inheritance
2. Abstraction
3. Polymorphism
4. Encapsulation
1. Polymorphic inheritance
2. Multilevel inheritance
3. Single Inheritance
4. Multiple inheritance
8. Which of the following operators below allow defining the member functions of a
class outside the class?
1. ::
2. ?
3. :?
4. %
9. The return value of the following code is
1. object of Class1
2. reference to ptr
3. reference of Class1
4. object pointed by ptr
10. EMP *eptr = new EMP[5]; call show method for employee having index 3.
1. (*eptr+3).shoe();
2. eptr[3].show()
3. Both 1 & 2
4. (eptr+3)->show();
Complex& getObject();
What sould be return statement in function definition ?
1. return *this;
2. retrun this&;
3. return &this;
4. return *&this;
int main()
{
Complex c1(4,5);
Complex c2(6,9);
Complex c3;
C3 = c1 + c2;
return 0;
}
1. c3 =C1.operator+(c2);
2. c3 = Operator+(c1,c2);
3. c3 = C2.operator+(c1);
4. None of of available option
1. True
2. False
15. Which of the following library function below by default aborts the program?
1. Terminate()
2. end()
3. Abort()
4. exit()
16. What is deep copy?
17. What is the difference between overloaded functions and overridden functions?
1. True
2. False
1. return *this;
2. retrun this&;
3. return &this;
4. return *&this;
1. Run time
2. Compile time
3. Depends on how it is invoked
4. Both b and c above
1. X~() {}
2. X() {}~
3. X() ~{}
4. ~X() {}
22. What is the Difference between struct and class in terms of Access Modifier?
1. By default all the struct members are private while by default class members are
public.
2. By default all the struct members are protected while by default class members
are private.
3. By default all the struct members are public while by default class members are
private.
4. By default all the struct members are public while by default class members are
protected.
int main ()
{
cout << "Hello World!" return 0;
}
1. Hello World
2. Syntax error
3. 0
4. Hello World!
25. The output of this program is :
int a = 10;
void main()
{
int a = 20;
cout << a << ::a;
}
1. Syntax error
2. 10 20
3. 20 10
4. 20 20
26. When class B is inherited from class A, what is the order in which the constructers
of those classes are called
27. Which of the following is a valid destructor of the class name "Country"
1. int ~Country()
2. void Country()
3. int ~Country(Country obj)
4. void ~Country()
class square
{
public:
double side1;
double area()
{
return(side1*side1);
}
};
int main(){
double area1=0;
square c1,c2;
cout << "Enter the length of the square" << endl;
cin >> c1.side;
cout << "The area of the square is : " << c1.area1() << endl;
return(0);
}
1. 16
2. Will result in an error
3. 8
4. 12
1. Yes
2. No
3. yes, depends on the situation
4. Both a and b