gs gs108 Delegates, Generics and LINQ - Runtime Type - Quiz No.1
gs gs108 CSharp Quiz
This quiz belongs to book/course code gs gs108 CSharp of gs organization. We have 110 quizzes available related to the book/course CSharp. This quiz has a total of 10 multiple choice questions (MCQs) to prepare and belongs to topic Delegates, Generics and LINQ. NVAEducation wants its users to help them learn in an easy way. For that purpose, you are free to prepare online MCQs and quizzes.
NVAEducation also facilitates users to contribute in online competitions with other students to make a challenging situation to learn in a creative way. You can create one to one, and group competition on an topic of a book/course code. Also on NVAEducation you can get certifications by passing the online quiz test.
expr is type
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 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
b is an A because it is derived from A This won’t display -- a not derived from B
"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"""
class A {} class B : A {} class CheckCast { static void Main() { A a = new A(); B b = new B(); b = a as B; b = null; if(b==null) Console.WriteLine("The cast in b = (B) a is NOT allowed."); else Console.WriteLine("The cast in b = (B) a is allowed"); } }
class UseTypeof { static void Main() { Type t = typeof(StreamReader); Console.WriteLine(t.FullName); if(t.IsClass) Console.WriteLine("Is a class."); if(t.IsAbstract) Console.WriteLine("Is abstract."); else Console.WriteLine("Is concrete."); } }
Is a class Is abstract
System.IO.StreamReader Is a class Is concrete
Both Is a class Is abstract & System.IO.StreamReader Is a class Is concrete