Abstract Methods at a glance

Abstract method is a method which does not have any body (i.e. implementation).

  • Abstract class means it can not be extended(instantiated)
  • Abstract method means it should be overridden.
Abstract method examples -

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
If a method inside a class is declared as abstract ,that class should be marked as abstract,other wise it will throw an error.

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"

Replies

You are reading an archived discussion.

Related Posts

Hello friends i am glad to tell u about my stay at iitb. I was very much excited to go to a new state without knowing their language.It was really...
Hello everybody . I have a problem in simulation of DTC-SVM five phases induction motor ..... i have the simulation on the three phases but whene i changed it into...
Just five hours ago, GL4.1 has been enabled in AMD RadeonSI driver. Compiled latest Mesa-git and yay! I am happy bunny now :3 Source : https://cgit.freedesktop.org/mesa/me...t?id=af1e6aa75b7f518cc6b08717fa8844370be3f05c ​
I am jeevabharathi govindasamy working as a project intern.Now you all came to know why I kept my story tittle as My First Carrier as a Intern.First of all after...
i had done my internship training on bikram chowk flyover construction work at jammu. It is very big opportunity for me to acquring some knowledge about flyover construction work. on...