Q50
What will be the output of the following C# code snippet? class B class A : B class Program static void Main(string[] args) A a = new A(); B b = new B(); if (a is A) Console.WriteLine("a is an A"); if (b is A) Console.WriteLine("b is an A because it is derived from A"); if (a is B) Console.WriteLine("This won’t display -- a not derived from B"); Console.ReadLine();
A.
a is an A
This won't display -- a not derived from B
AnswerThis won't display -- a not derived from B
B.
a is an A
b is an A because it is derived from A
b is an A because it is derived from A
C.
b is an A because it is derived from A
This won't display -- a not derived from B
This won't display -- a not derived from B
D.
"Both "a is an A
This won't display - a not derived from B" & "a is an A
b is an A because it is derived from A"
This won't display - a not derived from B" & "a is an A
b is an A because it is derived from A"
Answer: Option A
Solution
Answer: Option A
No explanation is given for this question Let's Discuss on Board