11 What will the following code print out? public class Oct{ public static void main(String argv[]){ Oct o = new Oct(); o.amethod(); } public void amethod(){ int oi= 012; System.out.println(oi); } }

  1. A 12

  2. B 012

  3. C 10

  4. D 10.0


Correct Option: C
Explanation:

To solve this question, the user needs to know the basics of Java programming language. The code creates an object of the Oct class and then calls the amethod() method, which initializes an integer variable oi with 012 and prints its value to the console.

In Java, leading zero in an integer literal denotes an octal (base-8) number. Therefore, the value 012 is an octal number that represents the decimal value 10.

So, the correct answer is:

The Answer is: C. 10

Find more quizzes: