Inheritance - Java test
1) Which inheritance is not supported in java?
A) Single inheritance
B) Hybrid inheritance
C) Multilevel inheritance
D) Java supports all of the above
View Answer / Hide Answer2) Which is a mechanism in which one object acquires all the properties and behaviors of parent object?
A) Inheritance
B) Encapsulation
C) Polymorphism
D) None of the above
View Answer / Hide Answer3) The following Syntax is used for?
class Subclass-name extends Superclass-name
{
//methods and fields
}
A) Polymorphism
B) Encapsulation
C) Inheritance
D) None of the above
View Answer / Hide Answer4) If subclass (child class) has the same method as declared in the parent class, it is known as?
A) Method overriding
B) Method overloading
C) Constructor overloading
D) None of the above
View Answer / Hide AnswerANSWER: Method overriding
5) In Method overriding a subclass in a different package can only override the non-final methods declared public or protected?
A) True
B) False
View Answer / Hide Answer6) Which allows you define one interface and have multiple implementations?
A) Encapsulation
B) Inheritance
C) Polymorphism
D) None of the above
View Answer / Hide Answer7) Which type of polymorphism is nothing but the method overloading in java?
A) Compile time polymorphism
B) Runtime polymorphism
C) Static polymorphism
D) Both A & C
View Answer / Hide Answer8) Which is a perfect example of runtime polymorphism?
A) Method overloading
B) Method overriding
C) Constructor overloading
D) None of the above
View Answer / Hide AnswerANSWER: Method overriding
9) The following two rules are defined by?
1. The parameters may differ in their type or number, or in both.
2. They may have the same or different return types.
A) Method overloading
B) Method overriding
C) Constructor overloading
D) None of the above
View Answer / Hide AnswerANSWER: Method overloading
10) Which method cannot be overridden?
A) Final Method
B) Final class
C) Final Variable
D) Both A & C
View Answer / Hide Answer11) A final class not to be inherited?
A) True
B) False
View Answer / Hide Answer12) A class which cannot be instantiated is known as?
A) Abstract Class
B) Abstract Method
C) Both A & B
D) None of the above
View Answer / Hide Answer13) An abstract class has no use until unless it is extended by some other class?
A) True
B) False
View Answer / Hide Answer14) The following syntax is a declaration for?
abstract return_type
();//no braces{}
A) Abstract Class
B) Abstract Method
C) None of the above
View Answer / Hide Answer
15) Multiple inheritances is not supported in case of class but it is supported in case of interface?
A) True
B) False
View Answer / Hide Answer
16) By interface, we cannot support the functionality of multiple inheritances?
A) True
B) False
View Answer / Hide Answer
17) Which keyword is used by classes to implement an interface?
A) import
B) implements
C) instance of
D) None of the above
View Answer / Hide Answer
18) An interface is a blueprint of a class. It has static constants and abstract methods?
A) True
B) False
View Answer / Hide Answer