RajAjmani

Greenhorn
+ Follow
since May 21, 2002
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by RajAjmani

I am planning to appear for Java exam in the comming month. This giveaway sounds good. If I am lucky I can go through this book which can help me a lot ....
Which of the following lines if placed after the comment //Here will print out 0.
1) System.out.println(i++);
2) System.out.println(i+'0');
3) System.out.println(i);
4) System.out.println(i--);
Answer to Question 8)
1) System.out.println(i++);
3) System.out.println(i);
4) System.out.println(i==);
The options for this question might look suspiciously easy if you are not aware of the effects of
the post-increment operators. The ++ and == operations for examples 1 and 4 only come into
effect after the output operations, ie after whatever else is done to them on that line of
code. Option 2 should be fairly obvious as you should know that the single quote characters
indicate a char value, ie storing the character rather than the numberical value for 0.
MyDoubt
y is option 2 wrong ?
Ans: because of int value of '0' is 48. it will be 0 + 48 which equals 48.