File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Mock Exam Errata and the fly likes Strings Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Mock Exam Errata
Bookmark "Strings" Watch "Strings" New topic


Stephen Joseph
Ranch Hand

Joined: Dec 29, 2000
Posts: 50
Errata: Jxam

1. Object o = new String("abcd");

2. String s = o;

3. System.out.println(s);

4. System.out.println(o);


As you can see here there will be an compile time error based on incompatible referencing,and this was the probable answer given in Jxam.And this was the only one given by them. But they have missed one that is also correct.
The program will compile if the first line is altered to
String s = new String("abcd");

this change will make it compile and run

Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Stephen,
I agree with you. I have wrote to the JXam site, but they haven't provided any fixes or new version yet.
sandeep bagati
Ranch Hand

Joined: Feb 22, 2001
Posts: 62
Hi stephen
There is Nothing wrong with first line
The Program will work perfectly if you typecast Object to String at line 2 as
String s=(String) o;
I agree. Here's the link:
subject: Strings
jQuery in Action, 3rd edition