+ 2
Does Constructor return any Value?
Yes, Constructor return the current instance of a class. Because they are used to initialize an object but constructor does not have any signature of return type
4 Antworten
+ 9
constructor doesn't returns any value as it does not have any return type .
remember rules for defining constructor : 1.'Constructor name must be the same name as your class name .'
2.'Constructor is used only to initialize your object.'
3.'constructor is called at the time of object creation.(i.e suppose your class name is A and you create its object say 'A obj=new A()'; as soon as the above statement gets executed constructor gets called automatically)'.
4.Constructor can be of 3 types, i)Simple.ii)Paramitarised.iii)copy constructor.
+ 1
it returns class, of what it's a method
- 1
no constructor doesnt return any value as it has void return type and NEW keyword is used to initialize an object by default values
- 3
^