[NTLUG:Discuss] [Fwd: Re: [javamug_discuss] Re: Java/Linux versus school teacher.]
Tom Hayden
tom.hayden.iii at mail.airmail.net
Mon Mar 19 13:29:43 CDT 2007
Steve,
Please see the link below. It takes you to the official Java documents
and appears to have a detailed discussion of this issue.
-------- Original Message --------
Subject: Re: [javamug_discuss] Re: [NTLUG:Discuss] Java/Linux versus
school teacher.
Date: Mon, 19 Mar 2007 10:23:41 -0700 (PDT)
From: Grant Lovaasen <g_lovaasen at yahoo.com>
To: Tom Hayden <tom.hayden.iii at mail.airmail.net>
See link below:
http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#19369
Tom Hayden <tom.hayden.iii at mail.airmail.net> wrote:
Steve,
I am forwarding this question to the JavaMUG discussion group where the
Java people can take a look at it. I suspect the "correct" answer has
more to do with Java than Linux
steve wrote:
> Do we have any Java/Linux guru's in the house?
>
> My son is learning Java in high school - inevitably they use
> Windows machines - but it's Java - which is portable - so it
> doesn't matter a whole lot. So my kid can use Linux to do
> his homework without problems.
>
> ...mostly...
>
> The other day, they had a Java Exam. The first two questions
> go like this:
>
> Assume x and y are String variables with x="Hello" and y=null.
>
> 1) The result of (x==y) is
> a) true
> b) false
> c) a syntax error
> d) a run-time error
> e) x being set to the value null.
>
> I think we can all agree that the answer is (b)false.
>
> 2) It the operation y="Hello"; is performed then the result
> of (x==y) is:
> a) true
> b) false
> c) x and y becoming aliases
> d) x being set to the value null
> e) a run-time error
>
> Question 2 is a problem. My son said "(a) true" but the
> teacher says that the answer is "(b)false" - and whilst
> I'm not a Java expert (I'm a C++ person) I can see why. Even
> though both x and y are set to "Hello", they don't refer to
> the same String object and the '==' operator doesn't compare
> the contents of the objects - it only tests whether the same
> object is being referenced on both sides. (At least according
> to "Java2 for Dummies" and my C++ intuition).
>
> When my son makes mistakes like that, I encourage him to write
> a little program to convince himself. The trouble is that when
> we tested it by writing a little Java program and running it
> under Linux:
>
> String x="Hello";
> String y="Hello";
> if ( x==y )
> println ( "true" ) ;
> else
> println ( "false" ) ;
>
> The answer comes out "true"...oh-oh!
>
> This suggests that some kind of optimisation is going on inside
> the Java compiler and the two instances of the "Hello" string are
> being combined into one single object or something.
>
> Clearly then the teacher is wrong and the correct answer is "either
> true or false depending on the implementation"...but I'm having
> a hard time believing that Java is that ill-specified. Is it in
> fact the case that Java under Windows would also have reported
> 'true'?
>
> So should I complain to the teacher? Stop using Linux for this
> stuff? (over my cold, dead body!)...Or is there something subtle
> that I'm missing here?
>
>
> Thanks!
>
> _______________________________________________
> http://www.ntlug.org/mailman/listinfo/discuss
<http://www.ntlug.org/mailman/listinfo/discuss>
>
>
>
--
Tom Hayden III
Coherent solutions for chaotic situations
tom.hayden.iii at mail.airmail.net
<mailto:tom.hayden.iii%40mail.airmail.net>
214-435-4174
2636 Verandah Ln.
Apartment 1431
Arlington Texas, 76006
__._,_.___
Messages in this topic
<http://groups.yahoo.com/group/javamug_discuss/message/211;_ylc=X3oDMTMzNTBwcHRnBF9TAzk3MzU5NzE0BGdycElkAzE1Mzg3NzY5BGdycHNwSWQDMTcwNTAwNjkwNQRtc2dJZAMyMTEEc2VjA2Z0cgRzbGsDdnRwYwRzdGltZQMxMTc0MzIyODM2BHRwY0lkAzIxMQ-->(1)
Reply (via web post)
<http://groups.yahoo.com/group/javamug_discuss/post;_ylc=X3oDMTJwdTFnZmUwBF9TAzk3MzU5NzE0BGdycElkAzE1Mzg3NzY5BGdycHNwSWQDMTcwNTAwNjkwNQRtc2dJZAMyMTEEc2VjA2Z0cgRzbGsDcnBseQRzdGltZQMxMTc0MzIyODM2?act=reply&messageNum=211>|
Start a new topic
<http://groups.yahoo.com/group/javamug_discuss/post;_ylc=X3oDMTJmbnI5Nm11BF9TAzk3MzU5NzE0BGdycElkAzE1Mzg3NzY5BGdycHNwSWQDMTcwNTAwNjkwNQRzZWMDZnRyBHNsawNudHBjBHN0aW1lAzExNzQzMjI4MzY->
Messages
<http://groups.yahoo.com/group/javamug_discuss/messages;_ylc=X3oDMTJmNGZpaHFvBF9TAzk3MzU5NzE0BGdycElkAzE1Mzg3NzY5BGdycHNwSWQDMTcwNTAwNjkwNQRzZWMDZnRyBHNsawNtc2dzBHN0aW1lAzExNzQzMjI4MzY->
| Links
<http://groups.yahoo.com/group/javamug_discuss/links;_ylc=X3oDMTJnc2pjdDNpBF9TAzk3MzU5NzE0BGdycElkAzE1Mzg3NzY5BGdycHNwSWQDMTcwNTAwNjkwNQRzZWMDZnRyBHNsawNsaW5rcwRzdGltZQMxMTc0MzIyODM2>
| Database
<http://groups.yahoo.com/group/javamug_discuss/database;_ylc=X3oDMTJkb2c3ZDhlBF9TAzk3MzU5NzE0BGdycElkAzE1Mzg3NzY5BGdycHNwSWQDMTcwNTAwNjkwNQRzZWMDZnRyBHNsawNkYgRzdGltZQMxMTc0MzIyODM2>
| Polls
<http://groups.yahoo.com/group/javamug_discuss/polls;_ylc=X3oDMTJnczQ0bWQ5BF9TAzk3MzU5NzE0BGdycElkAzE1Mzg3NzY5BGdycHNwSWQDMTcwNTAwNjkwNQRzZWMDZnRyBHNsawNwb2xscwRzdGltZQMxMTc0MzIyODM2>
| Members
<http://groups.yahoo.com/group/javamug_discuss/members;_ylc=X3oDMTJma2pjc2hyBF9TAzk3MzU5NzE0BGdycElkAzE1Mzg3NzY5BGdycHNwSWQDMTcwNTAwNjkwNQRzZWMDZnRyBHNsawNtYnJzBHN0aW1lAzExNzQzMjI4MzY->
| Calendar
<http://groups.yahoo.com/group/javamug_discuss/calendar;_ylc=X3oDMTJlMWo5aWVpBF9TAzk3MzU5NzE0BGdycElkAzE1Mzg3NzY5BGdycHNwSWQDMTcwNTAwNjkwNQRzZWMDZnRyBHNsawNjYWwEc3RpbWUDMTE3NDMyMjgzNg-->
Yahoo! Groups
<http://groups.yahoo.com/;_ylc=X3oDMTJlYzMwbTFyBF9TAzk3MzU5NzE0BGdycElkAzE1Mzg3NzY5BGdycHNwSWQDMTcwNTAwNjkwNQRzZWMDZnRyBHNsawNnZnAEc3RpbWUDMTE3NDMyMjgzNg-->
Change settings via the Web
<http://groups.yahoo.com/group/javamug_discuss/join;_ylc=X3oDMTJnMDZ0dWE0BF9TAzk3MzU5NzE0BGdycElkAzE1Mzg3NzY5BGdycHNwSWQDMTcwNTAwNjkwNQRzZWMDZnRyBHNsawNzdG5ncwRzdGltZQMxMTc0MzIyODM2>
(Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest
<mailto:javamug_discuss-digest at yahoogroups.com?subject=Email
Delivery: Digest> | Switch format to Traditional
<mailto:javamug_discuss-traditional at yahoogroups.com?subject=Change
Delivery Format: Traditional>
Visit Your Group
<http://groups.yahoo.com/group/javamug_discuss;_ylc=X3oDMTJlOWJmNGY1BF9TAzk3MzU5NzE0BGdycElkAzE1Mzg3NzY5BGdycHNwSWQDMTcwNTAwNjkwNQRzZWMDZnRyBHNsawNocGYEc3RpbWUDMTE3NDMyMjgzNg-->|
Yahoo! Groups Terms of Use <http://docs.yahoo.com/info/terms/>|
Unsubscribe
<mailto:javamug_discuss-unsubscribe at yahoogroups.com?subject=>
Visit Your Group
<http://groups.yahoo.com/group/javamug_discuss;_ylc=X3oDMTJmNjZ2Zzk3BF9TAzk3MzU5NzE0BGdycElkAzE1Mzg3NzY5BGdycHNwSWQDMTcwNTAwNjkwNQRzZWMDdnRsBHNsawN2Z2hwBHN0aW1lAzExNzQzMjI4MzY->
SPONSORED LINKS
* Dallas fort worth limousine
<http://groups.yahoo.com/gads;_ylc=X3oDMTJkb21vZDVuBF9TAzk3MzU5NzE0BF9wAzEEZ3JwSWQDMTUzODc3NjkEZ3Jwc3BJZAMxNzA1MDA2OTA1BHNlYwNzbG1vZARzdGltZQMxMTc0MzIyODM2?t=ms&k=Dallas+fort+worth+limousine&w1=Dallas+fort+worth+limousine&w2=Dallas+fort+worth+real+estate&w3=Dallas+fort+worth+limousine+service&w4=Dallas+fort+worth+home&w5=Dallas+fort+worth+hotel&c=5&s=166&g=2&.sig=Uk6hPzyt6rx6w5wfcxBZQw>
* Dallas fort worth real estate
<http://groups.yahoo.com/gads;_ylc=X3oDMTJkNTNjams0BF9TAzk3MzU5NzE0BF9wAzIEZ3JwSWQDMTUzODc3NjkEZ3Jwc3BJZAMxNzA1MDA2OTA1BHNlYwNzbG1vZARzdGltZQMxMTc0MzIyODM2?t=ms&k=Dallas+fort+worth+real+estate&w1=Dallas+fort+worth+limousine&w2=Dallas+fort+worth+real+estate&w3=Dallas+fort+worth+limousine+service&w4=Dallas+fort+worth+home&w5=Dallas+fort+worth+hotel&c=5&s=166&g=2&.sig=JP0B67LFIdAMvOV0VKn5TQ>
* Dallas fort worth limousine service
<http://groups.yahoo.com/gads;_ylc=X3oDMTJkNnViZTVqBF9TAzk3MzU5NzE0BF9wAzMEZ3JwSWQDMTUzODc3NjkEZ3Jwc3BJZAMxNzA1MDA2OTA1BHNlYwNzbG1vZARzdGltZQMxMTc0MzIyODM2?t=ms&k=Dallas+fort+worth+limousine+service&w1=Dallas+fort+worth+limousine&w2=Dallas+fort+worth+real+estate&w3=Dallas+fort+worth+limousine+service&w4=Dallas+fort+worth+home&w5=Dallas+fort+worth+hotel&c=5&s=166&g=2&.sig=ksGiXHcRXEK9b-5O87C5-g>
* Dallas fort worth home
<http://groups.yahoo.com/gads;_ylc=X3oDMTJkZGl2b3A0BF9TAzk3MzU5NzE0BF9wAzQEZ3JwSWQDMTUzODc3NjkEZ3Jwc3BJZAMxNzA1MDA2OTA1BHNlYwNzbG1vZARzdGltZQMxMTc0MzIyODM2?t=ms&k=Dallas+fort+worth+home&w1=Dallas+fort+worth+limousine&w2=Dallas+fort+worth+real+estate&w3=Dallas+fort+worth+limousine+service&w4=Dallas+fort+worth+home&w5=Dallas+fort+worth+hotel&c=5&s=166&g=2&.sig=dpn8EljPbvhdhQRlC7MWaA>
* Dallas fort worth hotel
<http://groups.yahoo.com/gads;_ylc=X3oDMTJkZHJuN3B1BF9TAzk3MzU5NzE0BF9wAzUEZ3JwSWQDMTUzODc3NjkEZ3Jwc3BJZAMxNzA1MDA2OTA1BHNlYwNzbG1vZARzdGltZQMxMTc0MzIyODM2?t=ms&k=Dallas+fort+worth+hotel&w1=Dallas+fort+worth+limousine&w2=Dallas+fort+worth+real+estate&w3=Dallas+fort+worth+limousine+service&w4=Dallas+fort+worth+home&w5=Dallas+fort+worth+hotel&c=5&s=166&g=2&.sig=LiO-yy2LgFEGe34pPWnBsA>
Cool Websites
Know a good site?
<http://us.ard.yahoo.com/SIG=12j8vv2ik/M=493064.10322723.10977639.9706567/D=groups/S=1705006905:NC/Y=YAHOO/EXP=1174330036/A=4438988/R=0/SIG=111nufaaj/*http://www.bix.com/contest/4746>
Share and vote
on Bix.com!
Y! Toolbar
Get it Free!
<http://us.lrd.yahoo.com/_ylc=X3oDMTJwMG43ZjQ4BF9TAzk3MzU5NzE0BF9wAzIEZ3JwSWQDMTUzODc3NjkEZ3Jwc3BJZAMxNzA1MDA2OTA1BHNlYwNuY21vZARzbGsDdG9vbGJhcgRzdGltZQMxMTc0MzIyODM2;_ylg=1/SIG=11c6dvmk9/**http%3A//toolbar.yahoo.com/%3F.cpdl=ygrps>
easy 1-click access
to your groups.
Yahoo! Groups
Start a group
<http://groups.yahoo.com/start;_ylc=X3oDMTJwODJncjJ2BF9TAzk3MzU5NzE0BF9wAzMEZ3JwSWQDMTUzODc3NjkEZ3Jwc3BJZAMxNzA1MDA2OTA1BHNlYwNuY21vZARzbGsDZ3JvdXBzMgRzdGltZQMxMTc0MzIyODM2>
in 3 easy steps.
Connect with others.
.
__,_._,___
========================
Grant Lovaasen
grant.lovaasen at yahoo.com
========================
--
Tom Hayden III
Coherent solutions for chaotic situations
tom.hayden.iii at mail.airmail.net
214-435-4174
2636 Verandah Ln.
Apartment 1431
Arlington Texas, 76006
More information about the Discuss
mailing list