Create multiple abstarct methods within a abstract class in java

Create multiple abstarct methods within a abstract class in java
abstract class superclass
{
abstract void get(int a, int b);
abstract void add();
abstract void display();
}
class subclass extends superclass
{
int x, y, z;
void get(int a, int b)
{
x = a; y = b;
} void add()
{
z = x + y;
}
void display()
{
System.out.println(“The Addition is : ” + z);
}
}
class test
{
public static void main(String args[])
{
subclass obj = new subclass();
obj.get(30, 50);
obj.add();
obj.display();
}
}

Output:
The Addition is : 80

Leave a Reply

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