20160721

Abstract Example - Shope

abstract class Shape {
 
  abstract void draw();
 
}
 
class Rectangle extends Shape {
 
  void draw() {
 
    System.out.println("Draw Rectangle");
 
  }
}
 
class Traingle extends Shape {
 
  void draw() {
 
    System.out.println("Draw Traingle");
 
  }
}
 
class AbstractTest {
 
  public static void main(String args[]) {
 
    Shape s1 = new Rectangle();
 
    s1.draw();
 
    s1 = new Traingle();
 
    s1.draw();
 
  }
 
}




OUTPUT

Draw Rectangle
Draw Traingle

Disqus Shortname

Recent Post Number

Related Post Number

Comments system