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 Programmer Certification (SCJP/OCPJP) and the fly likes casting... 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 » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "casting..." Watch "casting..." New topic
Author

casting...

Preethi Dev
Ranch Hand

Joined: Sep 07, 2008
Posts: 265
Hi,this from Master exam.

class putter
{
public static void main(String args[])
{
Bango b1=new Bango();
Bango b2=new Bongo();
Bango b3=new Bingo();
//here
}
}

class Bango{}
class Bongo extends Bango{}
class Bingo extends Bongo{}

which code inserted here will not compile?
options:
A.Bongo b5=(Bongo)b2;
B.Bango b6=b3;
C.Bango b7=(Bango)b3;
D.Bingo b9=(Bingo)b3;
E.Bango b10=(Bongo)b3;

Answer given is A and E.
but when i tried all it compiles and runs without error ad exception.
please give me the correct answer.

Thanks
Preetha
Preethi Dev
Ranch Hand

Joined: Sep 07, 2008
Posts: 265
oops! sorry...options are wrongly typed
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

There is an edit button to edit your post.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Jyothsna Panchagnula
Ranch Hand

Joined: Jul 11, 2005
Posts: 113
Hello Preetha,

Even I too ran the program. I dont see any compilation errors.

-Jyothsna
 
Don't get me started about those stupid light bulbs.
 
subject: casting...
 
Similar Threads
Master Mock exam
reference casting
3 Questions
Mock Exam on K&B cd Bingo Bango Bongo
question about assertion