Abstract classes and methods : Interface and Abstract Class « Language Basics « Java






Abstract classes and methods

Abstract classes and methods
// : c07:PrivateOverride.java
// Abstract classes and methods.
// From 'Thinking in Java, 3rd ed.' (c) Bruce Eckel 2002
// www.BruceEckel.com. See copyright notice in CopyRight.txt.

public class PrivateOverride {

  private void f() {
    System.out.println("private f()");
  }

  public static void main(String[] args) {
    PrivateOverride po = new Derived();
    po.f();
  }
}

class Derived extends PrivateOverride {
  public void f() {
    System.out.println("public f()");
  }
} ///:~



           
       








Related examples in the same category

1.Holds a sequence of ObjectsHolds a sequence of Objects
2.Initializing interface fields with non-constant initializers
3.Two ways that a class can implement multiple interfaces
4.Interface Collision
5.Multiple interfaces
6.Interface Usage ExampleInterface Usage Example
7.Implement multiple interfaces
8.Multi Super Interfaces
9.This shows that a class implementing an interface need not
10.Find out whether interfaces are inheritedFind out whether interfaces are inherited
11.Extending an interface with inheritance