What will be the output of the below C# code ?
public class ABC { public int A { set; get; } } static void Main(string[] args) { ABC obj1 = new ABC(); obj1.A = 101; ABC obj2 = new ABC(); obj2 = obj1; obj2.A = 102; Console.WriteLine(obj1.A); Console.WriteLine(obj2.A); }
Output:
102
102
What will be the output of the below C# code ?
public class A { public void Print() { Console.WriteLine("Class A"); } } public class B : A { public virtual new void Print() { Console.WriteLine("Class B"); } } public class C : B { public override void Print() { Console.WriteLine("Class C"); } } static void Main(string[] args) { B b = new B(); b.Print(); C c = new C(); c.Print(); A a = new B(); a.Print(); B b1 = new C(); b1.Print(); }
Output:
Class B
Class C
Class A
Class C
Pages: 1 2