aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes ID:3 SCJP Question of the day : Thursday June 10 2010 Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "ID:3 SCJP Question of the day : Thursday June 10 2010" Watch "ID:3 SCJP Question of the day : Thursday June 10 2010" New topic
Author

ID:3 SCJP Question of the day : Thursday June 10 2010

Martin Vanyavchich
Ranch Hand

Joined: Sep 16, 2008
Posts: 241
What will be the output of this code:




You know the rules, let's see your answers


Ref to rules... http://www.coderanch.com/t/498524/java-programmer-SCJP/certification/ID-SCJP-day-Wednesday-June

[HENRY: Added Reference. Change title id as requested]


SCJP 6, OCMJD 6, OCPJWSD 6
I no good English.
Sahil Kapoor
Ranch Hand

Joined: Sep 12, 2009
Posts: 316
Dude please do follow the Rules....If possible
Use ID3 instead of ID2

I have already posted ID2.......... i mean before you posted it !!!

You can just change the ID number to 3 in subject line !!!

Thanks for encouraging the concept !!!

Cheers!!!


SCJP 6.0 96%

(Connecting the Dots ....)
Sahil Kapoor
Ranch Hand

Joined: Sep 12, 2009
Posts: 316
Compilation Error :- I think ^(XOR) can be applied to integers only ~~!!!
Martin Vanyavchich
Ranch Hand

Joined: Sep 16, 2008
Posts: 241
Sorry about the ID, when I started to post, your thread wasn't up yet. I will try to change it

... and your answer is correct, while the explanation isn't . The '^' XOR can be applied to booleans.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35248
    
    7
Please leave the name out of the subject - it's long enough as it is. What's more, the name is visible wherever the topic title is visible, so it's redundant to begin with.


Android appsImageJ pluginsJava web charts
Martin Vanyavchich
Ranch Hand

Joined: Sep 16, 2008
Posts: 241
Ulf is right. We could shorten the titles to just "ID# SCJP QOTD" since all othed info is visible wher you select the thread
Sahil Kapoor
Ranch Hand

Joined: Sep 12, 2009
Posts: 316

Ulf Dittmer wrote:Please leave the name out of the subject - it's long enough as it is. What's more, the name is visible wherever the topic title is visible, so it's redundant to begin with.


Okay i agree, we would leave the name of an author from now onwards , but please do keep the date , inspite of being redundant, it looks attractive !!!

Sahil Kapoor
Ranch Hand

Joined: Sep 12, 2009
Posts: 316
If XOR can be applied to booleans
then

Compilation error is on line 12

as (short+short) is solved to (int)
and then int cannot be applied to short again without the explicit cast.

So we could do the following :-

Peter Taucher
Ranch Hand

Joined: Nov 18, 2006
Posts: 174
The code doesn't compile. But if you'd cast the result of the addition / subtraction to short it would be '100'...


Censorship is the younger of two shameful sisters, the older one bears the name inquisition.
-- Johann Nepomuk Nestroy
Martin Vanyavchich
Ranch Hand

Joined: Sep 16, 2008
Posts: 241
Sahil and Peter got it right! I'll try to make it more of a challenge the next time
Lalit Mehra
Ranch Hand

Joined: Jun 08, 2010
Posts: 369

I agree with Sahil because ... the auto conversion mechanism of java converts short to int when compiling so we need to re cast the same to short .

@sahil ... XOR can be applied to boolean values as well


http://plainoldjavaobject.blogspot.in
Sahil Kapoor
Ranch Hand

Joined: Sep 12, 2009
Posts: 316
Thanks Lalit , i remember it now !!!

Lalit Mehra
Ranch Hand

Joined: Jun 08, 2010
Posts: 369

@Sahil --> your welcome bro
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: ID:3 SCJP Question of the day : Thursday June 10 2010
 
Similar Threads
How to use OR in Regular Expressions?
ID:8 SCJP Question of the day !!!
Boolean Logic
SCJP 1.5 Objective 6.2, hashCode() and equals()
ID:1 SCJP Question of the day !!! Tuesday, August 24 2010