| Author |
overriding constructors?
|
kri shan
Ranch Hand
Joined: Apr 08, 2004
Posts: 1300
|
|
|
Can i override constructors? If not, why?
|
 |
pete stein
Bartender
Joined: Feb 23, 2007
Posts: 1561
|
|
kri shan wrote:Can i override constructors? If not, why?
No, you can't. Why not: it wouldn't make much sense. How can you override when you haven't created the object yet?
|
 |
kri shan
Ranch Hand
Joined: Apr 08, 2004
Posts: 1300
|
|
How can you override when you haven't created the object yet?
How object is created during overloaded constructors?
|
 |
pete stein
Bartender
Joined: Feb 23, 2007
Posts: 1561
|
|
kri shan wrote:
How object is created during overloaded constructors?
overloading and overriding are two completely different things. Overriding is how Java implements polypmorphism or virtual functions, and requires a formed object for it to occur. Overloading on the other hand simply means that two or more methods or two or more constructors have the same name, does not require OOPS (and in fact is a feature of many non-OOPs procedural languages) and does not require an object for it to work.
|
 |
Jim Hoglund
Ranch Hand
Joined: Jan 09, 2008
Posts: 525
|
|
I think it's helpful to think of constructors as class methods that
are available just after the class is loaded. Is this an okay model?
After all, they must exist before the objects they create.
Jim ...
|
BEE MBA PMP SCJP-6
|
 |
 |
|
|
subject: overriding constructors?
|
|
|