Que- An object can be used to represent _________________
a. A real world entity
b. A real function
c. Some real data only
d. Some function only
Ans- A real world entity
Que- Objects can be used _____________________
a. To access any member of a class
b. To access only public members of a class
c. To access only protected members of a class
d. To access only private members of a class
Ans- To access only public members of a class
Que- Which among the following is not a use of object?
a. Defining a member function
b. Accessing data members
c. Creating instance of a class
d. Using class members
Ans- Defining a member function
Que- Which object can be used to access the standard input?
a. System.inner
b. cin
c. System.stdin
d. console.input
Ans- cin
Que- A single object can be used __________________
a. As only two class types at a time
b. As only three class types at a time
c. As only one class type at a time
d. As of as many class types as required
Ans- As only one class type at a time
Que- If same object name is given to different objects of different class then _____________
a. Its compile time error
b. Its runtime error
c. It's not an error
d. Program suns smooth
Ans- Its compile time error
Que- Which among the following best describes abstract classes?
a. If a class has more than one virtual function, it's abstract class
b. If a class have only one pure virtual function, it's abstract class
c. If a class has at least one pure virtual function, it's abstract class
d. If a class has all the pure virtual functions only, then it's abstract class
Ans- If a class has at least one pure virtual function, it's abstract class
Que- Can abstract class have main() function defined inside it?
a. Yes, depending on return type of main()
b. Yes, always
c. No, main must not be defined inside abstract class
d. No, because main() is not abstract function
Ans- Yes, always
Que- If there is an abstract method in a class then, ________________
a. Class must be abstract class
b. Class may or may not be abstract class
c. Class is generic
d. Class must be public
Ans- Class must be abstract class
Que- If a class is extending/inheriting another abstract class having abstract method, then _______________________
a. Either implementation of method or making class abstract is mandatory
b. Implementation of the method in derived class is mandatory
c. Making the derived class also abstract is mandatory
d. It's not mandatory to implement the abstract method of parent class
Ans- Either implementation of method or making class abstract is mandatory
Que- Abstract class A has 4 virtual functions. Abstract class B defines only 2 of those member functions as it extends class A. Class C extends class B and implements the other two member functions of class A. Choose the correct option below.
a. Program won't run as all the methods are not defined by B
b. Program won't run as C is not inheriting A directly
c. Program won't run as multiple inheritance is used
d. Program runs correctly
Ans- Program runs correctly
Que- Abstract classes can ____________________ instances.
a. Never have
b. Always have
c. Have array of
d. Have pointer of
Ans- Never have
Que- We ___________________ to an abstract class.
a. Can create pointers
b. Can create references
c. Can create pointers or references
d. Can't create any reference, pointer or instance
Ans- Can create pointers or references
Que- Which among the following is an important use of abstract classes?
a. Header files
b. Class Libraries
c. Class definitions
d. Class inheritance
Ans- Class Libraries
Que- Use of pointers or reference to an abstract class gives rise to which among the following feature?
a. Static Polymorphism
b. Runtime polymorphism
c. Compile time Polymorphism
d. Polymorphism within methods
Ans- Runtime polymorphism
Que- The abstract classes in java can _________________
a. Implement constructors
b. Can't implement constructor
c. Can implement only unimplemented methods
d. Can't implement any type of constructor
Ans- Implement constructors
Que- Can abstract classes have static methods (Java)?
a. Yes, always
b. Yes, but depends on code
c. No, never
d. No, static members can't have different values
Ans- Yes, always
Que- A template class can have _____________
a. More than one generic data type
b. Only one generic data type
c. At most two data types
d. Only generic type of integers and not characters
Ans- More than one generic data type
Que- Which among the following is the proper syntax for the template class?
a. template ;
b. Template ;
c. template T named(T x, T y){ }
d. Template T1 named(T1 x, T2 y){ }
Ans- template T named(T x, T y){ }
Que- Can default arguments be used with the template class?
a. Yes, in some special cases
b. Yes, always
c. No, it must satisfy some specific conditions first
d. No, it can't be done
Ans- Yes, always
Que- What is the syntax to use explicit class specialization?
a. template class myClass<>{ }
b. template class myClass{ }
c. template <> class myClass<>{ }
d. template <> class myClass{ }
Ans- template <> class myClass{ }
Que- Which is the most significant feature that arises by using template classes?
a. Code readability
b. Ease in coding
c. Code reusability
d. Modularity in code
Ans- Code reusability
Que- A template class defines the form of a class _____________________ it will operate.
a. With full specification of the data on which
b. With full specification of the functions on which
c. Without full specification of the data on which
d. Without full specification of the functions on which
Ans- Without full specification of the data on which
Que- What are the two specializations of I/O template classes in C++?
a. 16-bit character and wide characters
b. 8-bit character and wide characters
c. 32-bit character and locale characters
d. 64-bit characters and locale characters
Ans- 8-bit character and wide characters
Que- Can typeid() function be used with the object of generic classes?
a. Yes, only if default type is given
b. Yes, always
c. No, generic data can't be determined
d. No, never possible
Ans- Yes, always
Que- The _____________ class is a specialization of a more general template class.
a. String
b. Integer
c. Digit
d. Math
Ans- String
Que- How is function overloading different from template class?
a. Overloading is multiple function doing same operation, Template is multiple function doing different operations
b. Overloading is single function doing different operations, Template is multiple function doing different operations
c. Overloading is multiple function doing similar operation, Template is multiple function doing identical operations
d. Overloading is multiple function doing same operation, Template is same function doing different operations
Ans- Overloading is multiple function doing similar operation, Template is multiple function doing identical operations
Que- What if static members are declared inside template classes?
a. All instances will share the static variable
b. All instances will have their own static variable
c. All the instances will ignore the static variable
d. Program gives compile time error
Ans- All instances will have their own static variable
Que- If template class is defined, is it necessary to use different types of data for each call?
a. No, not necessary
b. No, but at least two types must be there
c. Yes, to make proper use of template
d. Yes, for code efficiency
Ans- No, not necessary
Que- How many generic types can be given inside a single template class?
a. Only 1
b. Only 3
c. Only 7
d. As many as required
Ans- As many as required
Que- Which is most appropriate definition of a base class?
a. It is parent of any of its derived class
b. It is child of one of the parent class
c. It is most basic class of whole program
d. It is class with maximum number of members
Ans- It is parent of any of its derived class
Que- A base class is also known as _____________ class.
a. Basic
b. Inherited
c. Super
d. Sub
Ans- Super
Que- An abstract class is always a __________ class.
a. Base
b. Derived
c. Template
d. Nested
Ans- Base
Que- How many base classes can a single class inherit in java?
a. 1
b. 2
c. 3
d. As many as required
Ans- 1
Que- How to make a derived class a base class?
a. Change name of the class
b. Use keyword base
c. Make a class derive from it
d. Can't be done
Ans- Make a class derive from it
Que- If a base class is being derived by two other classes, which inheritance will that be called?
a. Single
b. Multiple
c. Multi-level
d. Hierarchical
Ans- Hierarchical
Que- Which among the following must be in a base class?
a. Data members
b. Member functions
c. Access specifiers
d. Nothing
Ans- Nothing
Que- Which type of members can't be accessed in derived classes of a base class?
a. Protected
b. Private
c. Public
d. All can be accessed
Ans- Private
Que- Base class have ________________ of abstraction.
a. Higher degree
b. Lower degree
c. Intermediate
d. Minimum degree
Ans- Lower degree
Que- Always the base class constructors are called ___________ constructor of derived class.
a. Before
b. After
c. Along
d. According to priority of
Ans- Before
Que- Can we call methods of base class using constructor of the derived class?
a. Yes, always
b. Yes, but not always
c. No, never
d. No, but we can call in some cases
Ans- Yes, always
Que- If a base class is inherited from another class and then one class derives it, which inheritance is shown?
a. Multiple
b. Single
c. Hierarchical
d. Multi-level
Ans- Multi-level
Que- How many base classes can a single derived class have in C++?
a. 1
b. 2
c. 3
d. As many as required
Ans- As many as required
Que- Which among the following is best definition of a derived class?
a. A child class
b. A class which inherits one or more classes
c. A class with keyword derived
d. A class with more than one constructor
Ans- A class which inherits one or more classes
Que- Which among the following is inherited by a derived class from base class?
a. Data members only
b. Member functions only
c. All the members except private members
d. All the members of base class
Ans- All the members except private members
Que- If there is a derived class in a program, how many classes must be in that program?
a. 1
b. 2
c. 3
d. 4
Ans- 2
Que- Which members can never be accessed in derived class from the base class?
a. Private
b. Protected
c. Public
d. All except private
Ans- All except private
Que- How many types of inheritance are supported in C++ for deriving a class?
a. 1
b. 2
c. 3
d. 4
Ans- 3
Que- How many derived class can a single base class have?
a. 1
b. 2
c. 3
d. As many are required
Ans- As many are required
Que- Which among the following is correct?
a. Friend function of derived class can access non-private members of base class
b. Friend function of base class can access derived class members
c. Friend function of derived class can access members of only derived class
d. Friend function can access private members of base class of a derived class
Ans- Friend function of derived class can access non-private members of base class
Que- If a class is being derived using more than two base classes, which inheritance will be used?
a. Single
b. Multi-level
c. Hierarchical
d. Multiple
Ans- Multiple
Que- Derived class is also known as ______________ class.
a. Subclass
b. Small class
c. Big class
d. Noticeable class
Ans- Subclass
Que- If class A is derived from another derived class B which is derived from class C, which class will have maximum level of abstraction?
a. Class A
b. Class B
c. Class C
d. All have same level of abstraction
Ans- Class C
Que- If base class is an abstract class then derived class ______________ the undefined functions.
a. Must define
b. Must become another abstract class or define
c. Must become parent class for
d. Must implement 2 definitions of
Ans- Must become another abstract class or define
Que- How many classes can be derived from a derived class?
a. Only 1
b. At most 1
c. At least 1
d. As many as required
Ans- As many as required
Que- Which feature is not related to the derived classes among the following?
a. Inheritance
b. Encapsulation
c. Run time memory management
d. Compile time function references
Ans- Run time memory management
Que- Deriving a class in such a way that that the base class members are not available for further inheritance is known as ___________________
a. Public inheritance
b. Protected inheritance
c. Protected or private inheritance
d. Private inheritance
Ans- Private inheritance