This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates 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


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Abstract methods and access modifier" Watch "Abstract methods and access modifier" New topic
Author

Abstract methods and access modifier

Craig Oliver
Greenhorn

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()
{
code
}
}
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: http://aspose.com/file-tools
 
subject: Abstract methods and access modifier