Explore topic-wise MCQs in Java.

This section includes 38 Mcqs, each offering curated multiple-choice questions to sharpen your Java knowledge and support exam preparation. Choose a topic below to get started.

1.

To stop or block inheriting a given class, the ___ keyword is used before the class.

A. static
B. private
C. final
D. none of the above
Answer» D. none of the above
2.

To control inheritance to different classes and levels, Java provides ____.

A. Return types like the void, int, float, double and other object types
B. Static keyword
C. Access modifiers like default, public, protected, private
D. None
Answer» D. None
3.

Can you call it a full-fledged inheritance of using ABSTRACT classes and INTERFACES in Java?

A. NO
B. YES
C. -
D. -
Answer» B. YES
4.

What is the output of the below Java program with inheritance?

A. Sweet=$10 Sugar=$20
B. Sweet=$10 Sugar=$10
C. Sweet=$20 Sugar=$20
D. Compiler error
Answer» B. Sweet=$10 Sugar=$10
5.

Which is the keyword used to implement inheritance in Java?

A. extends
B. implements
C. instanceof
D. None
Answer» B. implements
6.

Find Superclass and Subclass in the below Java program?

A. The Liquid is a superclass and Juice is a subclass.
B. The Liquid is a Subclass and Juice is a Superclass.
C. There is no superclass or subclass
D. None
Answer» B. The Liquid is a Subclass and Juice is a Superclass.
7.

Find Superclass and Subclass in the below Java code snippet?

A. B is superclass and A is subclass.
B. A is superclass and B is a subclass.
C. There is no superclass or subclass present.
D. None
Answer» D. None
8.

You can not inherit a Superclass'es constructor even after using inheritance in Java. State TRUE or FALSE.

A. TRUE
B. FALSE
C. -
D. -
Answer» B. FALSE
9.

A Subclass can become a Superclass to another class extending from it in Java. State TRUE or FALSE.

A. TRUE
B. FALSE
C. -
D. -
Answer» B. FALSE
10.

When a Class inherits two superclasses (not in Java), it is called ____ inheritance.

A. Multilevel inheritance
B. Single Inheritance
C. Multiple Inheritance
D. None
Answer» D. None
11.

In a Multi-Level Inheritance in Java, the last subclass inherits methods and properties of ____.

A. Only one immediate Superclass
B. Few classes above it.
C. All classes above it
D. None
Answer» D. None
12.

In a Multi Level Inheritance Class-C inherits from Class-B and Class-B inherits from Class-A. State TRUE or FALSE.

A. TRUE
B. FALSE
C. -
D. -
Answer» B. FALSE
13.

In a Single inheritance, Class B inherits only from Class A. State TRUE or FALSE.

A. TRUE
B. FALSE
C. -
D. -
Answer» B. FALSE
14.

What are the types of Inheritances (Whether Java supports or not) available in Object-Oriented Programming Languages?

A. Single Inheritance
B. Multi-Level Inheritance, Hierarchical Inheritance
C. Multiple Inheritance, Hybrid Inheritance
D. All the above
Answer» E.
15.

You should use Inheritance when there is an IS-A relationship between classes. State TRUE or FALSE.

A. TRUE
B. FALSE
C. -
D. -
Answer» B. FALSE
16.

Java language supports ___ type of inheritance.

A. Multiple Inheritance
B. Multi-Level Inheritance
C. -
D. -
Answer» C. -
17.

The class that inherits an already defined class is called ___.

A. Subclass
B. Superclass
C. -
D. -
Answer» B. Superclass
18.

The class that is being inherited or subclassed is called ___.

A. Subclass
B. Superclass
C. -
D. -
Answer» C. -
19.

What are the features reused using Inheritance in Java?

A. Methods
B. Variables
C. Constants
D. All the above
Answer» E.
20.

What are the features of an Object Oriented Programming (OOPs)?

A. Inheritance
B. Encapsulation
C. Polymorphism
D. All the above
Answer» E.
21.

What is the output of the below Java program using Inheritance?

A. Added.
B. No output
C. Added. Made of Wood.
D. Compiler error
Answer» E.
22.

What is the output of the below Java program on the references of Superclass and Subclass?

A. FOOD FOOD FOOD FOOD
B. FOOD FOOD TOASTED FOOD
C. FOOD TOASTED FOOD FOOD
D. Compiler error
Answer» C. FOOD TOASTED FOOD FOOD
23.

A subclass object can be used to invoke (call) a method or property of the superclass. State TRUE or FALSE.

A. TRUE
B. FALSE
C. -
D. -
Answer» B. FALSE
24.

A superclass reference can not be used to invoke a method or variable of the subclass. State TRUE or FALSE.

A. TRUE
B. FALSE
C. -
D. -
Answer» B. FALSE
25.

A Superclass reference can refer to a Subclass Object without casting. State TRUE or FALSE.

A. TRUE
B. FALSE
C. -
D. -
Answer» B. FALSE
26.

If a class is not subclassed by any class, then defining a default constructor is not mandatory in Java. State TRUE or FALSE.

A. TRUE
B. FALSE
C. -
D. -
Answer» B. FALSE
27.

What is the output of the below Java program with Constructors using Inheritance?

A. Inside WildAnt() Constructor.
B. Inside Ant(String) Constructor. Inside WildAnt() Constructor.
C. Inside WildAnt() Constructor. Inside WildAnt() Constructor.
D. Compiler error
Answer» E.
28.

What is the output of the below java program with Constructors and Inheritance?

A. Inside I5Processor() Constructor. Inside I3Processor() Constructor. Inside Processor() Constructor.
B. Inside I5Processor() Constructor. Inside I5Processor() Constructor. Inside I5Processor() Constructor.
C. Inside Processor() Constructor. Inside I3Processor() Constructor. Inside I5Processor() Constructor.
D. Compiler error
Answer» D. Compiler error
29.

What is the maximum number of levels possible in a Multilevel Inheritance in Java?

A. 8
B. 16
C. 32
D. No maximum level
Answer» E.
30.

WHICH_ACCESS_TYPE_DATA_GETS_DERIVED_AS_PRIVATE_MEMBER_IN_DERIVED_CLASS:?$

A. Private
B. Public
C. Protected
D. Protected and Private
Answer» B. Public
31.

Members which are not intended to be inherited are declared as:$

A. Public members
B. Protected members
C. Private members
D. Private or Protected members
Answer» D. Private or Protected members
32.

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 class
Answer» B. Only protected members become protected members of derived class
33.

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 possible
Answer» D. It is not possible
34.

Which programming language doesn’t support multiple inheritance?$

A. C++ and Java
B. C and C++
C. Java and SmallTalk
D. Java
Answer» E.
35.

B,E

A. A,C
B. C,E
C. T,H
Answer» D.
36.

Which of these is correct way of inheriting class A by class B?

A. class B + class A {}
B. class B inherits class A {}
C. class B extends A {}
D. class B extends class A {}
Answer» D. class B extends class A {}
37.

A class member declared protected becomes a member of subclass of which type?

A. public member
B. private member
C. protected member
D. static member
Answer» C. protected member
38.

Which of this keyword must be used to inherit a class?

A. super
B. this
C. extent
D. extends
Answer» E.