Sullivan Market

a web based full-circle development system

My Java Tutorials - Abstract Classes

Here is some example code.... Copy and paste it to your page if you wish to use it.

abstract class Cat {

String abstractClassName = "Cat"; //abstract classes can have variables

String getAbstractClassName() //abstract classes can have methods
return abstractClassName;

abstract String getClassName(); //this must be implemented in any class
extending Cat


class Himalayan extends Cat{ //you can't extend from two classes at

String className = "Himalayan";

public Himalayan() {}

String getClassName() //must have this method, because Cat
declared it
{ //as an abstract
return className;

public static void main(String[] args) {

//Cat percy = new Cat(); //can't instantiate an abstract class

Himalayan cappuccino = new Himalayan();

//output is: Cat
//output is: Himalayan


Back To Java Tutorials