Here are some objective question on Inheritance and interfaces in Java.
- Which of the following statements are true about an abstract class?
- An abstract class can be instantiated
- An abstract class can be subclassed
- An abstract class can not have a concrete method
- All of the above
- Which of the following is the correct declaration of an interface?
- interface Test { public void print(){}}
- interface Test { public void print(); }
- interface Test { int a; void print(){}}
- All of the above
- Which of the following statements are true?
- A final class can not be extended
- An abstract class can not be instantiated
- An interface can not be instantiated
- All of the above
- What is the correct way of defining a class ABC which uses an interface DEF?
- class ABC extends DEF
- class DEF extends ABC
- class ABC implements DEF
- None of the above
- Method overriding is used to implement ------
- Inheritance
- Polymorphism
- Abstraction
- None of the above
- A protected method in super class can have an overriding method in sub-class which is ------
- public
- private
- static
- None of the above
- When we write a static method in subclass with the same signature as a static method in super class, it is called ------
- Method hiding
- Overriding
- Overloading
- None of the above
- When we override a method in subclass, we can optionally using the annotation -----
- @override
- @Override
- @overrides
- None of the above
- Except for Object class, every class has one and only one --------
- method
- field
- super class
- sub class
Comments
Post a Comment