Problemas
What are the memory values associated with the variables x,y and z after the code snippet below executes? int x=7 double y=2.Theta boolean z=false x=x+3 z true; x holds the int value 7, y holds the double value 2.8 and holds the boolean value false x holds the int value 10, y holds the double value 2.0 and z holds the boolean value true This code snippet will result in a compile time error. x holds the int value 10, y holds the double value 2.8 and z holds the boolean value fals
Solución
Aldoélite · Tutor durante 8 años
Verificación de expertos
4.2 (419 votos)
Responder
The correct answer is: x holds the int value 10, y holds the double value 2.0 and z holds the boolean value true.<br /><br />Explanation:<br />1. The initial values of the variables are:<br /> - int x = 7<br /> - double y = 2.0<br /> - boolean z = false<br /><br />2. The code snippet performs the following operations:<br /> - x = x + 3<br /> - z = true;<br /><br />3. After the code snippet executes, the values of the variables will be:<br /> - x = 7 + 3 = 10<br /> - y remains unchanged at 2.0<br /> - z is set to true<br /><br />Therefore, the correct answer is that x holds the int value 10, y holds the double value 2.0, and z holds the boolean value true.
Haz clic para calificar: