File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes overriding constructors? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "overriding constructors?" Watch "overriding constructors?" New topic
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
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: overriding constructors?
 
Similar Threads
Why I can't call the parent class constructor?
another question on constructors
OOP 4: Lookup
Constructors are not inhertied - True
Can constructor throw exception?