<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).]