Ask your own question, for FREE!
Computer Science 7 Online
OpenStudy (anonymous):

what is constructor in Java? How it is important in Java?

OpenStudy (anonymous):

A constructor in Java is a method that can have parameters, in which its name is the same as the name of the class. Example1 : class Ravi2 { public Ravi2() { // Your code here... } } It's used to instantiate the class (create an object), and to initialize the parameters if it's necessary. Instantiate Example1 : Ravi2 raviObject = new Ravi2(); ********************************************************** Consider now this Example2. Example2 : class Ravi2 { public Ravi2(String name) { System.out.println(name); } } Instantiate Example2 : Ravi2 raviObject = new Ravi2("Ravi"); ************************************************* Good luck.

OpenStudy (anonymous):

thnx dear good response.....! now some confusion about instance Variables which are related to constructors....

OpenStudy (anonymous):

plz ...tell me about executing process when we call the constructor from Class to the main method for execute?

OpenStudy (anonymous):

If you are asking about how a program gets executed, then you should learn the Compilation, which we can summarize it as "The transformation of your code from a high level to the machine code, so your processor can understand it and execute it". To know how this happen, you should study compilation.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!