SlideShare a Scribd company logo
MCQs BANK
Page: 1
Object Oriented
Programming
Topic: Inheritance
Instructions:
This MCQs Bank contains question
and solution on adjacent(even-odd)
pages. First try to solve the MCQ by
yourself, then look for the solution.
Best viewed in “single page view”
in PDF viewer.
MCQs BANK No.: 6
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 1
___________ allows the creation
of hierarchical classifications in
object-oriented programming and
helps to create a general class that
defines traits common to a set of
related items. Fill in the blank.
a) Encapsulation
b) Inheritance
c) Data Hiding
d) Polymorphism
Page: 2
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 1 (Solution)
Ans: b) Inheritance
Explanation: Inheritance allows the
creation of hierarchical classifications in
object-oriented programming. Using
inheritance, you can create a general
class that defines traits common to a set
of related items. This class can then be
inherited by other, more specific classes,
each adding those things that are unique
to it. The idea of inheritance is simple but
powerful: When you want to create a
new class and there is already a class
that includes some of the code that you
want, you can derive your new class
from the existing class. In doing this, you
can reuse the fields and methods of the
existing class without having to write
(and debug!) them yourself..
Page: 3
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 2
In the terminology of Java, a class
that is inherited is called a
___________. Fill in the blank.
a) superclass
b) subclass
c) constructor class
d) destructor class
Page: 4
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 2 (Solution)
Ans: a) superclass
Explanation: In the terminology of
Java, a class that is inherited is
called a superclass. A class that is
derived from another class is
called a subclass (also a derived
class, extended class, or child
class). The class from which the
subclass is derived is called a
superclass (also a base class or a
parent class).
Page: 5
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 3
In the terminology of Java, a class
that does the inheriting is called a
________. Fill in the blank.
a) superclass
b) subclass
c) constructor class
d) destructor class
Page: 6
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 3 (Solution)
Ans: b) subclass
Explanation:
In the terminology of Java, a class
that does the inheriting is called a
subclass. A class that is derived
from another class is called a
subclass (also a derived class,
extended class, or child class). The
class from which the subclass is
derived is called a superclass (also
a base class or a parent class).
Page: 7
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 4
Excepting Object, which has no
superclass, every class has one
and only one direct superclass
(single inheritance). In the absence
of any other explicit superclass,
every class is implicitly a subclass
of Object. True or False
a) True
b) False
Page: 8
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 4 (Solution)
Ans: a) True
Explanation:
Excepting Object, which has no
superclass, every class has one and only
one direct superclass (single inheritance).
In the absence of any other explicit
superclass, every class is implicitly a
subclass of Object.
Classes can be derived from classes that
are derived from classes that are derived
from classes, and so on, and
ultimately derived from the topmost class,
Object. Such a class is said to be
descended from all the classes in the
inheritance chain stretching back to
Object.
Page: 9
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 5
The subclass inherits members of
the superclass and hence
promotes _______. Fill in the
blank.
a) polymorphism
b) code reuse
c) code rewrite
d) multiple inheritance
Page: 10
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 5 (Solution)
Ans: b) code reuse
Explanation:
The subclass inherits members of
the superclass and hence promotes
code reuse. The subclass itself can
add its own new behavior and
properties.
Page: 11
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 6
Private members of the superclass
are not inherited by the subclass.
True or False
a) True
b) False
Page: 12
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 6 (Solution)
Ans: a) True
Explanation:
Private members of the superclass
are not inherited by the subclass
and can only be indirectly
accessed(using public methods).
A subclass inherits all of the public
and protected members of its
parent, no matter what package
the subclass is in.
Page: 13
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 7
A subclass must use the
__________ keyword to derive from
a super class which must be written
in the header of the subclass
definition. Fill in the blank.
a) extends
b) import
c) static
d) super
Page: 14
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 7 (Solution)
Ans: a) extends
Explanation:
A subclass must use the extends
keyword to derive from a super
class which must be written in the
header of the subclass definition.
Page: 15
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 8
Since constructors and initializer
blocks are not members of a class,
they are not inherited by a subclass.
True or False
a) True
b) False
Page: 16
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 8 (Solution)
Ans: a) True
Explanation:
A subclass inherits all the members
(fields, methods, and nested
classes) from its superclass.
Constructors are not members, so
they are not inherited by subclasses,
but the constructor of the superclass
can be invoked from the subclass.
Page: 17
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 9
You can write a subclass
constructor that invokes the
constructor of the superclass,
either implicitly or by using the
keyword ________. Fill in the
blank.
a) default
b) super
c) extends
d) final
Page: 18
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 9 (Solution)
Ans: b) super
Explanation: A parent class
constructor is not inherited in child
class and this is why super() is
added automatically in child class
constructor if there is no explicit call
to super or this.
Page: 19
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 10
You can write a new instance
method in the subclass that has the
same signature as the one in the
superclass, this is called
__________________. Fill in the
blank
a) method calling
b) method overriding
c) method overloading
d) method hiding
Page: 20
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 10 (Solution)
Ans: b) method overriding
Explanation: You can write a new
instance method in the subclass that
has the same signature as the one in
the superclass, thus overriding it. If
subclass (child class) has the same
method as declared in the parent
class, it is known as method
overriding in Java. In other words, If
a subclass provides the specific
implementation of the instance
method that has been declared by
one of its parent class, it is known as
method overriding.
Page: 21
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 11
You can write a new static method
in the subclass that has the same
signature as the one in the
superclass, this is called
_____________. Fill in the blank.
a) method calling
b) method overriding
c) method overloading
d) method hiding
Page: 22
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 11 (Solution)
Ans: d) method hiding
Explanation:
Method hiding may happen in any
hierarchy structure in java. When a
child class defines a static method
with the same signature as a static
method in the parent class, then the
child's method hides the one in the
parent class.
Page: 23
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 12
You can declare new methods in
the subclass that are not in the
superclass. True or False
a) True
b) False
Page: 24
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 12 (Solution)
Ans: a) True
Explanation:
You can declare new methods in the
subclass that are not in the
superclass. The inherited methods
can be used directly as they are. You
can write a new instance method in
the subclass that has the same
signature as the one in the
superclass, thus overriding it.
Page: 25
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 13
A subclass can call a constructor
defined by its superclass by use of
_________. Fill in the blank.
a) super(parameter-list);
b) super class name
c) constructor(parameter-list);
d) default(parameter-list);
Page: 26
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 13 (Solution)
Ans: a) super(parameter-list);
Explanation:
A subclass can call a constructor
method defined by its superclass by
use of the following form of super:
super(parameter-list);
Here, parameter-list specifies any
parameters needed by the
constructor in the superclass.
super( ) must always be the first
statement executed inside a
subclass’ constructor.
Page: 27
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 14
If we want to refer a member of the
superclass of a subclass, we have
to use _____________. Fill in the
blank.
a) super.member
b) default.member
c) parent.member
d) base-class.member
Page: 28
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 14 (Solution)
Ans: a) super.member
Explanation: The second form of
super acts somewhat like this, except
that it always refers to the superclass
of the subclass in which
it is used. This usage has the
following general form:
super.member
Here, member can be either a method
or an instance variable. This second
form of super is most applicable to
situations in which member names of
a subclass hide members by the
same name in the superclass.
Page: 29
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 15
Which of the following correctly
explains multi-level inheritance.
a) one class extends one class
only
b) the ladder of single inheritance
increases
c) one class directly extends more
than one class
d) none of these
Page: 30
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 15 (Solution)
Ans: b) the ladder of single
inheritance increases
Explanation:
When a class extends a class, which
extends another class then this is
called multilevel inheritance. For
example class C extends class B
and class B extends class A then this
type of inheritance is known as
multilevel inheritance.
Page: 31
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 16
Java supports multiple inheritance
partially through _____________ .
Fill in the blank.
a) inheritance
b) interfaces
c) multiple packages
d) multi-level inheritance
Page: 32
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 16 (Solution)
Ans: b) interfaces
Explanation:
In multiple inheritance, one class
extends multiple classes. Java does
not support multiple inheritance but
C++ supports. Java supports
multiple inheritance partially through
interfaces.
Page: 33
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 17
If one class is extended by many
subclasses, then the type of
inheritance is called __________ .
Fill in the blank.
a) Multi-Level Inheritance
b) Hierarchical Inheritance
c) Multiple Inheritance
d) Single Inheritance
Page: 34
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 17 (Solution)
Ans: b) Hierarchical Inheritance
Explanation: In hierarchical type of
inheritance, one class is extended by many
subclasses. It is one-to-many relationship.
A realtime example is available at dynamic
binding. For example, Bird class is
extended by two classes – Parrot and
Vulture. Both classes can make use of the
methods of Bird. Even though the Parrot
and Vulture are subclasses of the same
class Bird, but still they cannot makeuse of
each other members. Parrot and Vulture
are known as "siblings". Siblings are
disjoint and they cannot make use of other
members as between them no inheritance
is involved (like two sons of a father; one
son's property cannot be shared by other
but both can share the property of father).
Page: 35
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 18
Which of the following are the
disadvantages of Inheritance
a) Both classes (super and
subclasses) are tightly-coupled.
b) As they are tightly coupled
(binded each other strongly with
extends keyword), they cannot
work independently of each other.
c) Changing the code in super
class method also affects the
subclass functionality.
d) All of the above.
Page: 36
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 18 (Solution)
Ans: d) All of the above.
Explanation:
Disadvantages of Inheritance
1. Both classes (super and subclasses)
are tightly-coupled.
2. As they are tightly coupled (binded
each other strongly with extends
keyword), they cannot work independently
of each other.
3. Changing the code in super class
method also affects the subclass
functionality.
4. If super class method is deleted, the
code may not work as subclass may call
the super class method with super
keyword. Now subclass method behaves
independently.
Page: 37
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 19
Defining a method in the subclass
that has the same name, same
arguments and same return type
as a method in the superclass and
it hides the super class method is
called .
a) method rebuilding
b) method overriding
c) method overloading
d) method calling
Page: 38
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 19 (Solution)
Ans: b) method overriding
Explanation:
Defining a method in the subclass that
has the same name, same arguments
and same return type as a method in
the superclass and it hides the super
class method is called method
overriding. Now when the method is
called, the method defined in the
subclass is invoked and executed
instead of the one in the superclass.
Page: 39
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 20
Method overriding is run time
polymorphism. True or False
a) True
b) False
Page: 40
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 20 (Solution)
Ans: a) True
Explanation:
Defining a method in the subclass
that has the same name, same
arguments and same return type as
a method in the superclass is called
method overriding.
Method overriding is an example of
runtime polymorphism. In method
overriding, a subclass overrides a
method with the same signature as
that of in its superclass. During
compile time, the check is made on
the reference type.
Page: 41
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 21
Method overloading is compile time
polymorphism.
a) True
b) False
Page: 42
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 21 (Solution)
Ans: a) True
Explanation: Overloading a method is
a way to provide more than one method in
one class which have same name but
different argument to distinguish them.
Method overloading is compile time
polymorphism.
Method overloading is the compile-time
polymorphism where more than one
methods share the same name with
different parameters or signature and
different return type. Method overriding is
the runtime polymorphism having same
method with same parameters or
signature, but associated in different
classes.
Page: 43
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 22
_______________ is the
mechanism by which a call to an
overridden method is resolved at
run time, rather than compile time.
Fill in the blank.
a) Dynamic method dispatch
b) Static class select
c) Dynamic class select
d) Static method dispatch
Page: 44
MCQs Bank on Object Oriented Programming
Topic : Inheritance
MCQ No: 22 (Solution)
Ans: a) Dynamic method dispatch
Explanation: Dynamic method dispatch
is the mechanism by which a call to an
overridden method is resolved at run time,
rather than compile time. Dynamic
method dispatch is important because this
is how Java implements run-time
polymorphism.
Overridden method to execution based
upon the type of the object being referred
to at the time the call occurs. Thus, this
determination is made at run time. In
other words, it is the type of the object
being referred to (not the type of the
reference variable) that determines which
version of an overridden method will be
executed.
Page: 45

More Related Content

PDF
Multiple Choice Questions on JAVA (object oriented programming) bank 3 -- cla...
Kuntal Bhowmick
 
PDF
Multiple Choice Questions on JAVA (object oriented programming) bank 2 -- bas...
Kuntal Bhowmick
 
PPTX
Java abstract class & abstract methods
Shubham Dwivedi
 
PPTX
Core Java Tutorials by Mahika Tutorials
Mahika Tutorials
 
PPS
Jdbc architecture and driver types ppt
kamal kotecha
 
PDF
Java I/O
Jussi Pohjolainen
 
PPTX
Data Types, Variables, and Operators
Marwa Ali Eissa
 
PPTX
C# classes objects
Dr.Neeraj Kumar Pandey
 
Multiple Choice Questions on JAVA (object oriented programming) bank 3 -- cla...
Kuntal Bhowmick
 
Multiple Choice Questions on JAVA (object oriented programming) bank 2 -- bas...
Kuntal Bhowmick
 
Java abstract class & abstract methods
Shubham Dwivedi
 
Core Java Tutorials by Mahika Tutorials
Mahika Tutorials
 
Jdbc architecture and driver types ppt
kamal kotecha
 
Data Types, Variables, and Operators
Marwa Ali Eissa
 
C# classes objects
Dr.Neeraj Kumar Pandey
 

What's hot (20)

PPSX
JDBC: java DataBase connectivity
Tanmoy Barman
 
PPTX
JAVA AWT
shanmuga rajan
 
PDF
Collections In Java
Binoj T E
 
PPTX
Applets in java
Wani Zahoor
 
PPT
Java: GUI
Tareq Hasan
 
PPTX
Constructor in java
Hitesh Kumar
 
PDF
Arrays in Java
Naz Abdalla
 
PPTX
Array in c#
Prem Kumar Badri
 
PPT
Collection Framework in java
CPD INDIA
 
PPT
C# basics
Dinesh kumar
 
PPTX
Strings in Java
Abhilash Nair
 
PPT
Packages in java
Abhishek Khune
 
PPTX
Multiple inheritance in java3 (1).pptx
RkGupta83
 
PPTX
L21 io streams
teach4uin
 
PPTX
Java exception handling
BHUVIJAYAVELU
 
PPTX
Interface in java
PhD Research Scholar
 
PPT
Looping statements in Java
Jin Castor
 
PPT
Jsp ppt
Vikas Jagtap
 
PDF
Java - File Input Output Concepts
Victer Paul
 
JDBC: java DataBase connectivity
Tanmoy Barman
 
JAVA AWT
shanmuga rajan
 
Collections In Java
Binoj T E
 
Applets in java
Wani Zahoor
 
Java: GUI
Tareq Hasan
 
Constructor in java
Hitesh Kumar
 
Arrays in Java
Naz Abdalla
 
Array in c#
Prem Kumar Badri
 
Collection Framework in java
CPD INDIA
 
C# basics
Dinesh kumar
 
Strings in Java
Abhilash Nair
 
Packages in java
Abhishek Khune
 
Multiple inheritance in java3 (1).pptx
RkGupta83
 
L21 io streams
teach4uin
 
Java exception handling
BHUVIJAYAVELU
 
Interface in java
PhD Research Scholar
 
Looping statements in Java
Jin Castor
 
Jsp ppt
Vikas Jagtap
 
Java - File Input Output Concepts
Victer Paul
 
Ad

Similar to Multiple Choice Questions on JAVA (object oriented programming) bank 6 -- inhertance (20)

PDF
Multiple Choice Questions on JAVA (object oriented programming) bank 7 -- abs...
Kuntal Bhowmick
 
PDF
Multiple Choice Questions on JAVA (object oriented programming) bank 1 -- int...
Kuntal Bhowmick
 
PDF
Multiple Choice Questions on JAVA (object oriented programming) bank 5 -- mem...
Kuntal Bhowmick
 
PDF
Multiple Choice Questions on JAVA (object oriented programming) bank 8 -- int...
Kuntal Bhowmick
 
DOCX
Ganesh groups
Ganesh Amirineni
 
DOCX
Sdtl assignment 03
Shrikant Kokate
 
PDF
Chapter- 3 Inheritance and Polymorphism-1x4.pdf
joshua211619
 
DOCX
Bt8903, c# programming
smumbahelp
 
PDF
Class notes(week 6) on inheritance and multiple inheritance
Kuntal Bhowmick
 
PPTX
Advanced programming topics asma
AbdullahJana
 
PDF
Top 40 Javascript Interview Questions and Answers.pdf
paldibya712
 
DOCX
Mcs 024 assignment solution (2020-21)
smumbahelp
 
PPTX
Top 20 c# interview Question and answers
w3asp dotnet
 
DOCX
CIS 407 STUDY Inspiring Innovation--cis407study.com
KeatonJennings91
 
PDF
Devry CIS 247 Full Course Latest
Atifkhilji
 
DOCX
Bt0074 oop with java
smumbahelp
 
PPTX
10. inheritance
M H Buddhika Ariyaratne
 
PDF
Breaking Dependencies Legacy Code - Cork Software Crafters - September 2019
Paulo Clavijo
 
DOCX
Java sessionnotes
Lakshmi Sarvani Videla
 
Multiple Choice Questions on JAVA (object oriented programming) bank 7 -- abs...
Kuntal Bhowmick
 
Multiple Choice Questions on JAVA (object oriented programming) bank 1 -- int...
Kuntal Bhowmick
 
Multiple Choice Questions on JAVA (object oriented programming) bank 5 -- mem...
Kuntal Bhowmick
 
Multiple Choice Questions on JAVA (object oriented programming) bank 8 -- int...
Kuntal Bhowmick
 
Ganesh groups
Ganesh Amirineni
 
Sdtl assignment 03
Shrikant Kokate
 
Chapter- 3 Inheritance and Polymorphism-1x4.pdf
joshua211619
 
Bt8903, c# programming
smumbahelp
 
Class notes(week 6) on inheritance and multiple inheritance
Kuntal Bhowmick
 
Advanced programming topics asma
AbdullahJana
 
Top 40 Javascript Interview Questions and Answers.pdf
paldibya712
 
Mcs 024 assignment solution (2020-21)
smumbahelp
 
Top 20 c# interview Question and answers
w3asp dotnet
 
CIS 407 STUDY Inspiring Innovation--cis407study.com
KeatonJennings91
 
Devry CIS 247 Full Course Latest
Atifkhilji
 
Bt0074 oop with java
smumbahelp
 
10. inheritance
M H Buddhika Ariyaratne
 
Breaking Dependencies Legacy Code - Cork Software Crafters - September 2019
Paulo Clavijo
 
Java sessionnotes
Lakshmi Sarvani Videla
 
Ad

More from Kuntal Bhowmick (20)

PDF
Multiple Choice Questions on JAVA (object oriented programming) bank 4 -- loops
Kuntal Bhowmick
 
PDF
Hashing notes data structures (HASHING AND HASH FUNCTIONS)
Kuntal Bhowmick
 
PPT
1. introduction to E-commerce
Kuntal Bhowmick
 
DOCX
Computer graphics question for exam solved
Kuntal Bhowmick
 
PDF
DBMS and Rdbms fundamental concepts
Kuntal Bhowmick
 
PDF
Java questions for interview
Kuntal Bhowmick
 
PDF
Java Interview Questions
Kuntal Bhowmick
 
PDF
Operating system Interview Questions
Kuntal Bhowmick
 
PDF
Computer Network Interview Questions
Kuntal Bhowmick
 
PDF
C interview questions
Kuntal Bhowmick
 
PDF
C question
Kuntal Bhowmick
 
PDF
Distributed operating systems cs704 a class test
Kuntal Bhowmick
 
DOCX
Cs291 assignment solution
Kuntal Bhowmick
 
DOCX
CS291(C Programming) assignment
Kuntal Bhowmick
 
PDF
C programming guide new
Kuntal Bhowmick
 
PDF
C lecture notes new
Kuntal Bhowmick
 
PDF
Shell script assignment 3
Kuntal Bhowmick
 
DOCX
Basic shell programs assignment 1
Kuntal Bhowmick
 
PDF
Basic shell programs assignment 1_solution_manual
Kuntal Bhowmick
 
DOCX
Shell programming assignment 2
Kuntal Bhowmick
 
Multiple Choice Questions on JAVA (object oriented programming) bank 4 -- loops
Kuntal Bhowmick
 
Hashing notes data structures (HASHING AND HASH FUNCTIONS)
Kuntal Bhowmick
 
1. introduction to E-commerce
Kuntal Bhowmick
 
Computer graphics question for exam solved
Kuntal Bhowmick
 
DBMS and Rdbms fundamental concepts
Kuntal Bhowmick
 
Java questions for interview
Kuntal Bhowmick
 
Java Interview Questions
Kuntal Bhowmick
 
Operating system Interview Questions
Kuntal Bhowmick
 
Computer Network Interview Questions
Kuntal Bhowmick
 
C interview questions
Kuntal Bhowmick
 
C question
Kuntal Bhowmick
 
Distributed operating systems cs704 a class test
Kuntal Bhowmick
 
Cs291 assignment solution
Kuntal Bhowmick
 
CS291(C Programming) assignment
Kuntal Bhowmick
 
C programming guide new
Kuntal Bhowmick
 
C lecture notes new
Kuntal Bhowmick
 
Shell script assignment 3
Kuntal Bhowmick
 
Basic shell programs assignment 1
Kuntal Bhowmick
 
Basic shell programs assignment 1_solution_manual
Kuntal Bhowmick
 
Shell programming assignment 2
Kuntal Bhowmick
 

Recently uploaded (20)

PPTX
Information Retrieval and Extraction - Module 7
premSankar19
 
PDF
Software Testing Tools - names and explanation
shruti533256
 
PDF
Cryptography and Information :Security Fundamentals
Dr. Madhuri Jawale
 
PPT
SCOPE_~1- technology of green house and poyhouse
bala464780
 
PPTX
EE3303-EM-I 25.7.25 electrical machines.pptx
Nagen87
 
PPT
Lecture in network security and mobile computing
AbdullahOmar704132
 
PDF
Queuing formulas to evaluate throughputs and servers
gptshubham
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
PPTX
unit 3a.pptx material management. Chapter of operational management
atisht0104
 
PPTX
Color Model in Textile ( RGB, CMYK).pptx
auladhossain191
 
PPTX
22PCOAM21 Data Quality Session 3 Data Quality.pptx
Guru Nanak Technical Institutions
 
PDF
July 2025: Top 10 Read Articles Advanced Information Technology
ijait
 
PDF
The Effect of Artifact Removal from EEG Signals on the Detection of Epileptic...
Partho Prosad
 
PDF
settlement FOR FOUNDATION ENGINEERS.pdf
Endalkazene
 
PDF
Unit I Part II.pdf : Security Fundamentals
Dr. Madhuri Jawale
 
PDF
Introduction to Ship Engine Room Systems.pdf
Mahmoud Moghtaderi
 
PDF
Activated Carbon for Water and Wastewater Treatment_ Integration of Adsorptio...
EmilianoRodriguezTll
 
PPTX
Module2 Data Base Design- ER and NF.pptx
gomathisankariv2
 
PDF
Traditional Exams vs Continuous Assessment in Boarding Schools.pdf
The Asian School
 
PDF
EVS+PRESENTATIONS EVS+PRESENTATIONS like
saiyedaqib429
 
Information Retrieval and Extraction - Module 7
premSankar19
 
Software Testing Tools - names and explanation
shruti533256
 
Cryptography and Information :Security Fundamentals
Dr. Madhuri Jawale
 
SCOPE_~1- technology of green house and poyhouse
bala464780
 
EE3303-EM-I 25.7.25 electrical machines.pptx
Nagen87
 
Lecture in network security and mobile computing
AbdullahOmar704132
 
Queuing formulas to evaluate throughputs and servers
gptshubham
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
unit 3a.pptx material management. Chapter of operational management
atisht0104
 
Color Model in Textile ( RGB, CMYK).pptx
auladhossain191
 
22PCOAM21 Data Quality Session 3 Data Quality.pptx
Guru Nanak Technical Institutions
 
July 2025: Top 10 Read Articles Advanced Information Technology
ijait
 
The Effect of Artifact Removal from EEG Signals on the Detection of Epileptic...
Partho Prosad
 
settlement FOR FOUNDATION ENGINEERS.pdf
Endalkazene
 
Unit I Part II.pdf : Security Fundamentals
Dr. Madhuri Jawale
 
Introduction to Ship Engine Room Systems.pdf
Mahmoud Moghtaderi
 
Activated Carbon for Water and Wastewater Treatment_ Integration of Adsorptio...
EmilianoRodriguezTll
 
Module2 Data Base Design- ER and NF.pptx
gomathisankariv2
 
Traditional Exams vs Continuous Assessment in Boarding Schools.pdf
The Asian School
 
EVS+PRESENTATIONS EVS+PRESENTATIONS like
saiyedaqib429
 

Multiple Choice Questions on JAVA (object oriented programming) bank 6 -- inhertance

  • 1. MCQs BANK Page: 1 Object Oriented Programming Topic: Inheritance Instructions: This MCQs Bank contains question and solution on adjacent(even-odd) pages. First try to solve the MCQ by yourself, then look for the solution. Best viewed in “single page view” in PDF viewer. MCQs BANK No.: 6
  • 2. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 1 ___________ allows the creation of hierarchical classifications in object-oriented programming and helps to create a general class that defines traits common to a set of related items. Fill in the blank. a) Encapsulation b) Inheritance c) Data Hiding d) Polymorphism Page: 2
  • 3. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 1 (Solution) Ans: b) Inheritance Explanation: Inheritance allows the creation of hierarchical classifications in object-oriented programming. Using inheritance, you can create a general class that defines traits common to a set of related items. This class can then be inherited by other, more specific classes, each adding those things that are unique to it. The idea of inheritance is simple but powerful: When you want to create a new class and there is already a class that includes some of the code that you want, you can derive your new class from the existing class. In doing this, you can reuse the fields and methods of the existing class without having to write (and debug!) them yourself.. Page: 3
  • 4. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 2 In the terminology of Java, a class that is inherited is called a ___________. Fill in the blank. a) superclass b) subclass c) constructor class d) destructor class Page: 4
  • 5. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 2 (Solution) Ans: a) superclass Explanation: In the terminology of Java, a class that is inherited is called a superclass. A class that is derived from another class is called a subclass (also a derived class, extended class, or child class). The class from which the subclass is derived is called a superclass (also a base class or a parent class). Page: 5
  • 6. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 3 In the terminology of Java, a class that does the inheriting is called a ________. Fill in the blank. a) superclass b) subclass c) constructor class d) destructor class Page: 6
  • 7. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 3 (Solution) Ans: b) subclass Explanation: In the terminology of Java, a class that does the inheriting is called a subclass. A class that is derived from another class is called a subclass (also a derived class, extended class, or child class). The class from which the subclass is derived is called a superclass (also a base class or a parent class). Page: 7
  • 8. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 4 Excepting Object, which has no superclass, every class has one and only one direct superclass (single inheritance). In the absence of any other explicit superclass, every class is implicitly a subclass of Object. True or False a) True b) False Page: 8
  • 9. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 4 (Solution) Ans: a) True Explanation: Excepting Object, which has no superclass, every class has one and only one direct superclass (single inheritance). In the absence of any other explicit superclass, every class is implicitly a subclass of Object. Classes can be derived from classes that are derived from classes that are derived from classes, and so on, and ultimately derived from the topmost class, Object. Such a class is said to be descended from all the classes in the inheritance chain stretching back to Object. Page: 9
  • 10. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 5 The subclass inherits members of the superclass and hence promotes _______. Fill in the blank. a) polymorphism b) code reuse c) code rewrite d) multiple inheritance Page: 10
  • 11. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 5 (Solution) Ans: b) code reuse Explanation: The subclass inherits members of the superclass and hence promotes code reuse. The subclass itself can add its own new behavior and properties. Page: 11
  • 12. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 6 Private members of the superclass are not inherited by the subclass. True or False a) True b) False Page: 12
  • 13. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 6 (Solution) Ans: a) True Explanation: Private members of the superclass are not inherited by the subclass and can only be indirectly accessed(using public methods). A subclass inherits all of the public and protected members of its parent, no matter what package the subclass is in. Page: 13
  • 14. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 7 A subclass must use the __________ keyword to derive from a super class which must be written in the header of the subclass definition. Fill in the blank. a) extends b) import c) static d) super Page: 14
  • 15. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 7 (Solution) Ans: a) extends Explanation: A subclass must use the extends keyword to derive from a super class which must be written in the header of the subclass definition. Page: 15
  • 16. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 8 Since constructors and initializer blocks are not members of a class, they are not inherited by a subclass. True or False a) True b) False Page: 16
  • 17. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 8 (Solution) Ans: a) True Explanation: A subclass inherits all the members (fields, methods, and nested classes) from its superclass. Constructors are not members, so they are not inherited by subclasses, but the constructor of the superclass can be invoked from the subclass. Page: 17
  • 18. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 9 You can write a subclass constructor that invokes the constructor of the superclass, either implicitly or by using the keyword ________. Fill in the blank. a) default b) super c) extends d) final Page: 18
  • 19. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 9 (Solution) Ans: b) super Explanation: A parent class constructor is not inherited in child class and this is why super() is added automatically in child class constructor if there is no explicit call to super or this. Page: 19
  • 20. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 10 You can write a new instance method in the subclass that has the same signature as the one in the superclass, this is called __________________. Fill in the blank a) method calling b) method overriding c) method overloading d) method hiding Page: 20
  • 21. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 10 (Solution) Ans: b) method overriding Explanation: You can write a new instance method in the subclass that has the same signature as the one in the superclass, thus overriding it. If subclass (child class) has the same method as declared in the parent class, it is known as method overriding in Java. In other words, If a subclass provides the specific implementation of the instance method that has been declared by one of its parent class, it is known as method overriding. Page: 21
  • 22. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 11 You can write a new static method in the subclass that has the same signature as the one in the superclass, this is called _____________. Fill in the blank. a) method calling b) method overriding c) method overloading d) method hiding Page: 22
  • 23. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 11 (Solution) Ans: d) method hiding Explanation: Method hiding may happen in any hierarchy structure in java. When a child class defines a static method with the same signature as a static method in the parent class, then the child's method hides the one in the parent class. Page: 23
  • 24. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 12 You can declare new methods in the subclass that are not in the superclass. True or False a) True b) False Page: 24
  • 25. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 12 (Solution) Ans: a) True Explanation: You can declare new methods in the subclass that are not in the superclass. The inherited methods can be used directly as they are. You can write a new instance method in the subclass that has the same signature as the one in the superclass, thus overriding it. Page: 25
  • 26. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 13 A subclass can call a constructor defined by its superclass by use of _________. Fill in the blank. a) super(parameter-list); b) super class name c) constructor(parameter-list); d) default(parameter-list); Page: 26
  • 27. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 13 (Solution) Ans: a) super(parameter-list); Explanation: A subclass can call a constructor method defined by its superclass by use of the following form of super: super(parameter-list); Here, parameter-list specifies any parameters needed by the constructor in the superclass. super( ) must always be the first statement executed inside a subclass’ constructor. Page: 27
  • 28. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 14 If we want to refer a member of the superclass of a subclass, we have to use _____________. Fill in the blank. a) super.member b) default.member c) parent.member d) base-class.member Page: 28
  • 29. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 14 (Solution) Ans: a) super.member Explanation: The second form of super acts somewhat like this, except that it always refers to the superclass of the subclass in which it is used. This usage has the following general form: super.member Here, member can be either a method or an instance variable. This second form of super is most applicable to situations in which member names of a subclass hide members by the same name in the superclass. Page: 29
  • 30. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 15 Which of the following correctly explains multi-level inheritance. a) one class extends one class only b) the ladder of single inheritance increases c) one class directly extends more than one class d) none of these Page: 30
  • 31. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 15 (Solution) Ans: b) the ladder of single inheritance increases Explanation: When a class extends a class, which extends another class then this is called multilevel inheritance. For example class C extends class B and class B extends class A then this type of inheritance is known as multilevel inheritance. Page: 31
  • 32. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 16 Java supports multiple inheritance partially through _____________ . Fill in the blank. a) inheritance b) interfaces c) multiple packages d) multi-level inheritance Page: 32
  • 33. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 16 (Solution) Ans: b) interfaces Explanation: In multiple inheritance, one class extends multiple classes. Java does not support multiple inheritance but C++ supports. Java supports multiple inheritance partially through interfaces. Page: 33
  • 34. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 17 If one class is extended by many subclasses, then the type of inheritance is called __________ . Fill in the blank. a) Multi-Level Inheritance b) Hierarchical Inheritance c) Multiple Inheritance d) Single Inheritance Page: 34
  • 35. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 17 (Solution) Ans: b) Hierarchical Inheritance Explanation: In hierarchical type of inheritance, one class is extended by many subclasses. It is one-to-many relationship. A realtime example is available at dynamic binding. For example, Bird class is extended by two classes – Parrot and Vulture. Both classes can make use of the methods of Bird. Even though the Parrot and Vulture are subclasses of the same class Bird, but still they cannot makeuse of each other members. Parrot and Vulture are known as "siblings". Siblings are disjoint and they cannot make use of other members as between them no inheritance is involved (like two sons of a father; one son's property cannot be shared by other but both can share the property of father). Page: 35
  • 36. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 18 Which of the following are the disadvantages of Inheritance a) Both classes (super and subclasses) are tightly-coupled. b) As they are tightly coupled (binded each other strongly with extends keyword), they cannot work independently of each other. c) Changing the code in super class method also affects the subclass functionality. d) All of the above. Page: 36
  • 37. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 18 (Solution) Ans: d) All of the above. Explanation: Disadvantages of Inheritance 1. Both classes (super and subclasses) are tightly-coupled. 2. As they are tightly coupled (binded each other strongly with extends keyword), they cannot work independently of each other. 3. Changing the code in super class method also affects the subclass functionality. 4. If super class method is deleted, the code may not work as subclass may call the super class method with super keyword. Now subclass method behaves independently. Page: 37
  • 38. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 19 Defining a method in the subclass that has the same name, same arguments and same return type as a method in the superclass and it hides the super class method is called . a) method rebuilding b) method overriding c) method overloading d) method calling Page: 38
  • 39. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 19 (Solution) Ans: b) method overriding Explanation: Defining a method in the subclass that has the same name, same arguments and same return type as a method in the superclass and it hides the super class method is called method overriding. Now when the method is called, the method defined in the subclass is invoked and executed instead of the one in the superclass. Page: 39
  • 40. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 20 Method overriding is run time polymorphism. True or False a) True b) False Page: 40
  • 41. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 20 (Solution) Ans: a) True Explanation: Defining a method in the subclass that has the same name, same arguments and same return type as a method in the superclass is called method overriding. Method overriding is an example of runtime polymorphism. In method overriding, a subclass overrides a method with the same signature as that of in its superclass. During compile time, the check is made on the reference type. Page: 41
  • 42. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 21 Method overloading is compile time polymorphism. a) True b) False Page: 42
  • 43. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 21 (Solution) Ans: a) True Explanation: Overloading a method is a way to provide more than one method in one class which have same name but different argument to distinguish them. Method overloading is compile time polymorphism. Method overloading is the compile-time polymorphism where more than one methods share the same name with different parameters or signature and different return type. Method overriding is the runtime polymorphism having same method with same parameters or signature, but associated in different classes. Page: 43
  • 44. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 22 _______________ is the mechanism by which a call to an overridden method is resolved at run time, rather than compile time. Fill in the blank. a) Dynamic method dispatch b) Static class select c) Dynamic class select d) Static method dispatch Page: 44
  • 45. MCQs Bank on Object Oriented Programming Topic : Inheritance MCQ No: 22 (Solution) Ans: a) Dynamic method dispatch Explanation: Dynamic method dispatch is the mechanism by which a call to an overridden method is resolved at run time, rather than compile time. Dynamic method dispatch is important because this is how Java implements run-time polymorphism. Overridden method to execution based upon the type of the object being referred to at the time the call occurs. Thus, this determination is made at run time. In other words, it is the type of the object being referred to (not the type of the reference variable) that determines which version of an overridden method will be executed. Page: 45