An abstract class is a class marked with the abstract keyword. It, contrary to non-abstract class, may contain abstract - implementation-less - methods. It is, however, valid to create an abstract class without abstract methods.
An abstract class cannot be instantiated. It can be sub-classed (extended) as long as the sub-class is either also abstract, or implements all methods marked as abstract by super classes.
Abstraction can be achieved with either abstract classes or interfaces .
This is a Java program that demonstrates the concept of abstract classes and abstract methods.
This program demonstrates how abstract classes and abstract methods can be used to create a base class with certain methods that must be implemented by its subclasses, while also providing some methods with default implementations that can be used as is.
//Abstract Class in Java Programming abstract class Shape { abstract void draw(); void message() { System.out.println("Message From Shape"); } } class rectangleShape extends Shape { @Override void draw() { System.out.println("Draw Rectangle Using Length & Breadth.."); } } public class abstractDemo { public static void main(String args[]) { rectangleShape o =new rectangleShape(); o.draw(); o.message(); } }
Draw Rectangle Using Length & Breadth.. Message From ShapeTo download raw file Click Here
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions