giovedì 28 marzo 2013

Q53


Given the following code:
public class Simple { /* Line 1 */
       public float price; /* Line 2 */
       public static void main(String[] args) { /* Line 3 */
             Simple price = new Simple(); /* Line 4 */
             price = 4; /* Line 5 */
       } /* Line 6 */
} /* Line 7 */

What will make this code compile and run?
A.
Change line 2 to the following:
Public int price
B.
Change line 4 to the following:
int price = new Simple ();
C.
Change line 4 to the following:
Float price = new Simple ();
D.
Change line 5 to the following:
price = 4f;
E.
Change line 5 to the following:
price.price = 4;
F.
Change line 5 to the following:
price = (float) 4:
G.
Change line 5 to the following:
price = (Simple) 4;
H.
The code compiles and runs properly; no changes are necessary

Risposta : E
L’attributo price va settato

 

Nessun commento:

Posta un commento