answersLogoWhite

0

Constructors have the same name as the class itself and they do not specify a return type, not even void because they return the instance of the class itself.

Because constructors have the same name as the class then they allow method overloading and also save memory and execution time of program.

Program release memory of constructors function after using this function and it reduce program complexity.

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

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.


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.


What does it mean in java when a constructor is undefined?

When a constructor is not define in java then the instance used in class is not optimised the value and therefore some times it generates some garbage value. By the way , When we not define a constructor then generally it not distrub the execution of the program.


Does Java support copy constructor?

No. Java does not support copy constructor


What is a constructor and its mandatory to use constructor in a class?

A constructor is a method that is invoked when an object is created. As to being mandatory, that really depends on the programming language; in the case of Java, each class must have a constructor, however, in many cases Java will automatically provide a default constructor, so you don't really need to program it.


Can you use constructor in servlet?

Yes you can but it is not required. A Servlet is nothing but another .java file and all rules that are applicable to standard Java classes are applicable to them. Note: Even if you write a constructor in a servlet, it will not get executed.


What is the difference between implicit and explicit Java programming?

Explicit means done by the programmer. Implicit means done by the JVM or the tool , not the Programmer. For Example: Java will provide us default constructor implicitly.Even if the programmer didn't write code for constructor, he can call default constructor. Explicit is opposite to this , ie. programmer has to write .


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( ) ").


Can we add website link when we write java program?

yes ,i can add the website link in java program when we write.


What is use of constructor in java?

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


Write a c program Fibonacci series using for loop in java?

Exactly what do you mean by 'C program in Java'


Can a constructor be defined within a method in java?

No.