

MCQOPTIONS
Saved Bookmarks
This section includes 41 Mcqs, each offering curated multiple-choice questions to sharpen your C++ Programming knowledge and support exam preparation. Choose a topic below to get started.
1. |
Which of the following statement is correct about the program given below?
#include
|
A. | The program will print the output 1 2 3. |
B. | The program will print the output 2 3 4 . |
C. | The program will print the output 4 5 6. |
D. | The program will report compile time error. |
Answer» C. The program will print the output 4 5 6. | |
2. |
Which of the following means ''The use of an object of one class in definition of another class''? |
A. | Encapsulation |
B. | inheritance |
C. | Composition |
D. | Abstraction |
Answer» D. Abstraction | |
3. |
Which of the following statement is correct about the program given below?
#include
|
A. | The program will print the output 1 2 3. |
B. | The program will print the output 2 3 4 . |
C. | The program will print the output 4 5 6. |
D. | The program will report compile time error. |
Answer» C. The program will print the output 4 5 6. | |
4. |
What will be the output of the following program?
#include
|
A. | 2 |
B. | 3 |
C. | 5 |
D. | 8 |
Answer» C. 5 | |
5. |
Which of the following statement is correct about the program given below?
#include
|
A. | The program will print the output 100. |
B. | The program will print the output 200. |
C. | The program will print the output 400. |
D. | The program will print the output Garbage-value. |
Answer» D. The program will print the output Garbage-value. | |
6. |
Which of the following statement is correct about the program given below?
#include
|
A. | The program will print the output 4 2.5. |
B. | The program will print the output 4. |
C. | The program will report runtime error. |
D. | The program will report compile time error. |
Answer» D. The program will report compile time error. | |
7. |
Which of the following statement is correct about the program given below?
#include
|
A. | The program will print the output 1 2. |
B. | The program will print the output 0 1. |
C. | The program will print the output 1 1. |
D. | The program will print the output 1. |
Answer» E. | |
8. |
What will be the output of the following program?
#include
|
A. | 1 2 |
B. | 10 20 |
C. | 11 22 |
D. | Garbage Garbage |
Answer» D. Garbage Garbage | |
9. |
Which of the following statement is correct about the program given below?
#include
|
A. | The program will print the output 100. |
B. | The program will print the output 200. |
C. | The program will print the output Garbage-value. |
D. | The program will report compile time error. |
Answer» B. The program will print the output 200. | |
10. |
What will be the output of the following program?
#include
|
A. | 1 |
B. | 2 |
C. | 24 |
D. | 25 |
Answer» C. 24 | |
11. |
What will be the output of the following program?
#include
|
A. | The program will print the output 4. |
B. | The program will print the ASCII value of 4. |
C. | The program will print the output 0. |
D. | The program will print the output garbage. |
Answer» B. The program will print the ASCII value of 4. | |
12. |
Which of the following statement is correct about the program given below?
#include
|
A. | The program will print the output me!. |
B. | The program will print the output Wel. |
C. | The program will print the output !em. |
D. | The program will print the output Welcome!. |
Answer» C. The program will print the output !em. | |
13. |
Which of the following statement is correct about the program given below?
#include
|
A. | The program will print the output 100. |
B. | The program will print the output 200. |
C. | The program will print the output Garbage-value. |
D. | The program will report compile time error. |
Answer» C. The program will print the output Garbage-value. | |
14. |
Which of the following statement is correct about the program given below?
#include
|
A. | The program will print the output 0. |
B. | The program will print the output 44. |
C. | The program will print the output Garbage. |
D. | The program will report compile time error. |
Answer» C. The program will print the output Garbage. | |
15. |
What does a class hierarchy depict? |
A. | It shows the relationships between the classes in the form of an organization chart. |
B. | It describes "has a" relationships. |
C. | It describes "kind of" relationships. |
D. | It shows the same relationship as a family tree. |
Answer» D. It shows the same relationship as a family tree. | |
16. |
Which of the following means "The use of an object of one class in definition of another class"? |
A. | Encapsulation |
B. | Inheritance |
C. | Composition |
D. | Abstraction |
Answer» D. Abstraction | |
17. |
What will be the output of the following program?
#include
|
A. | Class A. |
B. | Class B. |
C. | Class C. |
D. | The program will report compile time error. |
Answer» B. Class B. | |
18. |
Which of the following statement is correct about the program given below?
#include
|
A. | The program will print the output 0. |
B. | The program will print the output 33. |
C. | The program will print the output Garbage. |
D. | The program will report compile time error. |
Answer» E. | |
19. |
Which of the following access specifies is used in a class definition by default? |
A. | Protected |
B. | Public |
C. | Private |
D. | Friend |
Answer» D. Friend | |
20. |
What will be the output of the following program?
#include
|
A. | 0   |
B. | 5 |
C. | 10 |
D. | 15 |
Answer» E. | |
21. |
Which of the following statement is correct about the program given below?
#include
|
A. | The program will print the output 0. |
B. | The program will print the output 22. |
C. | The program will print the output Garbage. |
D. | The program will report compile time error. |
Answer» E. | |
22. |
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» D. Friend | |
23. |
Which of the following statements about virtual base classes is correct? |
A. | It is used to provide multiple inheritance. |
B. | It is used to avoid multiple copies of base class in derived class. |
C. | It is used to allow multiple copies of base class in a derived class. |
D. | It allows private members of the base class to be inherited in the derived class. |
Answer» C. It is used to allow multiple copies of base class in a derived class. | |
24. |
Which of the following statements is correct about the constructors and destructors? |
A. | Destructors can take arguments but constructors cannot. |
B. | Constructors can take arguments but destructors cannot. |
C. | Destructors can be overloaded but constructors cannot be overloaded. |
D. | Constructors and destructors can both return a value. |
Answer» C. Destructors can be overloaded but constructors cannot be overloaded. | |
25. |
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» C. Private members of the base class become private members of derived class. | |
26. |
Which of the following keywords is used to control access to a class member? |
A. | Default |
B. | Break |
C. | Protected |
D. | Asm |
Answer» D. Asm | |
27. |
What will be the output of the following program?
#include
|
A. | 0 |
B. | 1 |
C. | -1 |
D. | Garbage value |
Answer» B. 1 | |
28. |
What does the class definitions in following code represent? class Bike { Engine objEng; }; class Engine { float CC; }; |
A. | kind of relationship |
B. | has a relationship |
C. | Inheritance |
D. | Both A and B |
Answer» C. Inheritance | |
29. |
What will be the output of the following program?
#include
|
A. | 45 22 |
B. | 46 22 |
C. | 45 23 |
D. | 46 23 |
Answer» B. 46 22 | |
30. |
Which of the following statements is correct about the program given below? class Bix { public: static void MyFunction(); }; int main() { void(*ptr)() = &Bix::MyFunction; return 0; } |
A. | The program reports an error as pointer to member function cannot be defined outside the definition of class. |
B. | The program reports an error as pointer to static member function cannot be defined. |
C. | The program reports an error as pointer to member function cannot be defined without object. |
D. | The program reports linker error. |
Answer» E. | |
31. |
Which of the following is the only technical difference between structures and classes in C++? |
A. | Member function and data are by default protected in structures but private in classes. |
B. | Member function and data are by default private in structures but public in classes. |
C. | Member function and data are by default public in structures but private in classes. |
D. | Member function and data are by default public in structures but protected in classes. |
Answer» D. Member function and data are by default public in structures but protected in classes. | |
32. |
Which of the following statement is correct with respect to the use of friend keyword inside a class? |
A. | A private data member can be declared as a friend. |
B. | A class may be declared as a friend. |
C. | An object may be declared as a friend. |
D. | We can use friend keyword as a class name. |
Answer» C. An object may be declared as a friend. | |
33. |
Which of the following statements are correct for a static member function? It can access only other static members of its class. It can be called using the class name, instead of objects. |
A. | Only 1 is correct. |
B. | Only 2 is correct. |
C. | Both 1 and 2 are correct. |
D. | Both 1 and 2 are incorrect. |
Answer» D. Both 1 and 2 are incorrect. | |
34. |
Which of the following statements is correct when a class is inherited publicly? |
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» E. | |
35. |
Which of the following statement is correct regarding destructor of base class? |
A. | Destructor of base class should always be static. |
B. | Destructor of base class should always be virtual. |
C. | Destructor of base class should not be virtual. |
D. | Destructor of base class should always be private. |
Answer» C. Destructor of base class should not be virtual. | |
36. |
Which of the following can be overloaded? |
A. | Object |
B. | Functions |
C. | Operators |
D. | Both B and C |
Answer» E. | |
37. |
Which of the following two entities (reading from Left to Right) can be connected by the dot operator? |
A. | A class member and a class object. |
B. | A class object and a class. |
C. | A class and a member of that class. |
D. | A class object and a member of that class. |
Answer» E. | |
38. |
How many objects can be created from an abstract class? |
A. | Zero |
B. | One |
C. | Two |
D. | As many as we want |
Answer» B. One | |
39. |
Which of the following can access private data members or member functions of a class? |
A. | Any function in the program. |
B. | All global functions in the program. |
C. | Any member function of that class. |
D. | Only public member functions of that class. |
Answer» D. Only public member functions of that class. | |
40. |
What will be the output of the following program?
#include
|
A. | 10 10 20 20 |
B. | Garbage garbage 20 20 |
C. | 10 10 Garbage garbage |
D. | Garbage garbage Garbage garbage |
Answer» B. Garbage garbage 20 20 | |
41. |
What happens when we try to compile the class definition in following code snippet? class Birds {}; class Peacock : protected Birds {}; |
A. | It will not compile because class body of Birds is not defined. |
B. | It will not compile because class body of Peacock is not defined. |
C. | It will not compile because a class cannot be protectedly inherited from other class. |
D. | It will compile succesfully. |
Answer» E. | |