Que- Which programming language restricts the use of multiple inheritance?
a. C++
b. PHP
c. SmallTalk
d. Java
Ans- Java
Que- Is it possible to have all the abstract classes as base classes of a derived class from those?
a. Yes, always
b. Yes, only if derived class implements all the methods
c. No, because abstract classes doesn't have constructors
d. No, never
Ans- Yes, only if derived class implements all the methods
Que- If class A inherits class B and class C as ???class A: public class B, public class C {// class body ;}; ???, which class constructor will be called first?
a. Class A
b. Class B
c. Class C
d. All together
Ans- Class B
Que- Why does diamond problem arise due to multiple inheritance?
a. Methods with same name creates ambiguity and conflict
b. Methods inherited from the superclass may conflict
c. Derived class gets overloaded with more than two class methods
d. Derived class can't distinguish the owner class of any derived method
Ans- Methods with same name creates ambiguity and conflict
Que- How many base classes can a derived class have which is implementing multiple inheritance?
a. Only 2
b. At least 2
c. At most 2
d. As many as required
Ans- As many as required
Que- How to overcome diamond problem ?
a. Using alias name
b. Using seperate derived class
c. Using virtual keyword with same name function
d. Can't be done
Ans- Using virtual keyword with same name function
Que- When multiple inheritance is used, which class object should be used in order to access all the available members of parent and derived class ?
a. Derived class object
b. Parent class objects
c. Use Abstract derived class
d. Derive a class from derived class
Ans- Derived class object
Que- If all the members of all the base classes are private then,
a. There won't be any use of multiple inheritance
b. It will make those members public
c. Derived class can still access them in multiple inheritance
d. Compile time error
Ans- There won't be any use of multiple inheritance
Que- Is it compulsory to have constructor for all the classes involved in multiple inheritance?
a. Yes, always
b. Yes, only if no abstract class is involved
c. No, only classes being used should have a constructor
d. No, they must not contain constructors
Ans- Yes, only if no abstract class is involved
Que- If a class contains 2 nested class and is being inherited by another class, will there be any multiple inheritance?
a. No, only single level inheritance is used
b. No, only multilevel inheritance is used
c. Yes, because 3 classes are involved
d. Yes, because more than 1 classes are being derived
Ans- No, only single level inheritance is used
Que- Which members can't be accessed in derived class in multiple inheritance ?
a. Private members of base
b. Public members of base
c. Protected members of base
d. All the members of base
Ans- Private members of base
Que- Can the derived class be made abstract if multiple inheritance is used ?
a. No, because other classes must be abstract too
b. Yes, if all the functions are implemented
c. Yes, if all the methods are predefined
d. No, since constructors won't be there
Ans- No, since constructors won't be there
Que- Which among the following is best to define hierarchical inheritance?
a. More than one classes being derived from one class
b. More than 2 classes being derived from single base class
c. At most 2 classes being derived from single base class
d. At most 1 class derived from another class
Ans- More than one classes being derived from one class
Que- Do members of base class gets divided among all of its child classes ?
a. Yes, equally
b. Yes, depending on type of inheritance
c. No, it's doesn't get divided
d. No, it may or may not get divided
Ans- No, it's doesn't get divided
Que- Each class can inherit the base class ________________
a. Independently using any inheritance
b. Independently with private inheritance only
c. With same type of inheritance
d. With each class using different inheritance only
Ans- Independently using any inheritance
Que- How many classes must be there to implement hierarchical inheritance ?
a. Exactly 3
b. At least 3
c. At most 3
d. At least 1
Ans- At least 3
Que- Base class _______________
a. Can be made abstract
b. Can't be made abstract
c. Must be abstract
d. If made abstract, compile time error
Ans- Can be made abstract
Que- Which access specifiers should be used so that all the derived classes restrict further inheritance of base class members?
a. Private
b. Public
c. Protected
d. Any inheritance type can be used
Ans- Private
Que- How many classes can be derived from the base class using hierarchical inheritance?
a. As many as required
b. Only 7
c. Only 3
d. Up to 127
Ans- As many as required
Que- Which among the following is true ?
a. Hierarchical inheritance is subset of multiple inheritance
b. Hierarchical inheritance is strongest inheritance type
c. Hierarchical inheritance uses only 2 classes for implementation
d. Hierarchical inheritance allows inheritance of common features to more than one class
Ans- Hierarchical inheritance allows inheritance of common features to more than one class
Que- Hierarchical inheritance can be a subset of _________________
a. Hybrid inheritance
b. Multiple inheritance
c. Single level inheritance
d. Multilevel inheritance
Ans- Hybrid inheritance
Que- Which type of inheritance is most suitable for inheriting Same syllabus into different colleges with different streams?
a. Multiple
b. Single
c. Hierarchical
d. Multilevel
Ans- Hierarchical
Que- Which class constructor is called first when an object of derived class is created?
a. Base class constructor
b. Derived class constructor
c. Firstly created derived class constructor
d. Last created derived class constructor
Ans- Base class constructor
Que- Which among the following best defines the hybrid inheritance?
a. Combination of two or more inheritance types
b. Combination of same type of inheritance
c. Inheritance of more than 7 classes
d. Inheritance involving all the types of inheritance
Ans- Combination of two or more inheritance types
Que- How many types of inheritance should be used for hybrid ?
a. Only 1
b. At east 2
c. At most two
d. Always more than 2
Ans- At east 2
Que- If single inheritance is used with class A and B. A is base class. Then class C,D and E where C is base class and D is derived from C, then E is derived from D. Class C is made to inherit from class B. Which is the resultant type ?
a. Single level
b. Multilevel
c. Hybrid
d. Multiple
Ans- Multilevel
Que- Diamond problem includes ____________________ hybrid inheritance
a. Hierarchical and Multiple
b. Hierarchical and Hierarchical
c. Multiple and Multilevel
d. Single, Hierarchical and Multiple
Ans- Hierarchical and Multiple
Que- If __________________ inheritance is done continuously, it is similar to tree structure.
a. Hierarchical
b. Multiple
c. Multilevel
d. Hierarchical and Multiple
Ans- Hierarchical
Que- Which amongst the following is true for hybrid inheritance?
a. Constructor calls are in reverse
b. Constructor calls are priority based
c. Constructor of only derived class is called
d. Constructor calls are usual
Ans- Constructor calls are usual
Que- Which type of inheritance must be used so that the resultant is hybrid?
a. Multiple
b. Hierarchical
c. Multilevel
d. None
Ans- None
Que- The private member's are made public to all the classes in inheritance.
a. True
b. False
c. Partially True
d. None of the mentioned
Ans- False
Que- If hierarchical inheritance requires to inherit more than one class to single class, which syntax is correct? ( A,B,C are class names )
a. hierarchical class A: public B, public C
b. multiple class A: public B, public C
c. many class A: public B, public C
d. class A: public B, public C
Ans- class A: public B, public C
Que- What is the maximum number of classes allowed in hybrid inheritance?
a. 7
b. 127
c. 255
d. As many as required
Ans- As many as required
Que- What is the minimum number of classes to be there in a program implementing hybrid inheritance?
a. 2
b. 3
c. 4
d. No limit
Ans- No limit
Que- If object of lowest level class is created ( last derived class ), _________________ of its parent class constructors are calle
d.
a. Few
b. All
c. Only parent and parent
d. Base and Derived
Ans- Only parent and parent
Que- If hybrid inheritance is used, it mostly shows _______________ feature of OOP.
a. Flexibility
b. Reusability
c. Efficiency
d. Code readability
Ans- Reusability
Que- The sequence of destructors being called while using hybrid inheritance is ____________
a. Reverse of constructors being called
b. Reverse of classes being made
c. Reverse of objects being created
d. Reverse of code calling objects
Ans- Reverse of constructors being called
Que- Virtual function is ______ class function which expected to be redefined in ______ class, so that when reference is made to derived class object using pointer then we can call virtual function to execute ________ class definition version.
a. Base, derived, derived
b. Derived, Derived, Derived
c. Base, derived, base
d. Base, base, derived
Ans- Base, derived, derived
Que- What does a virtual function ensure for an object, among the following?
a. Correct method is called, regardless of the class defining it
b. Correct method is called, regardless of the object being called
c. Correct method is called, regardless of the type of reference used for function call
d. Correct method is called, regardless of the type of function being called by objects
Ans- Correct method is called, regardless of the type of reference used for function call
Que- Virtual functions are mainly used to achieve _____________
a. Compile time polymorphism
b. Interpreter polymorphism
c. Runtime polymorphism
d. Functions code polymorphism
Ans- Runtime polymorphism
Que- Which keyword is used to declare virtual functions?
a. virtual
b. virt
c. anonymous
d. virtually
Ans- virtual
Que- Where the virtual function should be defined?
a. Twice in base class
b. Derived class
c. Base class and derived class
d. Base class
Ans- Base class
Que- The resolving of virtual functions is done at ______________
a. Compile time
b. Interpret time
c. Runtime
d. Writing source code
Ans- Runtime
Que- In which access specifier should a virtual function be defined?
a. Private
b. Public
c. Protected
d. Default
Ans- Public
Que- Virtual functions can never be made _______________
a. Static function
b. Parameterized function
c. Default argument function
d. Zero parameter function
Ans- Static function
Que- Which is must condition for virtual function to achieve runtime polymorphism?
a. Virtual function must be accessed with direct name
b. Virtual functions must be accessed using base class object
c. Virtual function must be accessed using pointer or reference
d. Virtual function must be accessed using derived class object only
Ans- Virtual function must be accessed using pointer or reference