What is output with the statement System.out.println(x+y); if x and y are int values where x=10 and y=5?


What is output with the statement System.out.println(x+y); if x and y are int values where x=10 and y=5?


a) 15

b) 105

c) 10 5

d) x+y

e) An error since neither x nor y is a String

Answer: a. Explanation: Java first computes x+y and then casts it as a String to be output. x + y = 10 + 5 = 15, so the statement outputs 15.