What is the need for a method which has a body or implementation inside the abstract class ?, does it need to be implemented by an extended class. Basically, what is the main use of the method body in abstract class? Like this code. (New to Java)
public abstract class Animal {
protected int age;
public void eat() {
System.out.println("Animal is eating");
}
public abstract String getName();
}
class Swan extends Animal {
public String getName() {
return "Swan";
}
I am tried implementing the method but doesn't work then what's the need of method body in abstract class?