Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
Search Coderanch
Advance search
Google search
Register / Login
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:
Campbell Ritchie
Tim Cooke
paul wheaton
Jeanne Boyarsky
Ron McLeod
Sheriffs:
Paul Clapham
Liutauras Vilda
Devaka Cooray
Saloon Keepers:
Tim Holloway
Roland Mueller
Bartenders:
Forum:
Programmer Certification (OCPJP)
JQ + Question ID :958011966030
huiying li
Ranch Hand
Posts: 68
posted 23 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
public class Test34 { public static void main(String args[]) { System.out.println(null + true); //1 System.out.println(true + null); //2 System.out.println(null + null); //3 } }
The answer given is none of the three lines will compile, however, using JDK 1.3, all three did compile and here are the output.
C:\JavaRanch>javac Test34.java
C:\JavaRanch>
java
Test34
nulltrue
truenull
nullnull
Any thoughts?
SCJP
Subramaniam Venkatesan
Ranch Hand
Posts: 48
posted 23 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
None of the 3 lines compiled in jdk1.2.2
got these errors
C:\subs\SAMPLES>javac Test34.java Test34.java:7: Reference to println is ambiguous. It is defined in void println( java.lang.String) and void println(char[]). System.out.println(null); ^ C:\subs\SAMPLES>javac Test34.java Test34.java:7: Incompatible type for +. Can't convert boolean to int. System.out.println(true+null); ^ Test34.java:7: Incompatible type for +. Can't convert null to int. System.out.println(true+null);
but got truenull or the o/p you mentioned
in these codes
System.out.println(null + ""+ true); //1 System.out.println(true + ""+null); //2 System.out.println(null + ""+ null); //3
Stevie Kaligis
Ranch Hand
Posts: 400
posted 23 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Yes,
I was about to ask the same question,
it suppose to be compiled and run without any problem,
if this topic is related to JDK 1.0 and 1.1, than JQPlus was right,
but for JDK 1.2 and 1.3, it works without any problem.
huiying li
Ranch Hand
Posts: 68
posted 23 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thanks for your replies, hopefully there won't be something ambiguous like this in the real
test
.
SCJP
You showed up just in time for the waffles! And this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
doubt in method call
Thread Behavour
println() : question from JQPlus
doubt in kathy sierra question?
How's this possible ????
More...