+ 5

Does constructor creates an object or not?

23rd Feb 2018, 7:00 AM
Ankur Singh
Ankur Singh - avatar
8 Respostas
+ 5
No, constructors initializes the class' members value, they are used to "prepare" the class for use by setting up the members to a predefined set of value, or custom value that could be passed through the constructor method's parameters. Hth, cmiiw
23rd Feb 2018, 8:39 AM
Ipang
+ 3
yup
23rd Feb 2018, 7:27 AM
Farshaad Heydari
Farshaad Heydari - avatar
+ 2
Yes that is his job
23rd Feb 2018, 7:48 AM
Nitzan
Nitzan - avatar
+ 1
than what is the job of new keyword
23rd Feb 2018, 7:52 AM
Ankur Singh
Ankur Singh - avatar
+ 1
I like turtles
23rd Feb 2018, 9:31 AM
zif
+ 1
Ankur Singh ...The 'new' keyword is used to create an instance of a class or array object. Using keyword for this end is not completely necessary, though it serves two purposes: it enables the existence of different namespace for methods and class names, it defines statically and locally that a fresh object is indeed created, and of what runtime type it is.
1st Jul 2018, 6:23 AM
Ashi Soni
Ashi Soni - avatar
0
no by giving "new" operator we are just creating the new area in the heap area to store all non static methods from object class as well as class to which the constructor is created .
24th Feb 2018, 12:11 PM
Selva Ganapathy
Selva Ganapathy - avatar