permaculture playing cards
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 REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Javaranch question" Watch "Javaranch question" New topic

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:
subject: Javaranch question
It's not a secret anymore!