This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes Constructors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Constructors" Watch "Constructors" New topic
Author

Constructors

Manju KT
Greenhorn

Joined: Jan 16, 2008
Posts: 7
Can anybody tell me whether we can create a instance of type subclass using superclass constructor?
Charmy Madhvani
Ranch Hand

Joined: Dec 26, 2007
Posts: 59
You mean to say:
Child c=new Parent();

No..This is not valid in Java.
You can only have a Parent type reference to a child type object but not vice versa.


SCJP 5.0<br />SCWCD 5.0
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

"Manju KT",
Please check your private messages.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
wood burning stoves
 
subject: Constructors
 
Similar Threads
WA #1.....word association
Can the color for the disabled item be changed
Private methods
URGENT - NEED HELP - Block Code
error in Marcus Green 2.