C++ Programming Questions - Set 5

1)   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!


2)   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!


3)   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!


4)   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!


5)   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!


6)   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!


7)   __________________ 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!


8)   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!


9)   We can create objects of the abstract class.

a. True
b. False
Answer  Explanation 

ANSWER: False

Explanation:
No explanation is available for this question!


10)   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!


11)   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!


12)   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!


13)   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!


14)   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!


15)   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!


16)   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!


17)   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!


18)   Can we define our exceptions in CPP?

a. Yes
b. No
Answer  Explanation 

ANSWER: Yes

Explanation:
No explanation is available for this question!


19)   The code of statements which may cause abnormal termination of the program should be written under_________ block.

a. Try
b. catch
c. Finally
d. None of these
Answer  Explanation 

ANSWER: Try

Explanation:
No explanation is available for this question!


20)   Object based language differs from object oriented language as it does not support features _____ . 1. Encapsulation 2. Inheritance 3. Dynamic Binding 4. Abstraction 5. Polymorphism

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

ANSWER: Only 2,3

Explanation:
No explanation is available for this question!