Can I have constructor in Interface?

Answer Posted / saroj kumar biswal

no we can't have constructor in an interface, why bcz constructor is used to initialize the instance variable stored in an object. Constructor is called concurrently while creating object. We can't create object to interface & also we can't provide instance variable to interface. So we can't use constructor in an interface

Is This Answer Correct ?    30 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can a main method be overloaded?

567


What is supplier in java?

552


What is string in java with example?

484


Write a code to show a static variable?

611


What does java se mean?

584






What is boolean false?

522


There are two classes named classa and classb. Both classes are in the same package. Can a private member of classa can be accessed by an object of classb?

993


What is java and why do we need it? Explain

581


What is broken and continue statement?

530


What does singleton mean in java?

508


What does indexof mean?

528


What is treeset in java?

539


What is an example of a boolean?

567


How many bits is a string?

522


What is import java util arraylist?

650