Abstract method definition in tree inheritance in Java classes

Viewed 33

Cheers, let's suppose I have 3 different classes: A,B and C. A is abstract with a class of print() which is abstract again. B is a sub-class of A, and is again abstract. C is a sub-class of B, and here we want to implement print.

So in code (suppose they are in different files for the public part):

public abstract class A {

   public abstract void print();
}

public abstract class B extends A {
   // public abstract void print();
}

public class C extends B {

   public void print() {
      // some code here
   }
}

What difference would it make if we redefined the print() function in B as abstract, and if we didn't? I see that in the compilation nothing changes, and in both ways it works correctly, but is there a reason one would be preferred over the other? Thanks =)

0 Answers
Related