Two Laptop Bag*
The moose likes Beginning Java and the fly likes constructor lovers.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "constructor lovers.." Watch "constructor lovers.." New topic
Author

constructor lovers..

chintan ramavat
Ranch Hand

Joined: Sep 15, 2006
Posts: 134
hello ranchers

can anyone ll me why we need SUPER CLASS constructors and does it reflect to the subclasses, if so then whats the benefit of it. IF there's an abstract class in IS-A hierarchy then what's the outcome of having constructed SUPER CLASS.


Thank you ranchers
good night. would like to think about it in dreams hehe

Chintan Ramavat
Mamatha Preetham
Ranch Hand

Joined: Jan 23, 2007
Posts: 75
Hi Chintan,

Hope you had nice dreams!!
The constructor explicitly initializes the instance variables defined in the class, but it relies on the superclass constructor. And, by this time, you might be knowing that Object class is the super class for all the class. The instance variables are not initialized until after your super class constructor runs.

To invoke the superclass constructor, the constructor calls super(), which is a java keyword.

FYI The arguments pased to super() must match the parameters of the superclass constructor.

If you want constructors in your sub class , you will have to define a new one, else the compiler will provide a default one with no parameters.
Hope I made some sense for your question.....

mamatha
SCJP(1.4)
 
 
subject: constructor lovers..
 
Similar Threads
OO Design
why can't refer super before supertype........
can non-static inner class access any member
tricky question
Constructor