Explore topic-wise InterviewSolutions in .

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

Easiest explanation - There must be at least 3 levels of INHERITANCE. Otherwise if less, it will be SINGLE level inheritance or would have GOT no inheritance implemented. There must be a derived CLASS from which ANOTHER class is derived.

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

Easy EXPLANATION - The multilevel inheritance allows any number of levels of inheritance. This is the maximum flexibility feature to MAKE the members available to all the new classes and to add their own functionalities. The code REUSABILITY is USED too.

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

Best explanation: The CLASSES will be able to access only the non-private members of its parent class. The classes are using private inheritance, hence all the members of the parent class BECOME private in the derived class. In turn those won’t be allowed for further inheritance or DIRECT access outside the class.

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

Explanation: The class with HIGHEST degree of abstraction will be the class at the 1st level. You can look at a SIMPLE example like, a CAR is more abstract than SPORTS CAR class. The level of abstraction decrease with each level as more details comes out.

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

Best explanation: Only if the class is being derived from other derived class, it can be called as multilevel inheritance. If a class is derived from another class, it is SINGLE LEVEL inheritance. There must be more than one level of inheritance.

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

To explain: The nested classes are also members of a CLASS. They BEHAVE as a used defined data type with some methods implementation. So the INHERITANCE will be as usual with the nested classes being member of BASE class and of derived class if not private.

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

To EXPLAIN I would say: The base class constructor will be called first from the OBJECT of derived class constructor. When the derived class members are to be initialized and allocated memory, the base class members should ALSO be confirmed with the memory allocation.

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

The best explanation: If single inheritance is used then only feature of a single class are inherited, and if multilevel inheritance is used, the 2ND class might have use private inheritance. Hence only multiple inheritance can RESULT in derived class with more features. This is not MANDATORY but in a CASE if we CONSIDER same number of features in each class, it will result the same.

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

Best EXPLANATION: If more than 2 independent classes are involved to implement the single level inheritance, it won’t be POSSIBLE as there must be only one child and one parent CLASS and none other related class.

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

The best explanation: The derived class must implement those methods. This is because the parent class is abstract and hence will have some undefined functions which has to be defined in derived classes. Since we are using single level inheritance, if derived class doesn’t implement those functions then one more class has to be there which will BECOME multi-level inheritance.

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

To explain I WOULD SAY: The runtime inheritance is done when object of a class is created to call a method. At runtime the FUNCTION is searched if it is in class of object. If not, it will SEARCH in its parent classes and hierarchy for that method.

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

Easy explanation - The PROGRAM will contain at least 2 classes in the SENSE of base and DERIVED classes. At least one base CLASS and one derived class must be there. TYPES of inheritance remains the same though.

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

Explanation: Since class A is DERIVED from class C and then class B is derived from class D, there are two pairs of classes which shows single inheritance. Those two pairs are INDEPENDENT of each other though.

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

The BEST explanation: If only one base class is used to derive only one subclass, it is known as single level inheritance. The reason of this NAME is that we inherit the base class to one more level and stop the inheritance any further.

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

Easy explanation - In this case, there is no limit. All the classes going on like this will INHERIT the MEMBERS of base class, and hence the upper level inheritance won’t affect the number of classes that can go on INHERITING in this pattern.

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

Easy EXPLANATION - SINCE java doesn’t support multiple inheritance, it is not possible for a class to inherit more than 1 class in java. This is the same case in C# also.

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

The best EXPLANATION: Any class can inherit any number of classes. There is no LIMIT defined for the number of classes being inherited by a single class.

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

The best EXPLANATION: This is a COMMON TYPE of inheritance where the PROTECTED and public members of parent class become private members in child class. There is no type which doesn’t support 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

To explain I would say: This is so because few CLASSES might not be involved in any type of inheritance in WHOLE PROGRAM whereas other classes might be PARTICIPATING in more than ONE type of inheritance at the same time.

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

Explanation: This involves the same concept of inheritance, where the nested classes also follow the inheritance RULES. The Enclosing classes are having single inheritance. Nested classes involves multiple.

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

Easiest explanation - It is not necessary to have multiple inheritance in hybrid TYPE. It can have any type together. This doesn’t have to be of specific type always.

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

The EXPLANATION is: Here all the pairs are using single inheritance. And no DIFFERENT pairs are INHERITING same classes. Hence it can’t be called hybrid or multilevel inheritance. You can say the single inheritance is used 3 times in that program.

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

The best EXPLANATION: Any type of inheritance can be used in any PROGRAM. There is no rule to USE only few types of inheritance. Only thing that matters is how the CLASSES are inherited and used.

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

Explanation: If a class inherits more than one class, it is known as multiple inheritance. This should not be REFERRED with only two or three CLASSES being INHERITED. But there must be one class which inherits more than one class to be called as multiple inheritance.

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

To explain I would say: There are five types of INHERITANCE that are possible in C++. Single LEVEL, Multilevel, multiple, hierarchical and hybrid. Here we count hybrid also because it sometimes can bring up a new form of inheritance, Like inheritance USING multiple and hierarchical, which sometimes RESULTS in diamond problem.

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

The EXPLANATION is: It is not mandatory that you have to MAKE the visibility mode either public or protected. You can do either of those. That will GIVE you permission to inherit the PRIVATE members of BASE class.

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

To explain I would say: Consider that a variable is PRIVATE in base class and the derived class USES public INHERITANCE to inherit that class. Now if we also have a global variable of same name as that of base class private variable, neither the global variable nor the base class private variable will be accessible from derived class. This is because we can’t have 2 variables with same name in same LOCAL scope. Hence the private members are accessible but not DIRECTLY.

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

Best explanation: First the base class constructor is INVOKED. When we create a derived class OBJECT, the system tries to invoke its constructor but the class is derived so first the base class must be INITIALIZED, HENCE in turn the base class constructor is invoked before the derived 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

Explanation: If the ACCESS mode is not specified during inheritance, the class is inherited privately by default. This is to ensure the security of data and to maintain OOP features. Hence it is not mandatory to specify the access mode if we want the class to be inherited privately.

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

Easiest explanation - Private access specifier is the most secure access mode. It doesn’t ALLOW members to be INHERITED. Even Private INHERITANCE can only INHERIT protected and public 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

The explanation: As the programming language rules apply, all the public and protected members of base class becomes protected members of derived class in protected ACCESS mode. It can’t be changed because it would HINDER the security of data and may ADD vulnerability in the program.

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

Best EXPLANATION: When 2 or more classes inherit the same class using multiple inheritance and then ONE more class inherits those two base classes, we get a diamond like structure. Here, ambiguity ARISES when same FUNCTION gets derived into 2 base classes and finally to 3rd level class because same NAME functions are being inherited.

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*/ };

The explanation is: Firstly, keyword class should come, followed by the derived class NAME. COLON is MUST followed by access in which BASE class has to be derived, followed by the base class name. And finally the body of class. Semicolon after the body is also must.

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

Best explanation: One base class can be derived into the other two derived classes or more. If only one class GETS derived by only 2 other classes, it is also hierarchical INHERITANCE, but it is not a mandatory condition, because any number of derived classes can be there.

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

The explanation is: Java doesn’t support multiple inheritance. But that feature can be implemented by using the interfaces concept. Multiple inheritance is not supported because of diamond PROBLEM and similar issues.

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{};

The best explanation: Class topper is getting DERIVED from 2 other CLASSES and hence it is multiple INHERITANCE. Topper inherits class stream and class student PUBLICLY and hence can use its features. If only few classes are defined, there we are not even using inheritance (as in option class student{ }; class stream{ }; class topper{ };).

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

Easiest explanation - A class inheriting a base class DEFINES single level inheritance. Inheriting an already DERIVED class makes it MULTILEVEL inheritance. And if base class is inherited by 2 other classes, it is multiple inheritance.

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

The explanation: There are BASICALLY 4 types of inheritance provided in OOP, namely, single level, MULTILEVEL, multiple and HIERARCHICAL inheritance. We can add ONE more type as HYBRID inheritance but that is actually the combination any types of inheritance from the 4 basic ones.

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

To explain I would say: It can only be indicated by using the data and functions that we USE in derived class, being PROVIDED by parent class. COPYING code is nowhere similar to this concept, also using the code already written is same as copying. Using already defined functions is not inheritance as we are not adding any of our own features.