What is the output of the following java program? public class Solution{
What is the output of the following java program?
public class Solution{
public static void main(String[] args){
int[] p = {121, 201, 017};
for(int j = 0; j < p.length; j++){
System.out.print(p[j] + " ");
}
}
}
Show answerHide answer
Correct answer: (B) 1121 201 15
Explanation
A leading 0 makes 017 an octal literal, which equals 15. The program prints 121 201 15, which is option (B) (its text shows a stray leading 1).