Organizational Research By

Surprising Reserch Topic

Experts Most Trusted Topic


What are Abstract methods?


Abstract class can contain abstract methods. Abstract methods do not have implementation. Abstract methods should be implemented in the subclasses which inherit them. So if an abstract class has an abstract method class inheriting the abstract class should implement the method or else java compiler will through an error. In this way, an abstract class can define a complete programming interface thereby providing its subclasses with the method declarations for all of the methods necessary to implement that programming interface. Abstract methods are defined using "abstract" keyword. Below is a sample code snippet.
abstract class pcdsGraphics
{
abstract void draw();
}
Any class inheriting from "pcdsGraphics" class should implement the "draw" method or else the java compiler will throw an error. so if we do not implement a abstract method the program will not compile.
 

asked Sep 13, 2013 in oops by rajesh
edited Sep 12, 2013
0 votes
16 views



Related Hot Questions



Government Jobs Opening


...