Alex Rivera | Logout

Change the access modifier of an overridden method in Java?

Asked 2012-02-17T14:28:46.510
32

Is there a reason one can change the access modifier of an overridden method? For instance,

abstract class Foo{
    void start(){...}
}

And then change the package-private access modifier to public,

final class Bar extends Foo{
    @Override
    public void start(){...}
}

I'm just asking this question out of curiosity.

Edit
Report

1 Answer

6

There is only one, you might want the override to be visible by more classes, since no modifier is default, public broadens that.

answered 2012-02-17T14:30:39.567

Your Answer