permaculture playing cards*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes doubt in explanation  dam mock question 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 "doubt in explanation  dam mock question" Watch "doubt in explanation  dam mock question" New topic
Author

doubt in explanation dam mock question

zaghal mohd
Ranch Hand

Joined: Jun 27, 2002
Posts: 43
I have a doubt in explanation dam mock question... this is the question:
class Lg {
public static void main (String s[]) {
int i = 1 | 2 ^ 15 & 7 ^ 13 | 2;
System.out.println(i % 5);
}
}
the answer its ok but in explanation
(1 | (2 & (3 >> ((1 / 2) + 3)))), (1 | (2 & (3 >> ((0) + 3)))), (1 | (2 & (3 >> (3)))), (1 | (2 & (24))), (1 | (0))=1
I think (3 >> ((0) + 3)))) will give you zero not 24
Correct me please


SCJP,SCWCD,CCNA,CCAI,MCP,MCSA,MCSE<br />working on CCNP+SCBCD
zaghal mohd
Ranch Hand

Joined: Jun 27, 2002
Posts: 43
Sorry folks I wrote wrong question her its
class M {
static int m(int i) {
System.out.print(i + ", ");
return i;
}
public static void main(String s[]) {
int i=0;
int j=0;
System.out.print(m(++i) | m(++i) & m(++i) >> m(++j) / m(++j) + m(++j));
}
}
Dan Chisholm
Ranch Hand

Joined: Jul 02, 2002
Posts: 1865
Last Sunday, the correction was uploaded to the September 27 version.

Answer "b. Prints: 1,2,3,1,2,3,1"

Java evaluates expressions from left to right while respecting operator precedence. (1 | (2 & (3 >> ((1 / 2) + 3)))), (1 | (2 & (3 >> ((0) + 3)))), (1 | (2 & (3 >> (3)))), (1 | (2 & (0))), (1 | (0))=1

[ October 09, 2002: Message edited by: Dan Chisholm ]

Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>
zaghal mohd
Ranch Hand

Joined: Jun 27, 2002
Posts: 43
Thanks a lot dan for your nice mock its very helpful mocks
best wishes
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: doubt in explanation dam mock question
 
Similar Threads
doubt in ++ operator
Array doubt
Doubt About the output of this Question
Arrays doubt
array doubt