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

Why do we use variables?

516


Can extern variables be initialized?

514


Write a program to print 15 random numbers using foreach of java 8?

547


Write a program to check for a prime number in java?

561


What are the features of java?

533






What is the console in java?

680


what is abstract class in Java?

652


What is the difference between declaration and definition in java?

519


Why generics are used in java?

552


What is a variable in java?

536


What is difference between wait and notify in java?

547


If a variable is declared as private, where may the variable be accessed?

553


Why are parameters used in functions?

534


Which package is imported by default?

637


How do you compare arrays in java?

505