File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Initialization 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 » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Initialization" Watch "Initialization" New topic


Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
I got a question:
What exactly does it mean by doing the following?
/*some code*/
/*some code*/
classA xyz = new classB();
/*some code*/
Assuming, classB is assignable to classA.
Does this mean that xyz is an instance of classB or classA? And which constructor will be call?
Kishan Kumar
Ranch Hand

Joined: Sep 26, 2000
Posts: 130
The object will be an instance of class B and the referenced type
is of type class A
The class B constructors will be called as the object belongs to B.
Hope this helps

Regards,<BR>V. Kishan Kumar
It is sorta covered in the JavaRanch Style Guide.
subject: Initialization
Similar Threads
Need Help! How can I......
ArrayList confusion
Scope and classes/methods
How does this work? sychronized([Classname].this) {...
Inherited main method question