Consider the following program and predict the behavior of this program:
class Base {// w w w . j a v a 2 s. c o m public void print() { System.out.println("Base:print"); } } abstract class Main extends Base { //#1 public static void main(String[] args) { Base obj = new Base(); obj.print(); //#2 } }
AbstractClassInstantiationException
.c)
It is possible for an abstract class to extend a concrete class (though such inheritance often doesn't make much sense).
Also, an abstract class can have static methods.
Since you don't need to create an object of a class to invoke a static method in that class, you can invoke the main()
method defined in an abstract class.