14/04/2008
An abstract class cannot be instantiated directly. An abstract class has to be sub-classed first and then instantiated. Only then the method defined in the abstract class can be invoked.
An abstract class cannot be instantiated directly. An abstract class has to be sub-classed first and then instantiated. Only then the method defined in the abstract class can be invoked.



by instantiated. do you mean declaring it? i’m new to java and i don’t like the book that we have. I’m looking at other ways to learn it.
Anonymous on January 28th, 2011 4:18 pmA code snippet for your reference:
http://techguru.yakkoo.com/programming-concept-tutorials/2011/08/how-can-you-invoke-a-defined-method-of-an-abstract-class/
public abstract void myAbstractMethod() ;
public static void main(String[] args) {
// Not permitted
// MyAbstractClass instance1 = new MyAbstractClass ();
}
}
public class ConcreteSubclass extends MyAbstractClass {
public abstract void myAbstractMethod() {
System.out.println(“Called from concrete class”);
}
public static void main(String[] args) {
ConcreteSubclass instance1 = new ConcreteSubclass ();
danish on August 10th, 2011 8:58 aminstance1.myAbstractMethod();
}
}
in ConcreteSubclass the myAbstractMethod cannot have abstract keyword
Pradeep on March 15th, 2012 1:02 pm