File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript 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.
 
wood burning stoves
 
subject: Abstract methods and access modifier