Abstract Classes

class Center1 extends computercenter
{
int numcomputer()
{ return 30;} // this was the only method in the abstract class
}
//A class that can be instantiated is known as the concrete class.

class Center2 extends computercenter
{
int numcomputer()
{ return 15;}
// every class which extends the abstract class must implement the abstract methods.
}

class computercenterdemo
{
public static void main(String[] args)
{
Center1 c1= new Center1();
System.out.println(“ No. of computers in center1 = “ + c1.numcomputers());
Center2 c2= new Center2();
System.out.println(“ No. of computers in center2 = “ + c2.numcomputers());
}
}

 

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.