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 the access scope of protected access specifier?

544


What happens to a static var that is defined within a method of a class?

558


Can we assign integer value to char in java?

519


What are the advantages of user defined functions?

564


How do you use wildcards?

545






Is java same as core java?

603


How is Object Oriented Programming different from Procedure Oriented Programming?

601


Is hashset sorted in java?

674


Is ++ operator thread-safe in java?

644


What is a void method?

531


Difference between arraylist and vector.

598


How many bits is a double?

538


what is mutual exclusion? How can you take care of mutual exclusion using java threads? : Java thread

694


What are thread local variables?

567


Explain the difference between comparator and comparable in java?

492