Advertisement
JeffGrigg

TestSuperToSubclass2

Sep 10th, 2017
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.52 KB | None | 0 0
  1. public abstract class TestSuperToSubclass {
  2.  
  3.     public static void main(String[] args) {
  4.         final TestSuperToSubclass instance = new SubClass();
  5.         instance.superClassMethod();
  6.     }
  7.  
  8.     protected abstract String fetchValue();
  9.  
  10.     private void superClassMethod() {
  11.         System.out.println(this.fetchValue());
  12.     }
  13. }
  14.  
  15. class SubClass extends TestSuperToSubclass {
  16.    
  17.     private String field = "Test value.";
  18.  
  19.     @Override
  20.     protected String fetchValue() {
  21.         return field;
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement