Abstraction
abstract class MyClass {
/* Abstract class may or may not include abstract methods.They cannot be instantiated,
* but they can be subclassed.Contains mixture of non-abstract and abstract methods.*/
public void display() {
System.out.println("Inside display");
}
abstract public void show();
}
public class Abstraction extends MyClass { /* If an Abstract class is subclassed,
then all its abstract methods should be implemented in the sub class or
the class itself should be declared abstract. */
@Override
public void show() {
System.out.println("Inside show");
}
public static void main(String[] args) {
Abstraction ab = new Abstraction();
ab.display();
ab.show();
}
}
Output:
Inside display
Inside show