This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Answer Choices: - Compilation Error - Compile and print 100 - Throw a runtime exception My answer to this was (Compilation error), as Im trying to assign a 32 bit int to an 8 bit byte, hence loss of precision. However the compiler doesnt complain and instead compiles fine and prints out 100. If i remove the final from int i = 100; declaration and the rest of the code remains the same i do get a compilation error. Comments? Thoughts? [ July 31, 2003: Message edited by: SMZ ]
This code compiles fine and output is 100 Here final int i is a compile time constant. You don't have any casting problem. If you remove final from 'final int i' you would get possible loss of precision error. The answer is 'Compile and print 100'.
Joined: Jul 31, 2003
Yeah now it makes sense.... Thanx so much for your help Venu