aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Javaranch question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Javaranch question" Watch "Javaranch question" New topic
Author

Javaranch question

Parimala Somasundaram
Ranch Hand

Joined: Mar 31, 2001
Posts: 41
>
> I'm not sure about the answer to question#24 in the rules round up game. It
> is as follows:
>
> Q: Class Y is a subclass of class X. Will this compile? Y myY=new X()?
>
> Ans: No
>
> Is it not true that though the code is incorrect, referencing an object of
> class X using a reference of subclass Y, it will fail only at runtime and not
> at compile time?
>
Sean Casey
Ranch Hand

Joined: Dec 16, 2000
Posts: 625
The code will not compile. the rules roundup game is correct. Try it for yourself.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Javaranch question
 
Similar Threads
javaRanch round -up exam. question 27
coverting sub class object to super class object
class/ subclass
class / subclass.....
Constructor use in sub-classes