A

Admin • 833K Points
Coach

Q. What is the output for the below code?
public class Test{
public static void main(String[] args){
int i = 010;
int j = 07;
System.out.println(i);
System.out.println(j);
}
}

  • (A) 8 7
  • (B) 10 7
  • (C) Compilation fails with an error at line 3
  • (D) Compilation fails with an error at line 3 D. Compilation fails with an error at line 5
  • Correct Answer - Option(A)
  • Views: 36
  • Filed under category Java
  • Hashtags:

Explanation by: Admin

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

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.