Q. What is the output for the below code ?

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
πŸ’¬ 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: Jatin Dubey
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

πŸ‘οΈ
203
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Jatin Dubey
Publisher
πŸ“ˆ
95%
Success Rate