I liked the question of Praveen. And it inspired me to this exam question.
What happens when you compile and execute this code? (JSE 1.5)
Choose all that apply!
ACompilation fails due to an error in line 1 BCompilation fails due to an error in line 2 CCompilation fails due to an error in line 3 DCompilation fails due to an error in line 4 ECompilation fails due to an error in line 5 FCompiles and throws an Exception when executed GCompiles and prints trueREADY HCompiles and prints falseREADY ICompiles and prints nullREADY JVM dependent KNone of the above
both declarations are the same in that they declare an array of ints (1D) even if the brackets were positioned differently (though the first declarion is more readable & recommended). however, position of the brackets become significant when multiple declaration is involved:
You will find this topic written about in the K & B book (or any good Java book) together with the comment to the effect of "it may be legal, but that does not mean it's good programming style".
Please do not use this topic as a general puzzlers topic. Keep topics specific to one issue. Also consider whether the issue is SCJP specific or whether it is a puzzling aspect of Java which could be equally well discussed in one of our Java In General forums (Beginner, Intermediate, Advanced).
If you are really interested in such puzzlers, treat yourself to a copy of "Java Puzzlers" coauthored by Joshua Bloch. [ September 02, 2006: Message edited by: Barry Gaunt ]