thinkinterview » interview questions
« Previous

interview Questions

next »
question Can Abstract Class have constructors?
Answer Description: Abstract class can have a constructor, but we can’t access it through the object, since we cannot instantiate abstract class. To access the constructor first create a sub class and then extend the abstract class which is having the constructor.Example
public abstract class ExampleAbstract {
public ExampleAbstract(){
System.out.println("In ExampleAbstract()");
}
}
public class Test extends ExampleAbstract{
public static void main(String args[]){
Test obj=new Test();
}
}

Next Queston » What is interface? Does Java support multiple inheritance? If yes...
What is interface? Does Java support multiple inheritance? If yes then how?View full queston »

Posted in: Java(30) |