This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach 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 Murach's Java Servlets and JSP this week in the Servlets 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Abstract methods and access modifier
 
Similar Threads
Interface question - Dan Chrisholm.
Interfaces doubt
Abstract methods
Abstract classes
Combination of Abstract and Private Modifiers in a Method Declaration