Multiple choice technology programming languages

public class A{ public A() { Console.WriteLine("A");} } public class B: A { public B(){Console.WriteLine("B"); void print() {Console.WriteLine("Print"); }} public static void Main() { B b = new B(); b.print(); } }

  1. A B print

  2. print

  3. B

  4. B print

  5. print B A

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

When creating a derived class instance, the base class constructor runs first, then the derived constructor. Here, A's constructor prints "A", then B's constructor prints "B", and finally print() outputs "print".