Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Constructors

 
Manju KT
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anybody tell me whether we can create a instance of type subclass using superclass constructor?
 
Charmy Madhvani
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Manju KT",
Please check your private messages.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic