Que- What is the identifier given to string class to declare string objects?
a. String
b. string
c. STRING
d. Any of the above can be used
Answer- string
Que- What is the role of a constructor in classes?
a. To modify the data whenever required
b. To destroy an object
c. To initialize the data members of an object when it is created
d. To call private functions from the outer world
Answer- To initialize the data members of an object when it is created
Que- Why constructors are efficient instead of a function init() defined by the user to initialize the data members of an object?
a. Because user may forget to call init() using that object leading segmentation fault
b. Because user may call init() more than once which leads to overwriting values
c. Because user may forget to define init() function
d. All of the mentioned
Answer- All of the mentioned
Que- What is a copy constructor?
a. A constructor that allows a user to move data from one object to another
b. A constructor to initialize an object with the values of another object
c. A constructor to check the whether to objects are equal or not
d. A constructor to kill other copies of a given object.
Answer- A constructor to initialize an object with the values of another object
Que- What happens if a user forgets to define a constructor inside a class?
a. Error occurs
b. Segmentation fault
c. Objects are not created properly
d. Compiler provides a default constructor to avoid faults/errors
Answer- Compiler provides a default constructor to avoid faults/errors
Que- How many parameters does a default constructor require?
a. 1
b. 2
c. 0
d. 3
Answer- 0
Que- How constructors are different from other member functions of the class?
a. Constructor has the same name as the class itself
b. Constructors do not return anything
c. Constructors are automatically called when an object is created
d. All of the mentioned
Answer- All of the mentioned
Que- How many types of constructors are there in C++?
a. 1
b. 2
c. 3
d. 4
Answer- 3
Que- What is the role of destructors in Classes?
a. To modify the data whenever required
b. To destroy an object when the lifetime of an object ends
c. To initialize the data members of an object when it is created
d. To call private functions from the outer world
Answer- To destroy an object when the lifetime of an object ends
Que- What is syntax of defining a destructor of class A?
a. A(){}
b. ~A(){}
c. A::A(){}
d. ~A(){};
Answer- ~A(){}
Que- When destructors are called?
a. When a program ends
b. When a function ends
c. When a delete operator is used
d. All of the mentioned
Answer- All of the mentioned
Que- What is the difference between constructors and destructors?
a. They have a different function name
b. Constructors does not have return type whereas destructors do have
c. Constructors allow function parameters whereas destructors do not
d. Constructors does not function parameters
Answer- Constructors allow function parameters whereas destructors do not
Que- How many Destructors are allowed in a Class?
a. 1
b. 2
c. 3
d. Any number
Answer- 1
Que- Which of the following constructors are provided by the C++ compiler if not defined in a class?
a. Default constructor
b. Assignment constructor
c. Copy constructor
d. All of the mentioned
Answer- All of the mentioned
Que- When a copy constructor is called?
a. When an object of the class is returned by value
b. When an object of the class is passed by value to a function
c. When an object is constructed based on another object of the same class
d. All of the mentioned
Answer- All of the mentioned
Que- How destructor overloading is done?
a. By changing the number of parameters
b. By changing the parameters type
c. By changing both the number of parameters and their type
d. No chance for destructor overloading
Answer- No chance for destructor overloading
Que- Which of the following is correct?
a. Destructors can be virtual
b. There can be more than one destructor in a class
c. Destructor definition starts with !
d. Destructor is used to initialize objects
Answer- Destructors can be virtual
Que- Where is the derived class is derived from?
a. derived
b. base
c. both derived & base
d. class
Answer- base
Que- Pick out the correct statement.
a. A derived class's constructor cannot explicitly invokes its base class's constructor
b. A derived class's destructor cannot invoke its base class's destructor
c. A derived class's destructor can invoke its base class's destructor
d. A derived class's destructor can invoke its base & derived class's destructor
Answer- A derived class's destructor cannot invoke its base class's destructor
Que- Which of the following can derived class inherit?
a. members
b. functions
c. both members & functions
d. classes
Answer- both members & functions
Que- Which operator is used to declare the destructor?
a. #
b. ~
c. @
d. $
Answer- ~
Que- Which constructor will initialize the base class data member?
a. derived class
b. base class
c. class
d. derived & base class
Answer- base class
Que- Which class is used to design the base class?
a. abstract class
b. derived class
c. base class
d. derived & base class
Answer- abstract class
Que- Which is used to create a pure virtual function?
a. $
b. =0
c. &
d. !
Answer- =0
Que- Which is also called as abstract class?
a. virtual function
b. pure virtual function
c. derived class
d. base class
Answer- pure virtual function
Que- What is meant by pure virtual function?
a. Function which does not have definition of its own
b. Function which does have definition of its own
c. Function which does not have any return type
d. Function which does not have any return type & own definition
Answer- Function which does not have definition of its own
Que- Pick out the correct option.
a. We cannot make an instance of an abstract base class
b. We can make an instance of an abstract base class
c. We can make an instance of an abstract super class
d. We can make an instance of an abstract derived class
Answer- We cannot make an instance of an abstract base class
Que- Where does the abstract class is used?
a. base class only
b. derived class
c. both derived & base class
d. virtual class
Answer- base class only
Que- What is an abstract class in C++?
a. Class specifically used as a base class with atleast one virtual functions
b. Class specifically used as a base class with atleast one pure virtual functions
c. Class from which any class is derived
d. Any Class in C++ is an abstract class
Answer- Class specifically used as a base class with atleast one pure virtual functions
Que- What is a pure virtual function in C++?
a. A virtual function defined in a base class
b. A virtual function declared in a base class
c. Any function in a class
d. A function without definition in a base class
Answer- A virtual function declared in a base class
Que- Which is the correct syntax of defining a pure virtual function?
a. pure virtual return_type func();
b. virtual return_type func() pure;
c. virtual return_type func() = 0;
d. virtual return_type func();
Answer- virtual return_type func() = 0;
Que- Which is the correct statement about pure virtual functions?
a. They should be defined inside a base class
b. Pure keyword should be used to declare a pure virtual function
c. Pure virtual function is implemented in derived classes
d. Pure virtual function cannot implemented in derived classes
Answer- Pure virtual function is implemented in derived classes
Que- Pick the correct statement.
a. Pure virtual functions and virtual functions are the same
b. Both Pure virtual function and virtual function have an implementation in the base class
c. Pure virtual function has no implementation in the base class whereas virtual function may have an implementation in the base class
d. The base class has no pure virtual function
Answer- Pure virtual function has no implementation in the base class whereas virtual function may have an implementation in the base class
Que- Which interface determines how your class will be used by another program?
a. public
b. private
c. protected
d. void
Answer- public
Que- Pick out the correct statement about the override.
a. Overriding refers to a derived class function that has the same name and signature as a base class virtual function
b. Overriding has different names
c. Overriding refers to a derived class
d. Overriding has different names & it refers to a derived class
Answer- Overriding refers to a derived class function that has the same name and signature as a base class virtual function
Que- How many ways of reusing are there in the class hierarchy?
a. 1
b. 2
c. 3
d. 4
Answer- 2
Que- How many types of class are there in c++?
a. 1
b. 2
c. 3
d. 4
Answer- 3
Que- Pick out the correct statement about multiple inheritances.
a. Deriving a class from one direct base class
b. Deriving a class from more than one direct base class
c. Deriving a class from more than one direct derived class
d. Deriving a class from more than one direct derivedbase class
Answer- Deriving a class from more than one direct base class
Que- What does inheritance allow you to do?
a. create a class
b. create a hierarchy of classes
c. access methods
d. create a method
Answer- create a hierarchy of classes
Que- What is the syntax of inheritance of class?
a. class name
b. class name: access specifier
c. class name: access specifier class name
d. access specifier class name
Answer- class name: access specifier class name
Que- How many kinds of classes are there in c++?
a. 1
b. 2
c. 3
d. 4
Answer- 2
Que- What is meant by polymorphism?
a. class having many forms
b. class having only single form
c. class having two forms
d. class having four forms
Answer- class having many forms
Que- How many types of inheritance are there in c++?
a. 2
b. 3
c. 4
d. 5
Answer- 5
Que- What is meant by container ship?
a. class contains objects of other class types as its members
b. class contains objects of other class types as its objects
c. class contains objects of other class types as its members 7 also objects
d. class contains objects of other class types as its members 9 also objects
Answer- class contains objects of other class types as its members
Que- How many types of the constructor are there in C++?
a. 1
b. 2
c. 3
d. 4
Answer- 3
Que- How many constructors can present in a class?
a. 1
b. 2
c. 3
d. multiple
Answer- multiple
Que- What should be the name of the constructor?
a. same as the object
b. same as the member
c. same as the class
d. same as the function
Answer- same as the class
Que- What does derived class does not inherit from the base class?
a. constructor and destructor
b. friends
c. operator = () members
d. all of the mentioned
Answer- all of the mentioned
Que- What is a template?
a. A template is a formula for creating a generic class
b. A template is used to manipulate the class
c. A template is used for creating the attributes
d. A template is used to delete the class
Answer- A template is a formula for creating a generic class
Que- Pick out the correct statement about string template.
a. It is used to replace a string
b. It is used to replace a string with another string at runtime
c. It is used to delete a string
d. It is used to create a string
Answer- It is used to replace a string with another string at runtime
Que- How to declare a template?
a. tem
b. temp
c. template<>
d. temp()
Answer- template<>