Java Programming Multiple Choice Questions - Inheritance
This section focuses on the "Inheritance" in Java programming. These Multiple Choice Questions (MCQ) should be practiced to improve the Java programming skills required for various interviews (campus interviews, walk-in interviews, company interviews), placements and other competitive examinations.
1. ____________ can be defined as the process where one class acquires the properties (methods and fields) of another.
A. Overriding
B. Inheritance
C. Polymorphism
D. Abstraction
View Answer
Ans : B
Explanation: Inheritance can be defined as the process where one class acquires the properties (methods and fields) of another
2. The class which inherits the properties of other is known as ________
A. superclass
B. parent class
C. subclass
D. None of the above
View Answer
Ans : C
Explanation: The class which inherits the properties of other is known as subclass
3. Subclass also known as ?
A. derived class
B. child class
C. base class
D. Both A and B
View Answer
Ans : D
Explanation: subclass also known as derived class, child class.
4. The class whose properties are inherited is known as superclass.
A. TRUE
B. FALSE
C. Can be true or false
D. Can not say
View Answer
Ans : A
Explanation: True, the class whose properties are inherited is known as superclass
5. ___________ is the keyword used to inherit the properties of a class.
A. inherit
B. poly
C. extends
D. super
View Answer
Ans : C
Explanation: extends is the keyword used to inherit the properties of a class.
6. The super keyword is similar to _________ keyword.
A. construct
B. this
C. class
D. extends
View Answer
Ans : B
Explanation: The super keyword is similar to this keyword.
7. A class member declared protected becomes a member of subclass of which type?
A. public member
B. protected member
C. static member
D. private member
View Answer
Ans : D
Explanation: A class member declared protected becomes a private member of subclass.
8. 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 {}
View Answer
Ans : C
Explanation: class B extends A {} correct way of inheritance.
9. ______ is a way of saying: This object is a type of that object.
A. IS-A
B. HAS-A
C. ARE-A
D. HAD-A
View Answer
Ans : A
Explanation: IS-A is a way of saying: This object is a type of that object.
10. A subclass inherits all the members (fields, methods, and nested classes) from its superclass
A. Yes
B. NO
C. Can be yes or no
D. Can not say
View Answer
Ans : A
Explanation: YES, A subclass inherits all the members (fields, methods, and nested classes) from its superclass.
Discussion