exam questions

Exam 70-483 All Questions

View all questions & answers for the 70-483 exam

Exam 70-483 topic 2 question 1 discussion

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

You are developing an application.
The application contains the following code segment (line numbers are included for reference only):

When you run the code, you receive the following error message: "Cannot implicitly convert type 'object'' to 'int'. An explicit conversion exists (are you missing a cast?)."
You need to ensure that the code can be compiled.
Which code should you use to replace line 05?

  • A. var2 = arrayl[0] as int;
  • B. var2 = ((List<int>)arrayl) [0];
  • C. var2 = arrayl[0].Equals(typeof(int));
  • D. var2 = (int) arrayl [0];
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️

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
founderDev
Highly Voted 5 years, 3 months ago
It's D. Because as conversion can return null
upvoted 8 times
...
TonyBezerra
Highly Voted 5 years, 2 months ago
The right answer is D.
upvoted 8 times
...
DaGrooveNL
Most Recent 4 years, 3 months ago
FINAL ANSWER: D
upvoted 2 times
...
Aerologic
5 years, 5 months ago
I believe that A should be the correct answer since "as int" will resolve to null if the conversion can't be done. Otherwise casting with (int) will throw an exception if it can't be done.
upvoted 2 times
majco333
5 years, 5 months ago
Your answer isn't compiled... It's D
upvoted 6 times
...
mendolf92
5 years, 3 months ago
well var2 is of type int, therefor as int is not working for that type
upvoted 2 times
...
tanujgyan
5 years, 1 month ago
For A to be correct var2 needs to be nullable or reference type. int is a value type
upvoted 8 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 ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago