nerdexam
Microsoft

98-361 · Question #383

98-361 Question #383: Real Exam Question with Answer & Explanation

The correct answer is D. Rectangle r = o is Rectangle;. See the full explanation below for the reasoning.

Question

You are C# developer who is developing a Windows application. You write the following code: Object o; Later in the code, you need to assign the value in the variable o to an object of Rectangle type. You expect that at runtime the value in the variable o is compatible with the Rectangle class. However, you need to make sure that no exceptions are raised when the value is assigned. Which of the following code should you use?

Options

  • ARectangle r = (Rectangle) o;
  • BRectangle r = o;
  • CRectangle r = o as Rectangle;
  • DRectangle r = o is Rectangle;

Community Discussion

No community discussion yet for this question.

Full 98-361 Practice