CPP MCQ - 2
CPP MCQ - 2
Answer: Option B
1. Once a reference variable has been defined to refer to a particular variable it can 2. refer to
any other variable.
A. Only 1 is correct.
B. Only 2 is correct.
Answer: Option D
3. Functions can be declared to return a reference type. There are reasons to make such a
declaration/Which of the following reasons are correct?
1.The information being returned is a large enough object that returning a reference is more
efficient than returning a copy.
B. Only 2 is correct.
Answer: Option C
A. Only 1 is correct.
B. Only 2 is correct.
Answer: Option A
D. Both A and C.
Answer: Option C
A. &&
B. &
C. ||
D. !
Answer: Option B
A. Once a reference variable has been defined to refer to a particular variable it can refer
to any other variable.
C. Once a reference variable has been defined to refer to a particular variable it cannot
refer to any other variable.
Answer: Option C
A. Only 1 is correct.
B. Only 2 is correct.
Answer: Option B
A. Only 1 is correct.
B. Only 2 is correct.
Answer: Option D
Answer: Option B
1. Once the variable and the reference are linked they are tied together.
2. Once the reference of a variable is declared another reference of that variable is not
allowed.
A. Only 1 is correct.
B. Only 2 is correct.
Answer: Option A
12. Which of the following statements is correct?
A. Only 1 is correct.
B. Only 2 is correct.
Answer: Option B
A. Pointer
B. Structure
C. Macro
D. Enum
Answer: Option A
B. Once a reference variable has been defined to refer to a particular variable it can refer
to any other variable.
Answer: Option D
B. Once a reference variable has been defined to refer to a particular variable it can refer
to any other variable.
Answer: Option C
A. Only 1 is correct.
B. Only 2 is correct.
Answer: Option C
1. What happens when we try to compile the class definition in following code snippet?
class Birds {};
C. It will not compile because a class cannot be protectedly inherited from other class.
Answer: Option D
A. Friend keyword can be used in the class to allow access to another class.
B. Friend keyword can be used for a function in the public section of a class.
C. Friend keyword can be used for a function in the private section of a class.
Answer: Option D
Answer: Option B
4. Which of the following two entities (reading from Left to Right) can be connected by the
dot operator?
Answer: Option D
Answer: Option B
A. Public members of the base class become protected members of derived class.
B. Public members of the base class become private members of derived class.
C. Private members of the base class become protected members of derived class.
D. Public members of the base class become public members of derived class.
Answer: Option D
7. Which of the following statements is correct about the constructors and destructors?
Answer: Option B
A. Protected
B. Public
C. Private
D. Friend
Answer: Option C
9. Which of the following statement is correct with respect to the use of friend keyword
inside a class?
Answer: Option B
10. Which of the following keywords is used to control access to a class member?
A. Default
B. Break
C. Protected
D. Asm
Answer: Option C
11. Which of the following can access private data members or member functions of a class?
Answer: Option C
12. Which of the following type of data member can be shared by all instances of its class?
A. Public
B. Inherited
C. Static
D. Friend
Answer: Option C
A. Friend Functions
B. Object
C. Member Functions
D. Member Variables
Answer: Option B
B. an object is used
C. a class is declared
Answer: Option A
15. Which of the following statements about virtual base classes is correct?
D. It allows private members of the base class to be inherited in the derived class.
Answer: Option B
A. Zero
B. One
C. Two
D. As many as we want
Answer: Option A
class Bike
Engine objEng;
};
class Engine
float CC;
};
A. kind of relationship
B. has a relationship
C. Inheritance
D. Both A and B
Answer: Option B
18. Which of the following statements is correct when a class is inherited privately?
A. Public members of the base class become protected members of derived class.
B. Public members of the base class become private members of derived class.
C. Private members of the base class become private members of derived class.
D. Public members of the base class become public members of derived class.
Answer: Option B
Answer: Option B
20. What does a class hierarchy depict?
A. It shows the relationships between the classes in the form of an organization chart.
Answer: Option C
A. Object
B. Functions
C. Operators
D. Both B and C
Answer: Option D