When abstract class is inherited into any other class, which of the following action is correct? All abstract methods of abstract class must be implemented. Class must be declared as abstract class. Both (A) and (B) None of above code example
Example 1: java abstract class
abstract class Shape
{
abstract void sides();
}
class Triangle extends Shape
{
void sides()
{
System.out.println("Triangle shape has three sides.");
}
}
class Pentagon extends Shape
{
void sides()
{
System.out.println("Pentagon shape has five sides.");
}
public static void main(String[] args)
{
Triangle obj1 = new Triangle();
obj1.sides();
Pentagon obj2 = new Pentagon();
obj2.sides();
}
}
Example 2: abstract class in java
public abstract class GraphicObject {
abstract void draw();
}