does abstract class without abstract method?
@hareshjsakariya (35)
India
April 9, 2007 12:18am CST
In Abstract Class is it possible to be without abstract method? I knew only that if in a class any method is abstract then that class must be abstract.
2 responses
@julie111 (44)
•
11 Apr 07
For a class to be abstract it must contain atleast one abstract method. otherwise it will give compile time error.
Consider an example below:
//A simple demo of abstract class
abstract class A {
abstract void callme();
//concrete methods still allowed in abstract classes
void callmetoo() {
System.out.println("This s a concrete method")
}
}
class B extends A {
void callme() {
System.out.println("B's implementation of callme");
}
}
class AbstractDemo {
public static void main(String args[])
{
B b = new B();
b.callme();
b.callmetoo();
}
}
in the example class A declared abstract so it should contain an abtract method(missing body). And the class which inherits the abstract class should implement the abstract method as the class B does.
![](/Content/images/loading.gif)