Welcome Guest | Sign in | Register
Variables and Loops - Discussion Page For Q.2972 | Java Programming Questions and Answers | Java Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > Variables and Loops > Questions and Answers

Q: What is the output for the below code ?

1. public class Test {
2. public static void main(String[] args){
3. int i = 010;
4. int j = 07;
5. System.out.println(i);
6. System.out.println(j);
7. }
8. }
A. 8 7 B. 10 7
C. Compilation fails with an error at line 3 D. Compilation fails with an error at line 5

Answer and Explanation

Answer:8 7

Explanation:
By placing a zero in front of the number is an integer in octal form. 010 is in octal form so its value is 8.

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.