exam questions

Exam 70-483 All Questions

View all questions & answers for the 70-483 exam

Exam 70-483 topic 1 question 17 discussion

Actual exam question from Microsoft's 70-483
Question #: 17
Topic #: 1
[All 70-483 Questions]

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;
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
misbelieving
3 years, 8 months ago
A: (float) unboxes the float from object, (int) casts the float to int
upvoted 1 times
...
Gobe
4 years, 8 months ago
int balance = (int)amountRef; doesn't show compile time error, why is that?
upvoted 1 times
Tomtidom
4 years, 5 months ago
It does throw an invallid cast exception at runtime
upvoted 1 times
...
...
lh2607
4 years, 11 months ago
A is correct
upvoted 1 times
...
robinnirola
5 years, 1 month ago
A. int balance = (int) (float)amountRef;
upvoted 1 times
...
tanujgyan
5 years, 2 months ago
A is correct answer
upvoted 1 times
...
Idoudist
5 years, 2 months ago
correct , (float) amountRef convert object to float (int) (float) amountRef convert (float) amountRef to int , this way we make sure that code does not throw exception by directly casting amountRef to int , B false
upvoted 3 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...