Inheritance in Java
Inheritance in Java - Important Points
| 26. | Which type of inheritance is used in Java for classes? |
|---|
A. Single inheritance
B. Multiple inheritance
C. Hybrid inheritance
D. Hierarchical inheritance
View Answer Discuss Work SpaceAnswer: option a
Explanation:
| 27. | Which of the following is not a benefit of inheritance in Java? |
|---|
A. Code reusability
B. Polymorphism
C. Encapsulation
D. Modularity
View Answer Discuss Work SpaceAnswer: option c
Explanation:
| 28. | What is the access modifier of a method or field that is inherited by a subclass in Java? |
|---|
A. public
B. private
C. protected
D. default
View Answer Discuss Work SpaceAnswer: option c
Explanation:
| 29. | What is the output of the following program? class A { |
|---|
A. Class A
B. Class B
C. Compilation error
D. Runtime error
View Answer Discuss Work SpaceAnswer: option b
Explanation:
| 30. | What is the output of the following program? class A { |
|---|
A. 10, 20
B. 20, 20
C. 10, 10
D. Compilation error
View Answer Discuss Work SpaceAnswer: option a
Explanation: