Machine-translated by Google. Questions are authored in English.
Top

Inheritance Questions and Answers

1.

Which of the following is/are feature(s) of inheritance in OOPs?

Features:
i) Sub Class
ii) Super Class
iii) Reusability
iv) Operator Overloading

Exam Year(s)

DSSSB TGT - 2023,

Answer: D

The features of inheritance are the sub class, the super class and reusability, so i, ii and iii only. A sub class inherits from a super class and so reuses its code. Operator overloading is a kind of polymorphism, in which an operator is given more than one meaning, and not a feature of inheritance, so iv is wrong, and the options with fewer items are incomplete. Inheritance lets the sub class take the data and methods of the super class and add its own, so code is written once and reused.

Please log in or register to report this question.

2.

The.............. inheritance supports the mechanism of deriving one base class with more than one derived classes.

Exam Year(s)

MH SET - 2018, SET Exam - 2018,

Answer: A

The answer is Hierarchical inheritance.

In hierarchical inheritance several derived classes inherit from one base class, for example Circle, Square and Triangle all derived from Shape. This is the case the question describes: one base class with more than one derived class.

Multiple inheritance is the reverse, one derived class with several base classes. Multilevel inheritance is a chain (A to B to C), and hybrid inheritance is a combination of two or more of these types.

Please log in or register to report this question.

3.

In Java, which keyword prevents a class from being inherited ?

Exam Year(s)

Tripura Public Service Commission - 2026,

Answer: C

A class is protected from inheritance by the keyword final.

A class declared final cannot be extended: any attempt to write class B extends A, where A is final, fails to compile. String and the wrapper classes such as Integer are final for this reason. The same keyword stops a method being overridden or a variable being reassigned.

static marks members that belong to the class rather than to objects. abstract means the opposite of final: an abstract class exists to be inherited. A top-level class cannot be private in Java.

Please log in or register to report this question.

4.

How is generalization implemented in Object Oriented programming languages ?

Exam Year(s)

Tripura Public Service Commission - 2019,

Answer: A

Generalization is implemented through Inheritance.

Generalization is the is-a relationship: the common attributes and behaviour of several classes are moved up into a more general superclass, as Car and Truck generalise to Vehicle. In code this is written as inheritance, with the specific classes extending the general one.

Polymorphism lets one interface behave differently for different types, and encapsulation hides an object's data behind its methods. Abstract classes are often used as the general class, but the relationship itself is implemented by inheritance.

Please log in or register to report this question.

Loading…

Other Subjects

Tags: Inheritance Questions and Answers || Inheritance MCQ Questions and Answers || Inheritance GK Questions and Answers || Inheritance GK MCQ Questions || Inheritance Multiple Choice Questions and Answers || Inheritance GK || GK on Inheritance || Object Oriented Programming Questions and Answers || Object Oriented Programming MCQ Questions and Answers || Object Oriented Programming GK Questions and Answers || GK on Object Oriented Programming