You are implementing a method named Calculate that performs conversions between value types
and reference types. The following code segment implements the method. (Line numbers are
included for reference only.)
You need to ensure that the application does not throw exceptions on invalid conversions.
Which code segment should you insert at line 04?
A.
int balance = (int) (float)amountRef;
B.
int balance = (int)amountRef;
C.
int balance = amountRef;
D.
int balance = (int) (double) amountRef;
A
A – tested in VS
unboxing is explicit. boxing is implicit. unboxing the obj to float then performing a narrowing conversion which is also explicit
20 new questions on the latest dump from March 2017.
http://optifiles.com/70483ProgrammingInC
A : you can review this on stackoverflow
https://stackoverflow.com/questions/3953391/why-does-intobject10m-throw-specified-cast-is-not-valid-exception