Java OCA OCP Practice Question 1736

Question

What will be the result of compiling and running the following program?

public class Main {
  public static void main(String[] args) {
    System.out.println(0x10 + 10 + 010);
  }
}

Select the one correct answer.

  • (a) The program will not compile because of errors in the expression 0x10 + 10 + 010.
  • (b) When run, the program will print 28.
  • (c) When run, the program will print 30.
  • (d) When run, the program will print 34.
  • (e) When run, the program will print 36.
  • (f) When run, the program will print 101010.


(d)

Note

0x10 is a hexadecimal literal equivalent to the decimal value 16.10 is a decimal literal.

010 is an octal literal equivalent to the decimal value 8.

The println() method will print the sum of these values, which is 34, in decimal form.




PreviousNext

Related