What is output with the statement System.out.println(x+y); if x and y are int values where x=10 and y=5? Group of answer choices 15 105 10 5 x+y An error since neither x nor y is a String

Respuesta :

ijeggs

Answer:

15

Explanation:

Java's output statement can be used to print String values when the are enclosed in a pair of quotations marks (" "). Given that the values x =10 and y=5 have been declared as integers, the statement:

System.out.println(x+y); will output 10+15 = 15

On the other hand consider if these variables x and y were declared as Strings like this;

String x="10";

String y ="5";

Then the output of the statement System.out.println(x+y); will be 105