Inheritance - Java test

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 Answer

ANSWER: D




2) 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 Answer

ANSWER: Inheritance




3) 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 Answer

ANSWER: Inheritance




4) 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 Answer

ANSWER: 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 Answer

ANSWER: True




6) Which allows you define one interface and have multiple implementations?

A) Encapsulation
B) Inheritance
C) Polymorphism
D) None of the above
View Answer / Hide Answer

ANSWER: Polymorphism




7) 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 Answer

ANSWER: Both A & C




8) 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 Answer

ANSWER: 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 Answer

ANSWER: Method overloading




10) Which method cannot be overridden?

A) Final Method
B) Final class
C) Final Variable
D) Both A & C
View Answer / Hide Answer

ANSWER: Final Method




11) A final class not to be inherited?

A) True
B) False
View Answer / Hide Answer

ANSWER: True




12) 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 Answer

ANSWER: Abstract Class




13) An abstract class has no use until unless it is extended by some other class?

A) True
B) False
View Answer / Hide Answer

ANSWER: True




14) 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

ANSWER: Abstract Method




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

ANSWER: True




16) By interface, we cannot support the functionality of multiple inheritances?

A) True
B) False
View Answer / Hide Answer

ANSWER: False




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

ANSWER: implements




18) An interface is a blueprint of a class. It has static constants and abstract methods?

A) True
B) False
View Answer / Hide Answer

ANSWER: True


Post your comment

    Discussion

  • RE: Inheritance - Java test -N.Abi (08/12/15)
  • As per Dr.James Goslings's definition for Java inorder to enforce simplicity in the language, multiple inheritance is not supported. but multiple implementation is.
  • RE: Inheritance - Java test -Shankar Ram (04/06/15)
  • Which inheritance is not supported in java in case of class - Multilevel inheritance
    Huh? How come?
  • RE: Inheritance - Java test -senthil (09/20/14)
  • super