abstract class Shape{ abstract void draw(); int size; abstract void remove(); } class Rectangle extends Shape { void draw(){ System.out.println("Drawing a rectangle "+size); } void remove(){ System.out.println("removing what we drew"); } } public class Second { public static void main(String[] args) { Rectangle obj=new Rectangle(); obj.draw(); obj.remove(); } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter