Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public abstract class TestSuperToSubclass {
- public static void main(String[] args) {
- final TestSuperToSubclass instance = new SubClass();
- instance.superClassMethod();
- }
- protected abstract String fetchValue();
- private void superClassMethod() {
- System.out.println(this.fetchValue());
- }
- }
- class SubClass extends TestSuperToSubclass {
- private String field = "Test value.";
- @Override
- protected String fetchValue() {
- return field;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement