What Will Be The Correct Statement In The Following C Codep Pre #362
What will be the Correct statement in the following C# code?</p> <pre><code class="language-csharp" line="1"> class baseclass { int a; public baseclass(int a1) { a = a1; console.writeline(" a "); } class derivedclass : baseclass { public derivedclass (int a1) : base(a1) { console.writeline(" b "); } } class program { static void main(string[] args) { derivedclass d = new derivedclass(20); } } } </code></pre>
This multiple choice question (MCQ) is related to the book/course gs gs108 CSharp. It can also be found in gs gs108 Object Oriented Concepts - Inheritance Implementation - Quiz No.1.
What will be the Correct statement in the following C# code?
class baseclass { int a; public baseclass(int a1) { a = a1; console.writeline(" a "); } class derivedclass : baseclass { public derivedclass (int a1) : base(a1) { console.writeline(" b "); } } class program { static void main(string[] args) { derivedclass d = new derivedclass(20); } } }
Compile time error
b a
a b
The program will work correctly if we replace base(a1) with base.baseclass(a1)