
Q1. Which of the following is a static polymorphism mechanism?
A. Function overloading
B. Operator overloading
C. Templates
D. All of the mentioned
Show Answer
Answer:-D. All of the mentionedExplanation
All the options mentioned above uses static polymorphism mechanism. As the conflicts in all these types of functions are resolved during compile-time.Q 2. Which of the following is true?
I) All operators in C++ can be overloaded.
II) The basic meaning of an operator can be changed.
A. I only
B. II only
C. Both I and II
D. Neither I nor II
Show Answer
Answer:-D. Neither I nor IIExplanation
Both statements are false because all the operators of C++ cannot be overloaded and the basic meaning of an operator cannot be changed, we can only give new meaning to an operator.Q 3. Which of the following is not a type of inheritance?
A. Multiple
B. Multilevel
C. Distributive
D. Hierarchical
Show Answer
Answer:-C. DistributiveExplanation
Distributive is not a type of inheritance whereas others are a type of inheritance having their own meaning.Q 4. What happens if a class does not have a name?
A. It will not have a constructor
B. It will not have a destructor
C. It is not allowed
D. It will neither have a constructor or destructor
Show Answer
Answer:-B. It will not have a destructorExplanation
A class without a name will not have a destructor. The object is made so constructor is required but the destructor is not. Check the code below: #includeQ 5. Which of the following statement is true?
I) In Procedural programming languages, all function calls are resolved at compile-time
II) In Object Oriented programming languages, all function calls are resolved at compile-time
A. I only
B. II only
C. Both I and II
D. Neither I nor II
Show Answer
Answer:-A. I onlyExplanation
In Procedural programming like C we don’t have the concept of polymorphism, therefore, all the function calls are resolved at the compile-time but in case of OOP languages sue to polymorphism concept all function calls are not resolved at compile-time.Q 6. Which members are inherited but are not accessible in any case?
A. Private
B. Public
C. Protected
D. Both private and protected
Show Answer
Answer:-A. PrivateExplanation
Private members of a class are inherited to the child class but are not accessible from the child class.Q 7. Which of the following is correct?
A. Friend functions can access public members of a class
B. Friend functions can access protected members of a class
C. Friend functions can access private members of a class
D. All of the mentioned
Show Answer
Answer:-D. All of the mentionedExplanation
Friend functions can access any member of a class without caring about the type of member i.e. without caring whether it is private, protected or public.Q 8. Which of the following is correct in C++?
A. Classes cannot have protected data members
B. Structures can have member functions
C. Class members are public by default
D. Structure members are private by default
Show Answer
Answer:-B. Structures can have member functionsExplanation
Though C does not allows member functions in structures but C++ allows structures to have member functions. Members of structures are public by default and those of classes are private by default. Classes can have protected data members.Q 9. Which of the following is used to make an abstract class?
A. By using virtual keyword in front of a class declaration
B. By using an abstract keyword in front of a class declaration
C. By declaring a virtual function in a class
D. By declaring a pure virtual function in a class
Show Answer
Answer:-D. By declaring a pure virtual function in a classExplanation
Abstract class should have at least one pure virtual function. Therefore to declare an abstract class one should declare a pure virtual function in a class.Q 10. Which of the following is correct?
A. A class is an instance of its objects
B. An object is an instance of its class
C. A class is an instance of the data type that the class have
D. An object is an instance of the data type of the class
Show Answer
Answer:-B. An object is an instance of its classExplanation
An object is an instance of a class i.e. an object represents a class i.e. what class has(data members) and what it can do(member functions).Q 11. Which of the following is correct?
A. C++ allows static type checking
B. C++ allows dynamic type checking.
C. C++ allows static member function to be of type const.
D. C++ allows both static and dynamic type checking
Show Answer
Answer:-D. C++ allows both static and dynamic type checkingExplanation
C++ allows both static and dynamic type checking i.e. types are checked by the compiler.Q 12. Which of the following supports the concept that reusability is a desirable feature of a language?
A. It reduces the testing time
B. It reduces maintenance cost
C. It decreases the compilation time
D. It reduced both testing and maintenance time
Show Answer
Answer:-D. It reduced both testing and maintenance timeExplanation
As we will be using the existing code therefore we don’t need to check the code again and again so testing and maintenance time decreases but the compiler time may increase or remains same because though we are reusing the code but every part needs to be compiled and extra include statement needs to be executed therefore compilation time may remain same or increases.Q 13. Which operator is overloaded for a cout object?
A. >>
B. <<
C. <
D. >
Show Answer
Answer:-B. <<Explanation
cout in C++ uses << operator to print anything so << operator is overloaded for a cout object.Q 14. Which of the following cannot be used with the virtual keyword?
A. Class
B. Member functions
C. Constructors
D. Destructors
Show Answer
Answer:-C. ConstructorsExplanation
Virtual keyword cannot be used with constructors as constructors are defined to initialized an object of particular class hence no other class needs constructor of other class.Q 15. Which concept is used to implement late binding?
A. Virtual functions
B. Operator functions
C. Constant functions
D. Static functions
Leave a Reply