What will make this code compile and run?

Given the following code: What will make this code compile and run?

Given the following code: What will make this code compile and run?

A.
Change line 5 to the following: Price = (float) 4:

B.
Change line 5 to the following: Price = (Simple) 4;

C.
Change line 5 to the following: price.price = 4;

D.
Change line 4 to the following: Float price = new simple ();

E.
Change line 4 to the following: int price = new simple ();

F.
Change line 2 to the following: Public int price

G.
Change line 5 to the following: Price = 4f;



Leave a Reply 2

Your email address will not be published. Required fields are marked *


Sanket Patel

Sanket Patel

Hey,

In this question even f could be write ans and G also,
C is wrong because float has to specif ‘f’ at the end.

Regards,
Sanket Patel

Gordon

Gordon

You don’t have to put f at the end since 4 is an integer which can be implicitly converted to float.
C is correct.