InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 51. |
What is the minimum number of levels for a implementing multilevel inheritance?(a) 1(b) 2(c) 3(d) 4This question was addressed to me in an online quiz.The query is from Multilevel Inheritance topic in section Inheritance & its Types of Object Oriented Programming |
|
Answer» The correct choice is (c) 3 |
|
| 52. |
Multilevel inheritance allows _________________ in the program.(a) Only 7 levels of inheritance(b) At least 7 levels of inheritance(c) At most 16 levels of inheritance(d) As many levels of inheritance as requiredI have been asked this question in quiz.Question is taken from Multilevel Inheritance topic in division Inheritance & its Types of Object Oriented Programming |
|
Answer» Right choice is (d) As many LEVELS of inheritance as required |
|
| 53. |
If all the classes use private inheritance in multilevel inheritance then ______________(a) It will not be called multilevel inheritance(b) Each class can access only non-private members of its parent(c) Each subsequent class can access all members of previous level parent classes(d) None of the members will be available to any other classI had been asked this question during an online exam.This intriguing question comes from Multilevel Inheritance topic in division Inheritance & its Types of Object Oriented Programming |
|
Answer» The correct choice is (b) Each class can ACCESS only non-PRIVATE members of its parent |
|
| 54. |
Which Class is having highest degree of abstraction in multilevel inheritance of 5 levels?(a) Class at 1st level(b) Class 2nd last level(c) Class at 5th level(d) All with same abstractionI had been asked this question in an interview for internship.Enquiry is from Multilevel Inheritance in division Inheritance & its Types of Object Oriented Programming |
|
Answer» Right ANSWER is (a) Class at 1st LEVEL |
|
| 55. |
If there are 3 classes. Class C is derived from class B and B is derived from A, Which class destructor will be called at last if object of C is destroyed.(a) A(b) B(c) C(d) All togetherI had been asked this question in an interview.My question is based upon Multilevel Inheritance in division Inheritance & its Types of Object Oriented Programming |
|
Answer» CORRECT answer is (a) A Easiest explanation - The destructors are called in the reverse order of the constructors being called. Hence in MULTILEVEL inheritance, the constructors are created from PARENT to child, which leads to DESTRUCTION from child to parent. Hence CLASS A destructor will be called at last. |
|
| 56. |
If there are 5 classes, E is derived from D, D from C, C from B and B from A. Which class constructor will be called first if the object of E or D is created?(a) A(b) B(c) C(d) A and BThis question was posed to me in an online quiz.My doubt stems from Multilevel Inheritance in portion Inheritance & its Types of Object Oriented Programming |
|
Answer» RIGHT choice is (a) A For EXPLANATION: A is PARENT of all other classes indirectly. Since A is parent of B and B is parent of C and so on till E. Class A CONSTRUCTOR will be called first always. |
|
| 57. |
Which among the following best defines multilevel inheritance?(a) A class derived from another derived class(b) Classes being derived from other derived classes(c) Continuing single level inheritance(d) Class which have more than one parentThis question was posed to me by my college professor while I was bunking the class.My doubt stems from Multilevel Inheritance in chapter Inheritance & its Types of Object Oriented Programming |
|
Answer» The CORRECT OPTION is (b) Classes being DERIVED from other derived classes |
|
| 58. |
If base class contains 2 nested classes, will it be possible to implement single level inheritance?(a) Yes, always(b) Yes, only if derived class also have nested classes(c) No, it will use more than 2 classes which is wrong(d) No, neverThe question was asked during an online interview.The origin of the question is Single Level Inheritance topic in section Inheritance & its Types of Object Oriented Programming |
|
Answer» Right choice is (a) Yes, always |
|
| 59. |
Which constructor will be called first from the classes involved in single inheritance from object of derived class?(a) Base class constructor(b) Derived class constructor(c) Both class constructors at a time(d) Runtime errorThis question was addressed to me during an interview.My doubt is from Single Level Inheritance topic in chapter Inheritance & its Types of Object Oriented Programming |
|
Answer» Right option is (a) Base class constructor |
|
| 60. |
Single level inheritance will be best for___________(a) Inheriting a class which performs all the calculations(b) Inheriting a class which can print all the calculation results(c) Inheriting a class which can perform and print all calculations(d) Inheriting all the classes for different calculationsThe question was asked in an internship interview.Query is from Single Level Inheritance in chapter Inheritance & its Types of Object Oriented Programming |
|
Answer» CORRECT CHOICE is (b) Inheriting a class which can print all the CALCULATION results Best explanation: Inheriting a class which can PERFORM the most common task will be more efficient. If class which can perform all the calculations is inherited then there won’t be any problem to print the result too. But if a class which can do the most common task for all the other tasks, it will make real use of INHERITANCE. |
|
| 61. |
Which concept will result in derived class with more features (consider maximum 3 classes)?(a) Single inheritance(b) Multiple inheritance(c) Multilevel inheritance(d) Hierarchical inheritanceI have been asked this question in class test.This is a very interesting question from Single Level Inheritance in division Inheritance & its Types of Object Oriented Programming |
|
Answer» Right choice is (b) Multiple inheritance |
|
| 62. |
Which among the following is false for single level inheritance?(a) There can be more than 2 classes in program to implement single inheritance(b) There can be exactly 2 classes to implement single inheritance in a program(c) There can be more than 2 independent classes involved in single inheritance(d) The derived class must implement all the abstract method if single inheritance is usedThe question was asked in quiz.My question is from Single Level Inheritance in division Inheritance & its Types of Object Oriented Programming |
|
Answer» Right answer is (C) There can be more than 2 independent classes involved in single inheritance |
|
| 63. |
If single level inheritance is used and an abstract class is created with some undefined functions, can its derived class also skip some definitions?(a) Yes, always possible(b) Yes, possible if only one undefined function(c) No, at least 2 undefined functions must be there(d) No, the derived class must implement those methodsThe question was posed to me during an online interview.I would like to ask this question from Single Level Inheritance in chapter Inheritance & its Types of Object Oriented Programming |
|
Answer» The correct ANSWER is (d) No, the derived CLASS MUST implement those methods |
|
| 64. |
Single level inheritance supports _____________ inheritance.(a) Runtime(b) Compile time(c) Multiple inheritance(d) Language independencyThis question was addressed to me in an internship interview.This interesting question is from Single Level Inheritance topic in section Inheritance & its Types of Object Oriented Programming |
|
Answer» The correct option is (a) Runtime |
|
| 65. |
If single inheritance is used, program will contain ________________(a) At least 2 classes(b) At most 2 classes(c) Exactly 2 classes(d) At most 4 classesThe question was posed to me during an interview for a job.Origin of the question is Single Level Inheritance topic in chapter Inheritance & its Types of Object Oriented Programming |
|
Answer» Correct answer is (a) At least 2 classes |
|
| 66. |
If class A and class B are derived from class C and class D, then ________________(a) Those are 2 pairs of single inheritance(b) That is multilevel inheritance(c) Those is enclosing class(d) Those are all independent classesThis question was posed to me in an international level competition.My question is from Single Level Inheritance in section Inheritance & its Types of Object Oriented Programming |
|
Answer» Correct answer is (a) Those are 2 PAIRS of single INHERITANCE |
|
| 67. |
Which among the following defines single level inheritance?(a) One base class derives another class(b) One derived class inherits from one base class(c) One base class inherits from one derived class(d) One derived class derives from another derived classI have been asked this question by my college professor while I was bunking the class.Question is from Single Level Inheritance in section Inheritance & its Types of Object Oriented Programming |
|
Answer» The CORRECT OPTION is (b) One DERIVED class inherits from one base class |
|
| 68. |
If multi-level inheritance is used, First class B inherits class A, then C inherits B and so on. Till how many classes can this go on?(a) Only till class C(b) Only till class J(c) Only till class Z(d) There is no limitThe question was posed to me in quiz.This intriguing question originated from Types of Inheritance in chapter Inheritance & its Types of Object Oriented Programming |
|
Answer» Right OPTION is (d) There is no limit |
|
| 69. |
How many classes can be inherited by a single class in java?(a) Only 1(b) Only 27(c) Only 255(d) Only 1024The question was posed to me in an interview for job.I need to ask this question from Types of Inheritance in section Inheritance & its Types of Object Oriented Programming |
|
Answer» The CORRECT choice is (a) Only 1 |
|
| 70. |
How many classes can be inherited by a single class in multiple inheritance (C++)?(a) Only 2(b) Only 27(c) Only 1024(d) Any number of classes can be inheritedThe question was asked at a job interview.My doubt stems from Types of Inheritance topic in chapter Inheritance & its Types of Object Oriented Programming |
|
Answer» Right answer is (d) Any NUMBER of CLASSES can be inherited |
|
| 71. |
Which type of inheritance cannot involve private inheritance?(a) Single level(b) Multiple(c) Hybrid(d) All types can have private inheritanceThe question was posed to me in class test.Asked question is from Types of Inheritance topic in section Inheritance & its Types of Object Oriented Programming |
|
Answer» Correct CHOICE is (d) All types can have private inheritance |
|
| 72. |
In hierarchical inheritance, all the classes involve some kind of inheritance.(a) True(b) FalseThe question was asked in an international level competition.This interesting question is from Types of Inheritance topic in division Inheritance & its Types of Object Oriented Programming |
|
Answer» Correct choice is (b) False |
|
| 73. |
If class A has two nested classes B and C. Class D has one nested class E, and have inherited class A. If E inherits B and C, then ________________(a) It shows multiple inheritance(b) It shows hierarchical inheritance(c) It shows multiple inheritance(d) Multiple inheritance among nested classes, and single level for enclosing classesThis question was posed to me during an online interview.This interesting question is from Types of Inheritance topic in section Inheritance & its Types of Object Oriented Programming |
|
Answer» Correct option is (d) MULTIPLE INHERITANCE among NESTED CLASSES, and single level for enclosing classes |
|
| 74. |
Which among the following is false?(a) If one class inherits the inherited class in single level inheritance, it is multi-level inheritance(b) Hybrid inheritance always contains multiple inheritance(c) Hierarchical inheritance involves inheriting same class into more than one classes(d) Hybrid inheritance can involve any types of inheritance togetherI have been asked this question during an online exam.The question is from Types of Inheritance topic in section Inheritance & its Types of Object Oriented Programming |
|
Answer» The CORRECT OPTION is (B) Hybrid inheritance always contains MULTIPLE inheritance |
|
| 75. |
If 6 classes uses single level inheritance with pair classes (3 pairs), which inheritance will this be called?(a) Single(b) Multiple(c) Hierarchical(d) MultilevelThe question was posed to me during a job interview.Query is from Types of Inheritance in division Inheritance & its Types of Object Oriented Programming |
|
Answer» Right option is (a) Single |
|
| 76. |
Which type of inheritance results in the diamond problem?(a) Single level(b) Hybrid(c) Hierarchical(d) MultilevelThis question was posed to me during an interview.This intriguing question comes from Types of Inheritance topic in portion Inheritance & its Types of Object Oriented Programming |
|
Answer» CORRECT answer is (b) Hybrid The best I can explain: In DIAMOND problem, hierarchical inheritance is used FIRST, where TWO different classes inherit the same class and then in TURN a 4th class inherits the two classes which had inherited the first class. Using more than one type of inheritance here, it is known as hybrid inheritance. |
|
| 77. |
How many types of inheritance can be used at a time in a single program?(a) Any two types(b) Any three types(c) Any 4 types(d) Any type, any number of timesThis question was posed to me by my college professor while I was bunking the class.This interesting question is from Types of Inheritance in chapter Inheritance & its Types of Object Oriented Programming |
|
Answer» Right CHOICE is (d) Any type, any number of times |
|
| 78. |
Which among the following best describes multiple inheritance?(a) Two classes being parent of any other classes(b) Three classes being parent of other classes(c) More than one class being parent of other child classes(d) More than one class being parent of single childI had been asked this question during an internship interview.My question is taken from Types of Inheritance in division Inheritance & its Types of Object Oriented Programming |
|
Answer» Right choice is (d) More than one CLASS being PARENT of single child |
|
| 79. |
Which among the following is true?(a) Java supports all types of inheritance(b) Java supports multiple inheritance(c) Java doesn’t support multiple inheritance(d) Java doesn’t support inheritanceI had been asked this question in an international level competition.My question is taken from Types of Inheritance topic in chapter Inheritance & its Types of Object Oriented Programming |
|
Answer» RIGHT answer is (c) Java doesn’t support multiple inheritance Explanation: Java doesn’t support multiple inheritance. This is done to avoid the diamond problem that SOMETIMES arises with inherited FUNCTIONS. Though, multiple inheritance can be IMPLEMENTED in java using interfaces. |
|
| 80. |
How many types of inheritance are possible in C++?(a) 2(b) 3(c) 4(d) 5This question was posed to me in a job interview.Asked question is from Types of Inheritance topic in section Inheritance & its Types of Object Oriented Programming |
|
Answer» The correct option is (d) 5 |
|
| 81. |
How can you make the private members inheritable?(a) By making their visibility mode as public only(b) By making their visibility mode as protected only(c) By making their visibility mode as private in derived class(d) It can be done both by making the visibility mode public or protectedThis question was posed to me in homework.Question is taken from Inheritance topic in section Inheritance & its Types of Object Oriented Programming |
|
Answer» The correct option is (d) It can be done both by making the visibility mode public or protected |
|
| 82. |
The private members of the base class are visible in derived class but are not accessible directly.(a) True(b) FalseThis question was addressed to me in semester exam.I want to ask this question from Inheritance in division Inheritance & its Types of Object Oriented Programming |
|
Answer» Right answer is (a) True |
|
| 83. |
If a derived class object is created, which constructor is called first?(a) Base class constructor(b) Derived class constructor(c) Depends on how we call the object(d) Not possibleI had been asked this question in a job interview.This interesting question is from Inheritance topic in chapter Inheritance & its Types of Object Oriented Programming |
|
Answer» The correct choice is (a) BASE class constructor |
|
| 84. |
While inheriting a class, if no access mode is specified, then which among the following is true? (in C++)(a) It gets inherited publicly by default(b) It gets inherited protected by default(c) It gets inherited privately by default(d) It is not possibleThe question was posed to me in class test.The origin of the question is Inheritance topic in chapter Inheritance & its Types of Object Oriented Programming |
|
Answer» The correct ANSWER is (c) It GETS inherited privately by DEFAULT |
|
| 85. |
Members which are not intended to be inherited are declared as ________________(a) Public members(b) Protected members(c) Private members(d) Private or Protected membersI have been asked this question in homework.Query is from Inheritance in portion Inheritance & its Types of Object Oriented Programming |
|
Answer» The CORRECT answer is (c) Private members |
|
| 86. |
If a base class is inherited in protected access mode then which among the following is true?(a) Public and Protected members of base class becomes protected members of derived class(b) Only protected members become protected members of derived class(c) Private, Protected and Public all members of base, become private of derived class(d) Only private members of base, become private of derived classI had been asked this question by my school teacher while I was bunking the class.I would like to ask this question from Inheritance topic in section Inheritance & its Types of Object Oriented Programming |
|
Answer» Right option is (a) PUBLIC and Protected members of base class BECOMES protected members of derived class |
|
| 87. |
Which access type data gets derived as private member in derived class?(a) Private(b) Public(c) Protected(d) Protected and PrivateI have been asked this question in exam.My question is from Inheritance in portion Inheritance & its Types of Object Oriented Programming |
|
Answer» RIGHT choice is (a) PRIVATE Explanation: It is a RULE, that when a derived class inherits the BASE class in private access mode, all the MEMBERS of base class gets derived as private members of the derived class. |
|
| 88. |
Which type of inheritance leads to diamond problem?(a) Single level(b) Multi-level(c) Multiple(d) HierarchicalI have been asked this question during an interview.Origin of the question is Inheritance topic in portion Inheritance & its Types of Object Oriented Programming |
|
Answer» The correct answer is (c) Multiple |
|
| 89. |
Which is the correct syntax of inheritance?(a) class derived_classname : base_classname{ /*define class body*/ };(b) class base_classname : derived_classname{ /*define class body*/ };(c) class derived_classname : access base_classname{ /*define class body*/ };(d) class base_classname :access derived_classname{ /*define class body*/ };I have been asked this question during an interview.I want to ask this question from Inheritance in chapter Inheritance & its Types of Object Oriented Programming |
|
Answer» Correct choice is (c) class derived_classname : access base_classname{ /*define class body*/ }; |
|
| 90. |
Which among the following is correct for a hierarchical inheritance?(a) Two base classes can be used to be derived into one single class(b) Two or more classes can be derived into one class(c) One base class can be derived into other two derived classes or more(d) One base class can be derived into only 2 classesThe question was asked in an international level competition.I need to ask this question from Inheritance topic in portion Inheritance & its Types of Object Oriented Programming |
|
Answer» The CORRECT OPTION is (c) One base class can be DERIVED into other two derived classes or more |
|
| 91. |
Which programming language doesn’t support multiple inheritance?(a) C++ and Java(b) C and C++(c) Java and SmallTalk(d) JavaThe question was posed to me in an internship interview.Question is from Inheritance in division Inheritance & its Types of Object Oriented Programming |
|
Answer» The correct choice is (d) JAVA |
|
| 92. |
Which among the following is correct for multiple inheritance?(a) class student{public:int marks;}s;class stream{int total;}; class topper:public student, public stream{};(b) class student{int marks;}; class stream{ }; class topper: public student{ };(c) class student{int marks;}; class stream:public student{ };(d) class student{ }; class stream{ }; class topper{ };The question was asked in final exam.My question is taken from Inheritance topic in chapter Inheritance & its Types of Object Oriented Programming |
|
Answer» The correct option is (a) CLASS student{public:int marks;}s;class stream{int total;}; class topper:public student, public stream{}; |
|
| 93. |
Which among the following best defines single level inheritance?(a) A class inheriting a derived class(b) A class inheriting a base class(c) A class inheriting a nested class(d) A class which gets inherited by 2 classesThe question was posed to me by my school teacher while I was bunking the class.Asked question is from Inheritance in portion Inheritance & its Types of Object Oriented Programming |
|
Answer» Right answer is (b) A class INHERITING a base class |
|
| 94. |
How many basic types of inheritance are provided as OOP feature?(a) 4(b) 3(c) 2(d) 1The question was posed to me in an online quiz.The doubt is from Inheritance topic in chapter Inheritance & its Types of Object Oriented Programming |
|
Answer» Right choice is (a) 4 |
|
| 95. |
Which among the following best describes the Inheritance?(a) Copying the code already written(b) Using the code already written once(c) Using already defined functions in programming language(d) Using the data and functions into derived segmentThis question was posed to me during an interview.My question comes from Inheritance in section Inheritance & its Types of Object Oriented Programming |
|
Answer» Correct choice is (d) Using the data and FUNCTIONS into derived segment |
|