• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

JQ+ answer has conflicting results

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<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).]
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Noel,
The exam title says it all...
SCJP2
Manfred.
 
Noel Castillo
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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).]
 
Ranch Hand
Posts: 400
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic