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 / imtiyaz

The access specifier for the overriding method can allow
more but not less access than the overridden method.
For example, a protected method in the superclass can be
made public but not private

private, protected and public is Ascending order of access
modifiers depending upon the strength

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 a file pointer?

516


Why string is a class?

548


What are the differences between getting and load method?

546


What are reference variables in java?

598


Do I need java on my computer?

528






What is logical variable?

514


Is string is a keyword in java?

549


Is math class static in java?

616


Explain about instanceof operator in java?

609


What is widening and narrowing in java? Discuss with an example.

561


What do you mean by local variable and instance variable?

517


Does java allow overriding static methods ?

632


What is the size of integer?

588


What are the pillars of java?

489


If you do not want your class to be inherited by any other class. What would you do?

563