answersLogoWhite

0

Can you create a constructor for an interface in java?

Updated: 8/20/2019
User Avatar

Wiki User

12y ago

Best Answer

NO, we cannot create a contructor for an interface in java.

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Can you create a constructor for an interface in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What happens when no constructor function is declared in a class - in Java?

When any constructor is deffined in your class, the java compiler create a default no argument constructor for you. This constructor only have an invocation to the super class constructor (" super( ) ").


Why constructor use in java?

To create objects of classes


Can you initialize an object without constructor in java?

No. if you wish to create an object that you plan on using in a java program then the answer is NO. You cannot initialize an object of a Java class without calling the constructor.


Why constructor rather than classes in java?

Constructor is not an alternative to class. In Java, you create classes; the classes contain methods - including the constructor, which can be viewed as a special method. If you want to have a constructor, you need a class that surrounds it, so it's not one or the other.


Can you create an object of interface in java?

maybe


Does Java support copy constructor?

No. Java does not support copy constructor


Can you create an empty interface with no definitions?

Yes. This is a valid interface definition in Java: interface Useless {}


Why super constructor should be first statement in subclass constructor in java?

Because, the parent class also needs to be initialized when you create an object in the inheritance hierarchy.


Is there a sample program for constructor?

All Java programs would have a constructor... public class Test { public Test(){ ... } ..... } This is a constructor. Even if you dont code the constructor Java would automatically place a default constructor for compilation.


What is use of constructor in java?

Constructor is used to do something (written in constructor) immediately after object creation.


What are the functions of an interface in Java?

To create an abstraction or a blueprint for a class to implement later.


Can a constructor be defined within a method in java?

No.