Can you have a constructor in abstract class?

Answer Posted / sam

Yes

abstract class test{
int i=10;
abstract void method();
test(){
System.out.println("Abstract class constructor");
}
}
public class test1 extends test{
void method(){
//implement abstract method of test
}
public static void main(String args[]){
test1 t=new test1();
}
}

Is This Answer Correct ?    29 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does the “static” keyword mean?

677


What does super keyword do?

648


Can java inner class be static?

644


How many return statement are allowed in a function?

550


What is the difference between a synchronized method and a synchronized block?

726






Can we declare a class as static?

679


Are arrays immutable in java?

636


What are drawbacks of singleton class?

619


How to display all the prime numbers between 1 and 100

584


What are the differences between getting and load method?

628


Explain java heap space and garbage collection?

683


Explain the concept of hashtables?

713


What are keywords give examples?

665


Can static methods be inherited?

620


Explain access modifiers in java.

672