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 JQ+ answer has conflicting results 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 "JQ+ answer has conflicting results" Watch "JQ+ answer has conflicting results" New topic
Author

JQ+ answer has conflicting results

Noel Castillo
Greenhorn

Joined: Jan 03, 2001
Posts: 12
<pre>
Question ID :958011966030
Consider the following lines of code...
System.out.println(null + true); //1
System.out.println(true + null); //2
System.out.println(null + null); //3
Which of the following statements are correct?
JQ+ Correct Answer: 1) None of the three lines will compile.
My Comment:
1) The program compiled successfuly under TextPad 4.4.0 w/ JDK1.3
2) USING KAWA 5.0 + jikes; this is the result (compile-error):

Working Directory -
D:\jdk1.3\jikes\bin\jikes.exe -d "d:\My Java\Class Files" "Java SCJP Work\Test.java"
Working Directory - D:\My Java\
Class Path - d:\My Java\Class Files;.;D:\jdk1.3\jre\lib\rt.jar;d:\myjava~1\javasc~1;D:\Program Files\Kawa5.00\kawaclasses.zip;d:\jdk1.3\lib\tools.jar;d:\jdk1.3\jre\lib\i18n.jar
File Compiled...
--------------------------- Compiler Output ---------------------------
Found 3 semantic errors compiling "D:/My Java/Java SCJP Work/Test.java":
4. System.out.println(null + true);
<-->
*** Error: The type of this expression, "null", is not numeric.
5. System.out.println(true + null);
<-->
*** Error: The type of this expression, "boolean", is not numeric.
6. System.out.println(null + null);
<-->
*** Error: The type of this expression, "null", is not numeric.

3) USING KAWA 5.0 + javac (successful compile and run)
D:\My Java\
Class Path - d:\My Java\Class Files;.;D:\jdk1.3\jre\lib\rt.jar;d:\myjava~1\javasc~1;D:\Program Files\Kawa5.00\kawaclasses.zip;d:\jdk1.3\lib\tools.jar;d:\jdk1.3\jre\lib\i18n.jar
File Compiled...
No Errors...
Working Directory - D:\My Java\Class Files\
Class Path - d:\My Java\Class Files;.;D:\jdk1.3\jre\lib\rt.jar;d:\myjava~1\javasc~1;D:\Program Files\Kawa5.00\kawaclasses.zip;d:\jdk1.3\lib\tools.jar;d:\jdk1.3\jre\lib\i18n.jar
nulltrue
truenull
nullnull
Process Exit...
</pre>

[This message has been edited by Noel Castillo (edited April 11, 2001).]
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Noel,
Keep in mind that JQ+ is for JDK1.2 and not any other version. You can't use the JQ+ answers and compare them to other JDK versions!
For JDK1.2 all three lines give compiler errors, therefore JQ+ answers are correct.
Regards,
Manfred.
Noel Castillo
Greenhorn

Joined: Jan 03, 2001
Posts: 12
Manfred, thanks for your response. True, JQ+ may have been tested against JDK 1.2 but does the SCJP2 exams (for w/c we are practicing the mocks for) preclude JDK1.3 compliant syntax? If your passing mark depended on the correct answer to this question, should your answer reflect JQ+ or JDK1.3? Remember, in the exams there is only right or wrong answer.
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Noel,
The exam title says it all...
SCJP2
Manfred.
Noel Castillo
Greenhorn

Joined: Jan 03, 2001
Posts: 12
Originally posted by Manfred Leonhardt:
Noel,
The exam title says it all...
SCJP2
Manfred.

Are you implying that only JDK 1.2 is compliant with Java 2?? What about JDK 1.2.1 +?
[This message has been edited by Noel Castillo (edited April 12, 2001).]
Stevie Kaligis
Ranch Hand

Joined: Feb 04, 2001
Posts: 400
Hi Noel...,
if I got that question on real exam, i will answer "the program will compiled successfuly", i think sun wouldn't ask a question such as "what is the result if you trying to compile this code under jdk 1.2, or jd 1.2.1, or 1.3, or Kawa, or anything...".
And in my opinion, any mock exam is only trying to give us a description of what might be come up on the real exam, if I only depend on the answer(some times is wrong) of this mock, than I will Lost.

stevie
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JQ+ answer has conflicting results
 
Similar Threads
String tokenizer
problem with applet
Class compilation question
I need help in Setting of Kawa
jar files