+ 1
Can any show me where is constructor in this program. The given information isn't clarifying the doubt please help me
6 Answers
+ 11
There is no constructor. The method is static, so the jvm can call it without needing an instance of the class.
+ 9
There is no object necessary for a static method.
The default constructor is called when you create an object using new, but didn't declare a constructor in your class. Then the default constructor creates an object and returns it.
If you would write down the default constructor for My class it would look like this:
public MyClass() {}
+ 9
If you create an object of that class that contains your main method then the default constructor is called as well, as long as you don't declare a constructor.
+ 2
our lecturer says, constructors is found in every program whether it may be create default. what is mean by default constructor
+ 2
and thanks for answering me
+ 2
kk thanks it really helpful