aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Good one.....  ( System.out.println() ) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Good one.....  ( System.out.println() )" Watch "Good one.....  ( System.out.println() )" New topic
Author

Good one..... ( System.out.println() )

Adeeshwar Singhal
Greenhorn

Joined: Oct 18, 2000
Posts: 28
Guess the ans............

System.out.println(5+4+3*2+" equals "+5+4+3*2);
scroll down to see the ans.......
















15 equals 546
It is just for information... If anybody needs explanation, come and burn it with fire.............
Anyone interested in Overriding question see the Tricky one............. by me again.......
Adeesh
---------------------------------------------
It is chilling cold out here, Start burning ur wood ranchians.....
[This message has been edited by Adeeshwar Singhal (edited November 30, 2000).]
[This message has been edited by Adeeshwar Singhal (edited November 30, 2000).]
[This message has been edited by Adeeshwar Singhal (edited November 30, 2000).]


Hey guys!! come and have some cups of HOT JAVA........<BR>Adeesh
Jorma Koistinen
Greenhorn

Joined: Nov 30, 2000
Posts: 7
Guess the ans...
public class Have{
private Have(){
int x=1702845791;
int y=014537656537;
int a=0x657f5d5e;
int b=014537656540;
System.out.println(this.getClass().getName()+" "+Integer.
toHexString(x--<<(y-->>>(a++/x*x++^--a))/(b++>>>(y--/--a))).
toUpperCase());
}
public static void main(String[]_){
new Have();
}
}</code>
jorma
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4340
    
    2

i think the first part of an overloaded + has to be a String


SCJP
Visit my download page
Amond Adams
Ranch Hand

Joined: Nov 28, 2000
Posts: 62
Have CAFEBABE
Adeeshwar Singhal
Greenhorn

Joined: Oct 18, 2000
Posts: 28
Have some CAFE JORMA.
That was really good one....... Could u also throw some light on it by dissecting it a bit.
Hope to hear from u soon......
Adeesh
( Try the one on Overriding with subject as Tricy One...........)
-------------------------------------------
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
Isn't this one same as the old post??
Ajith


Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Jorma Koistinen
Greenhorn

Joined: Nov 30, 2000
Posts: 7
<html>
<body>
<pre>
Hi Adeeshwar !
I try to throw some light to this code.
The Operator precedence is the only thing to look at:
Operators listed from highest precedence to lowest:
</pre>
GroupOperators
postfix operators <code>[] . (params) expr++ expr--</code>
unary operators <code>++expr --expr +expr -expr ~ !</code>
creation or cast <code>new (type)expr</code>
multiplicative <code>* / %</code>
additive <code>+ -</code>
shift <code><< >> >>></code>
relational <code>< > >= <= instanceof</code> <tr><td>equality <td><code>== !=</code> <tr><td>bitwise AND <td><code>&</code> <tr><td>bitwise exclusive XOR <td><code>^</code> <tr><td>bitwise inclusive OR <td><code>|</code> <tr><td>logical AND <td><code>&&</code> <tr><td>logical OR <td><code>| |</code> <tr><td>conditional <td><code>?:</code> <tr><td>assignment <td><code>= += -= *= /= %= >>= <<= >>>= &= ^= |=</code>


<pre>
public class Have{
private Have(){
int x=1702845791; //Decimal = 0xcafebabe/2
int y=014537656537; //Octal = 0xcafebabe/2
int a=0x657f5d5e; //Hex = 0xcafebabe/2 -1
int b=014537656540; //Octal 0xcafebabe/2 +1
/*
System.out.println(this.getClass().getName()+" "+Integer.
toHexString(x--<<(y-->>>(a++/x*x++^--a))/(b++>>>(y--/--a))).
toUpperCase());
*/
//(x--<<(y-->>>(a++/x*x++^--a))/(b++>>>(y--/--a)))
//Splitting this Monster to smaller pieces in this order:

x--; //From left to right
y--;
int par1=(a++/x*x++^--a);//First parenthes to count
int par2=(y>>>par1); //Unsigned shift
b++;
int par3=(y--/--a);
int par4=(b>>>par3);
int par5=(par2/par4);//Integer division= 1
int par6=(x<<par5); >
//Overflow OOps !! ??
//I didn't ment that way x<<1 = x*2

System.out.println(this.getClass().getName()+" "+Integer.
toHexString(par6).toUpperCase());
}
public static void main(String[]_){
new Have();
}
}
I hope this helps
</pre></body></html>

[This message has been edited by Jorma Koistinen (edited December 01, 2000).]
[This message has been edited by Jorma Koistinen (edited December 01, 2000).]
[This message has been edited by Jorma Koistinen (edited December 01, 2000).]
Adeeshwar Singhal
Greenhorn

Joined: Oct 18, 2000
Posts: 28
Thanks for such a wonderful explanation of operator precedence Jorma.
I understood ur explanation very well. But I couldn't get exactly why did it print CAFEBABE. Does this toHexString() do all the magic or there is something else.......
Adeesh
----------------------------------------------------
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Good one..... ( System.out.println() )