
code for abstract class

Hi Friend,
Try this:
abstract class Shape {
abstract public double area();
}
public class AbstractClassExample extends Shape {
static int l, b;
public AbstractClassExample() {
l = 5;
b = 2;
}
public double area() {
return l*b;
}
public void display() {
System.out.println("Length: " + l + ",Breadth: " + b);
System.out.println(area());
}
public static void main(String args[]) {
AbstractClassExample p = new AbstractClassExample();
p.display();
}
}
For more information, visit the following links:
http://www.roseindia.net/help/java/a/java-abstract-class.shtml
http://www.roseindia.net/java/master-java/abstract-class.shtml
Thanks
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.