?
What is the output for the below code?
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);
}
}
public class Test{
public static void main(String[] args){
int i = 010;
int j = 07;
System.out.println(i);
System.out.println(j);
}
}
Answer & Solution
Correct Answer:
Option
A
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
Join the Discussion
Login to post a comment or share your explanation.
Login10 = 001 000
Right to left (001 000)
2³= 8
public class DemoOctal {
public static void main(String[] args) {
int i=010;
System.out.println(i);
}
}