C++ Test Questions Set 4

1)   Can constructors be overloaded?

a. Yes
b. No


Answer  Explanation 

ANSWER: Yes

Explanation:
No explanation is available for this question!


2)   Assume class TEST. Which of the following statements is/are responsible to invoke copy constructor?

a. TEST T2(T1)
b. TEST T4 = T1
c. T2 = T1
d. both a and b
e. All of these
Answer  Explanation 

ANSWER: both a and b

Explanation:
No explanation is available for this question!


3)   When overloading unary operators using Friend function,it requires_____ argument/s.

a. Zero
b. One
c. Two
d. None of these.
Answer  Explanation 

ANSWER: One

Explanation:
No explanation is available for this question!


4)   In CPP program, Can we declare and define a user defined function inside a struct as we do in a class ?

a. Yes
b. No
c. Can’t say

Answer  Explanation 

ANSWER: Yes

Explanation:
No explanation is available for this question!


5)    ____________ refers to the act of representing only essential features without including the background details.

a. Data Hiding
b. Data Encapsulation
c. Data Abstraction
d. All of these
Answer  Explanation 

ANSWER: Data Abstraction

Explanation:
No explanation is available for this question!


6)   Runtime polymorphism is achieved only when a virtual function is accessed through a pointer to the base class.

a. True
b. False


Answer  Explanation 

ANSWER: True

Explanation:
No explanation is available for this question!


7)   Find the wrong statement/s about Abstract Class.

a. We can’t create its objects.
b. We can’t create pointers to an abstract class.
c. It contains at least one pure virtual function.
d. We can create references to an abstract class.
Answer  Explanation 

ANSWER: We can’t create pointers to an abstract class.

Explanation:
No explanation is available for this question!


8)   Assigning one or more function body to the same name is called ____________ .

a. Function Overriding
b. Function Overloading
c. Both a and b
d. None of the above
Answer  Explanation 

ANSWER: Function Overloading

Explanation:
No explanation is available for this question!


9)   Function overloading can also be achieved if two or more functions differ only in their return types.

a. True
b. False


Answer  Explanation 

ANSWER: False

Explanation:
No explanation is available for this question!


10)   In nested try block, if inner catch handler gets executed, then _____________ .

a. Program execution stops immediately.
b. Outer catch handler will also get executed.
c. Compiler will jump to the outer catch handler and then executes remaining executable statements of main().
d. Compiler will execute remaining executable statements of outer try block and then the main().
Answer  Explanation 

ANSWER: Compiler will execute remaining executable statements of outer try block and then the main().

Explanation:
No explanation is available for this question!


11)   A function can be declared as friend maximum only in two classes.

a. True
b. False


Answer  Explanation 

ANSWER: False

Explanation:
No explanation is available for this question!


12)   Which of the following statements are not true about destructor?

1. It is invoked when object goes out of the scope
2. Like constructor, it can also have parameters
3. It can be virtual
4. It can be declared in private section
5. It bears same name as that of the class and precedes Lambda sign.


a. Only 2, 3, 5
b. Only 2, 3, 4
c. Only 2, 4, 5
d. Only 3, 4, 5
Answer  Explanation 

ANSWER: Only 2, 4, 5

Explanation:
No explanation is available for this question!


13)   When a child class inherits traits from more than one parent class, this type of inheritance is called _______________ inheritance.

a. Hierarchical
b. Hybrid
c. Multilevel
d. Multiple
Answer  Explanation 

ANSWER: Multiple

Explanation:
No explanation is available for this question!


14)   In case of inheritance where both base and derived class are having constructor and destructor, then which if the following are true ?

1. Constructors are executed in their order of derivation
2. Constructors are executed in reverse order of derivation
3. Destructors are executed in their order of derivation
4. Destructors are executed in reverse order of derivation


a. Only 2 ,4
b. Only 1 , 3
c. Only 1 , 4
d. Only 2, 3
Answer  Explanation 

ANSWER: Only 1 , 4

Explanation:
No explanation is available for this question!


15)    __________________ is the OOP feature and mechanism that binds together code and the data it manipulates, and keep both safe from outside world.

a. Data Binding
b. Data Encapsulation
c. Data Storing
d. Data Abstraction
Answer  Explanation 

ANSWER: Data Encapsulation

Explanation:
No explanation is available for this question!


16)   Which of the followings is/are not keyword/s in CPP?

1. asm
2. boolean
3. mutable
4. export
5. constant_cast


a. Only 5
b. Only 1 and 4
c. Only 1,2 and 5
d. Only 2 and 5
Answer  Explanation 

ANSWER: Only 2 and 5

Explanation:
No explanation is available for this question!


17)   We can create objects of the abstract class.

a. True
b. False


Answer  Explanation 

ANSWER: False

Explanation:
No explanation is available for this question!


18)   Which of the followings are true about Virtual functions?

a. They must be non-static member function of the class
b. They cannot be friends
c. Constructor Functions cannot be virtual
d. All of these
Answer  Explanation 

ANSWER: All of these

Explanation:
No explanation is available for this question!


19)   If a class contains static variable, then every object of the class has its copy of static variable.

a. True
b. False


Answer  Explanation 

ANSWER: False

Explanation:
No explanation is available for this question!


20)   Which of the following are member dereferencing operators in CPP?

1. *
2. ::
3. ->*
4. ::*
5. ->


a. Only 1, 3, 4
b. Only 1 and 5
c. Only 3 and 4
d. Only 3,4,5
Answer  Explanation 

ANSWER: Only 1, 3, 4

Explanation:
No explanation is available for this question!


21)   In Multipath inheritance, in order to remove duplicate set of records in child class, we ___________ .

a. Write Virtual function in parent classes
b. Write virtual functions is base class
c. Make base class as virtual base class
d. All of these
Answer  Explanation 

ANSWER: Make base class as virtual base class

Explanation:
No explanation is available for this question!


22)   If base class has constructor with arguments, then it is ________________ for the derived class to have constructor and pass the arguments to base class constructor.

a. Optional
b. Mandatory
c. Compiler dependent
d. Error
Answer  Explanation 

ANSWER: Mandatory

Explanation:
No explanation is available for this question!


23)   Using friend operator function, following perfect set of operators may not be overloaded.

a. = , ( ) , [ ] , ->
b. <<, = = , [ ] , >>
c. ?, = , ( ) , ++
d. None of these
Answer  Explanation 

ANSWER: = , ( ) , [ ] , ->

Explanation:
No explanation is available for this question!


24)   An operator function is created using _____________ keyword.

a. iterator
b. allocator
c. constructor
d. operator
Answer  Explanation 

ANSWER: operator

Explanation:
No explanation is available for this question!


25)   Classes in CPP are________ .

a. derived data types
b. User defined data types
c. built-in data types
d. All of these
Answer  Explanation 

ANSWER: User defined data types

Explanation:
No explanation is available for this question!