Abstract Methods at a glance
Abstract method is a method which does not have any body (i.e. implementation).
public void erase(); --- ABSTRACT METHOD DOES NOT SPECIFY BODY,NO BRACES ALSO.
Some examples of abstract methods are :
int area();
private String brand();
SYNTAX : (ACCESS MODIFIER) RETURN TYPE NAME OF METHOD() SEMI COLON
package Test;
public class Board {
int height;
int width;
abstract void write(); --error message will be shown as "The abstract method write in type Board can only be defined by an abstract class"
- Abstract class means it can not be extended(instantiated)
- Abstract method means it should be overridden.
public void erase(); --- ABSTRACT METHOD DOES NOT SPECIFY BODY,NO BRACES ALSO.
Some examples of abstract methods are :
int area();
private String brand();
SYNTAX : (ACCESS MODIFIER) RETURN TYPE NAME OF METHOD() SEMI COLON
- Access modifier is optional
- Return type is mandatory
- Method name is mandatory
- No Braces ,Should end with semicolon
package Test;
public class Board {
int height;
int width;
abstract void write(); --error message will be shown as "The abstract method write in type Board can only be defined by an abstract class"
0