C++ Programming Questions - Set 3

1)   Inline functions may not work ______ . 1. If function contain static variables. 2. If function contain global and register variables. 3. If function returning value consists looping construct(i.e. for, while). 4. If inline functions are recursive. 5. If function contains const value.

a. Only 1,4,5
b. Only 2,3,5
c. Only 1,3,4
d. All of these
Answer  Explanation 

ANSWER: Only 1,3,4

Explanation:
No explanation is available for this question!


2)   Which of the followings is/are not false about friend function ? 1. It can be called / invoked with class object. 2. It has objects as arguments. 3. It can have built-in types as arguments. 4. It must declared only in public part of a class. 5. It does not have this pointer as an argument.

a. Only 2,4
b. Only 1,2,5
c. Only 2,3,5
d. All of these
Answer  Explanation 

ANSWER: Only 2,3,5

Explanation:
No explanation is available for this question!


3)   Default return type of functions in CPP is ____ .

a. void
b. long
c. char
d. Int
Answer  Explanation 

ANSWER: Int

Explanation:
No explanation is available for this question!


4)   Default values for a function are need to be specified from left to right only.

a. True
b. False
Answer  Explanation 

ANSWER: False

Explanation:
No explanation is available for this question!


5)   During a class inheritance in CPP, if the visibility mode or mode of derivation is not provided, then by default visibility mode is ___________.

a. public
b. protected
c. private
d. Friend
Answer  Explanation 

ANSWER: private

Explanation:
No explanation is available for this question!


6)   The derivation of Child class from Base class is indicated by ____ symbol.

a. ::
b. :
c. ;
d. |
Answer  Explanation 

ANSWER: :

Explanation:
No explanation is available for this question!


7)   If we have object from fstream class, then what is the default mode of opening the file?

a. ios::in|ios::out
b. ios::in|ios::out|ios::trunc
c. ios::in|ios::trunc
d. Default mode depends on compiler
Answer  Explanation 

ANSWER: Default mode depends on compiler

Explanation:
No explanation is available for this question!


8)   __________ is return type of is_open() function.

a. int
b. bool
c. float
d. char *
Answer  Explanation 

ANSWER: bool

Explanation:
No explanation is available for this question!


9)   Public data members and member functions of the class are accessible ONLY to the member functions of that class.

a. True
b. False
Answer  Explanation 

ANSWER: False

Explanation:
No explanation is available for this question!


10)   Only functions of the class can access the data of the class and they(functions) provides the interface between data, objects and the program. This kind isolation of the data from direct access by the program is called _______________ .

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

ANSWER: Data Hiding

Explanation:
No explanation is available for this question!


11)   A Constructor that does not have any parameters is called____________ Constructor.

a. Custom
b. Dynamic
c. Static
d. Default
Answer  Explanation 

ANSWER: Default

Explanation:
No explanation is available for this question!


12)   If we have object from ofstream class, then default mode of opening the file is _____ .

a. ios::in
b. ios::out
c. ios::in|ios::trunc
d. ios::out|ios::trunk
Answer  Explanation 

ANSWER: ios::out|ios::trunk

Explanation:
No explanation is available for this question!


13)   _______________ is a member function that is declared within a base class and redefined by derived class.

a. virtual function
b. static function
c. friend function
d. const member function
Answer  Explanation 

ANSWER: virtual function

Explanation:
No explanation is available for this question!


14)   Syntax for Pure Virtual Function is ______________ .

a. virtual void show()==0
b. void virtual show()==0
c. virtual void show()=0
d. void virtual show()=0
Answer  Explanation 

ANSWER: virtual void show()=0

Explanation:
No explanation is available for this question!


15)   Logical expressions produce ____________ type results.

a. explicit
b. garbage
c. bool
d. static
Answer  Explanation 

ANSWER: bool

Explanation:
No explanation is available for this question!


16)   We can initialize a value of static variable of a class only when its object is created. No other initialization is permitted.

a. True
b. False
Answer  Explanation 

ANSWER: False

Explanation:
No explanation is available for this question!


17)   When a base class is privately inherited by the derived class, then_____________ .

a. protected members of the base class become private members of derived class
b. public members of the base class become private members of derived class
c. both a and b
d. only b
Answer  Explanation 

ANSWER: both a and b

Explanation:
No explanation is available for this question!


18)   What is the difference between protected and private access specifiers in inheritance?

a. private member is not inheritable and not accessible in derived class.
b. protected member is inheritable and also accessible in derived class.
c. Both are inheritable but private is accessible in the derived class.
d. Both are inheritable but protected is not accessible in the derived class.
Answer  Explanation 

ANSWER: protected member is inheritable and also accessible in derived class.

Explanation:
No explanation is available for this question!


19)   A friend function does not have 'this' pointer associated with it.

a. True
b. False
Answer  Explanation 

ANSWER: True

Explanation:
No explanation is available for this question!


20)   In nested try blocks, if both inner and outer catch handlers are not able to handle the exception, then ______________ .

a. Compiler executes only executable statements of main().
b. Compiler issues compile time errors about it.
c. Program will be executed without any interrupt.
d. Program will be terminated abnormally.
Answer  Explanation 

ANSWER: Program will be terminated abnormally.

Explanation:
No explanation is available for this question!