Question 1240 – Nielit STA [02-12-2018]
December 10, 2023
Question 1246 – Nielit STA [02-12-2018]
December 10, 2023
Question 1240 – Nielit STA [02-12-2018]
December 10, 2023
Question 1246 – Nielit STA [02-12-2018]
December 10, 2023

OOPS

Question 108
Which of the following is FALSE about inheritance in Java?
A
Private methods are final
B
Protected members are accessible within a package and inherited classes outside the package
C
Protected methods are final
D
We cannot override private methods
Question 108 Explanation: 
→ Methods declared public in a superclass must also be public in all subclasses (this, by the way, is the reason most of the applet methods are public).
→ Methods declared protected in a superclass must either be protected or public in subclasses; they cannot be private.
→ Methods declared private are not inherited and therefore this rule doesn’t apply.
→ Methods declared without protection at all (the implicit package protection) can be declared more private in subclasses.
Correct Answer: C
Question 108 Explanation: 
→ Methods declared public in a superclass must also be public in all subclasses (this, by the way, is the reason most of the applet methods are public).
→ Methods declared protected in a superclass must either be protected or public in subclasses; they cannot be private.
→ Methods declared private are not inherited and therefore this rule doesn’t apply.
→ Methods declared without protection at all (the implicit package protection) can be declared more private in subclasses.

Leave a Reply

Your email address will not be published. Required fields are marked *