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 Jxam question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Jxam question" Watch "Jxam question" New topic

Jxam question

Vani Prabakaran

Joined: Jun 08, 2000
Posts: 13
The below mentioned question is in Jxam.
Q: Select ALL valid answers...
Consider the following piece of code and select the correct statements.
1. Object o = new String("abcd");
2. String s = o;
3. System.out.println(s);
4. System.out.println(o);
Answer 1:
The following is displayed:
Answer 2:
The code fails to compile at line 1.
Answer 3:
The code fails to compile at line 2
Answer 4:
The code fails to compile at line 4.
Answer 5:
The code can be made to compile by changing line 1 to the
String o = new String("abcd");

The given correct answer is 3 and I think it is 3 and 5. See the attached working code:
public class testing {
public static void main(String argv[]){
//Object o = new String("abcd");
String o = new String("abcd");
String s = o;
Can anyone confirm this please?
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
You are correct.
- satya
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
I also did the exam and you are right.
maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
Yes. All set to go to our Errata Forum .Thank you.
maha anna
I agree. Here's the link:
subject: Jxam question
It's not a secret anymore!