πŸ“Š JAVA
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
πŸ’¬ Discuss
βœ… Correct Answer: (A) 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

Explanation by: Ritu Singhal
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

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
77
Total Visits
πŸ“½οΈ
12 mo ago
Published
πŸŽ–οΈ
Ritu Singhal
Publisher
πŸ“ˆ
86%
Success Rate