java - Provide a method definition with an abstract version before it? -
is posible have:
public abstract void somemethod(); ... public void somemethod() {     // ... } in same class? or definition have in child classes?
public abstract void somemethod();  public void somemethod() {    // ... } in same class, duplicate method definition. not possible. method differentiated based on method signature , not based on modifier abstract.from official java tutorial:
two of components of method declaration comprise method signature—the method's name , parameter types.the java programming language supports overloading methods, , java can distinguish between methods different method signatures.
question:
or definition have in child classes? it can subclass , must concrete subclass in hierarchy.so, first non abstract subclass should provide implementation abstract method. again, java tutorial:
when abstract class subclassed, subclass provides implementations of abstract methods in parent class. however, if not, subclass must declared abstract.
Comments
Post a Comment