Inheritance
- If super class and subclass have same variable name, which keyword should be used to use super class?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Super keyword is used to access hidden super class variable in subclass.
- Static members are not inherited to subclass.
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Static members are also inherited to subclasses.
- Which of the following is used for implementing inheritance through an interface?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Interface is implemented using implements keyword. A concrete class must implement all the methods of an interface, else it must be declared abstract.
- Which of the following is used for implementing inheritance through class?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
Class can be extended using extends keyword. One class can extend only one class. A final class cannot be extended.
- What would be the result if a class extends two interfaces and both have a method with same name and signature?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
In case of such conflict, compiler will not be able to link a method call due to ambiguity. It will throw compile time error.