This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Abstract methods and access modifier Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Abstract methods and access modifier" Watch "Abstract methods and access modifier" New topic

Abstract methods and access modifier

Craig Oliver

Joined: Aug 25, 2003
Posts: 21
If abstract class declares abstract method what are rules regarding access modifier to implementation of method in concrete subclass? ie if abstract method declared as default (package) can subclass implementation be public (wider access)?

eg is following valid
public abstract class Test
abstract void m1();

public class SubTest extends Test
public void m1()
Darin Niard
Ranch Hand

Joined: Jun 08, 2004
Posts: 118
Yes, that is valid. You can always assign broader access, but not weaker access.
I agree. Here's the link:
subject: Abstract methods and access modifier
It's not a secret anymore!