Follow Our FB Page << >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...

Can you have a constructor in abstract class?

Answers were Sorted based on User's Feedback

Can you have a constructor in abstract class?..

Answer / sumit

But you can create constructor in an abstract class.
and whenever you careate object of class implementing
abstarct class, constructor of te abstract class runs.

Is This Answer Correct ?    108 Yes 13 No

Can you have a constructor in abstract class?..

Answer / rajesh dangi

I don't understand why ppl start writing responses without
writing a small code to confirm it.

Guys an abstract class too can have a constructer. Any time
a class inheriting an abstract class is instantiated, its
constructer would first call the constructor of the
abstract class. Try it yourself.
Plus, the method in the abstract class with the same name
(i.e. its constructer) is always considered as a
constructer and not any regular method. Even when the
constructer is public, you can not invoke the constructer
of an abstract class in a sub class inheriting the abstract
class. That method can not be invoked by our code since it
is an abstract class and can not be instantiated by us

Is This Answer Correct ?    62 Yes 6 No

Can you have a constructor in abstract class?..

Answer / sam


abstract class test{
int i=10;
abstract void method();
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

Can you have a constructor in abstract class?..

Answer / jag bhushan

we can have constructor in abstract class.
But we can not make instance of the abstract class.
instead we can make a reference to that abstract class.
and when we make a new object of the class which extends
the abstract class, the constructor of abstract class get

see the code for example:

public abstract class TestAbstract {


System.out.println(" abstract class'

public abstract void showAbstract();
public void show(){
System.out.println(" show");

public class Test extends TestAbstract{
public static void main(String[] args) {

TestAbstract ta = new Test(); //
constructor call


public void showAbstract() {
System.out.println(" showAbstract");



Is This Answer Correct ?    22 Yes 3 No

Can you have a constructor in abstract class?..

Answer / ranjan

We can write a method name same as class which is called
constructor in the abstract class , but as a abstract class
can not be instanciated so that method used as a general

but no error would be there...

Is This Answer Correct ?    31 Yes 16 No

Can you have a constructor in abstract class?..

Answer / dileep

Yes you can have a constructor in abstract class but you
should not instansiated directly you have to write one
subclass extends the abstract class.

Is This Answer Correct ?    12 Yes 1 No

Can you have a constructor in abstract class?..

Answer / abdul hannan

Yes. We can have constructor in an abstract class but we can
not directly instantiate it. If the abstract class have no
argument constructor, it will automatically call by the
constructor of subclass through constructor chaining. If
abstract class have constructor with argument, then we need
to call it by super() and pass the argument in it.

Is This Answer Correct ?    5 Yes 0 No

Can you have a constructor in abstract class?..

Answer / srinu

Yes constructor their abstract class.if u any doubt araise
just see HttpServlet Api. HttpServlet contain constructor

Is This Answer Correct ?    6 Yes 2 No

Can you have a constructor in abstract class?..

Answer / vinoth kumar

we can define it in the abstract class itself.But it invoke
only by super() in sub class constructor.


abstract class AbsConstCheck{
System.out.println("I AM WORKING AbsConstCheck");
}//some other methods declaration
class Sub extends AbsConstCheck{
super();//calling abstract class constructor
System.out.println("I AM WORKING Sub");
class Main{
public static void main(String vin[]){
Sub s=new Sub();//calling sub,abstract class constructor


I AM WORKING AbsConstCheck

Is This Answer Correct ?    1 Yes 0 No

Can you have a constructor in abstract class?..

Answer / kundan ranjan

you can write constructor in abstract class
becoz,construct are use in abstract class only for initialize the state(variables) of class
you know that all the variable are allowed inside the abstract class
if you not initialize the variable at declaration time then you have need constructor becoz
you have no any alternative method to initialize the state thats why constructor are allowed inside
abstract class
see example:
abstract class hello
int x;
abstract void m1();
hello(int x)


class Hai extends hello
Hai(int x)
void m1()
class Lab84
public static void main(String as[])

hello h=new Hai(12);

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

Explain how hashmap works?

0 Answers  

What is the difference between form & report?

0 Answers  

Explain about data types?

0 Answers  

Explain about anonymous inner classes ?

0 Answers  

Where local and global variables are stored?

0 Answers  

Explain constructors and types of constructors in java.

0 Answers  

What is a jagged array in java?

0 Answers  

what is difference betwenn Access Specifier and Access Modifier ????

2 Answers  

What is the Dictionary class?

1 Answers  

int a=10,b=20,c=30 a= b+c;b=a+c;c=a+b; System.out.println("The value is"+a+b+c;

17 Answers   Honeywell,

Which is the class in java?

0 Answers  

Can we use a default constructor of a class even if an explicit constructor is defined?

0 Answers