ExamVeda
Login
Home
Data Types and Variables
?

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);
      }
}

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

Examveda
Question posted by Examveda
Community

Join the Discussion

4 Comments
Brijesh Kumar
Brijesh Kumar 6 years ago
Priyank sharma: output will be 8
Rajesh C
Rajesh C 7 years ago
010 means
10 = 001 000
Right to left (001 000)
2³= 8
Yubraj Singh
Yubraj Singh 8 years ago
in code written plrintln which means 7 must be print in next line it print in same line
Priyank Sharma
Priyank Sharma 10 years ago
What is the O/P of following program:

public class DemoOctal {
public static void main(String[] args) {
int i=010;

System.out.println(i);
}
}