when asub class inherits a super class and overrides a
public method of super class in sub class(public method in
super class).
why these methods needs to be public in sub class.
(otherwise compile time error).

Answer Posted / sushila

if super class method is public, then override method should
be public.

override method will take same access specifier or expanded one.

the order of access specifier is
private > default > protected > public

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of default method in interface in java? Explain

541


How many java versions are there?

556


What is a boolean used for?

582


Highest level event class of the event-delegation model?

3495


What is oop in java?

519






How hashset works internally in java?

580


Can we extend singleton class in java?

539


What is hashing principle in java?

548


What does the “final” keyword mean in front of a variable? A method? A class?

540


What happens when you add a double value to a string?

536


What is literal example?

558


How does split work in java?

528


What is a loop java?

583


Is 0 an even number?

541


How can we create a synchronized collection from given collection?

575