Cool How To Write Abstract Method In Java
To declare an abstract method use this general form.
How to write abstract method in java. As you can see no method body is present. Abstract Method in Java. An abstract class may also have concrete complete methods.
Abstract class Office int empNo. Now as all methods in an interface are abstract methods therefore we can implement it using Abstract. Example public abstract class Employee private String name.
Here display is an abstract method. Abstract void printStatus no method. Class without abstract keyword that extends an abstract class must override all the abstract methods of the class.
An abstract method cant have a method body it has to be implemented by the class which is inheriting this abstract class. Abstract class Shape int color. Important rules for abstract methods.
Example of abstract method. The method which is declared with abstract keyword and doesnt have any implementation is known as an abstract method. Reference of an abstract class can point to objects of its sub-classes thereby achieving run-time polymorphism Ex.
Abstract class. Essentially you would have. Class Teaching extends Office String designation.