Abstract Keyword in Java


Abstract method will have only the method declaration part in the class.It won’t have the method implentation.

The Implementation part of the abstract method will be available in some other class which the ‘extends’ the abstract method class.

If there is any one abstract method in class then that class will be declared as abstract class.

Sample program that makes understand the abstract

File:abs.java

abstract class a
{
void show()
{
System.out.println(“Sample method Statement”);
}
abstract void get();
}
class abs extends a
{
void get()
{
System.out.println(“Statement in abstract method”);
}
public static void main(String ar[])
{
abs d=new abs();
d.get();
d.show();
}
}

Output
Statement in abstract method
Sample method Statement

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s