Classes And Objects In C Sharp — Part 2 MCQs with Explanations
Practice high-yield Programming & Software Development MCQs on Classes And Objects In C Sharp — Part 2 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.
Questions
40
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
48 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
40
Verified Practice Questions
Interactive test mode with detailed academic worked solutions
Live Progress|0/40 answered
✓0 correct
✗0 wrong
0% score
🎉 Set complete! All 40 questions answered.
Question 1 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C# code? static void Main(string[] args) { Mul(); m(); Console.ReadLine(); } static void Mul() { Console.WriteLine("4"); } static void m() { Console.WriteLine("3"); Mul(); }
Correct Answer: Option C — 4 3 4
Detailed Academic Explanation:
4 3 4 is the correct answer to “What will be the output of the following C# code? static void Main(string[] args) { Mul(); m(); Console.ReadLine(); } static void Mul() { Console.WriteLine("4"); } static void m() { Console.WriteLine("3"); Mul(); }”. This question is standard in competitive examination syllabi for Classes And Objects In C Sharp.
💡Key Conceptual Anchor:Classes And Objects In C Sharp
Question 2 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which among the following is the correct statement: Constructors are used to?
Correct Answer: Option A — initialize the objects
Detailed Academic Explanation:
initialize the objects is the correct answer to “Which among the following is the correct statement: Constructors are used to”. This question is standard in competitive examination syllabi for Classes And Objects In C Sharp.
💡Key Conceptual Anchor:Classes And Objects In C Sharp
Question 3 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the correct statement of the following C# code? enum color:byte { yellow = 500, green = 1000, pink = 1300 }
Correct Answer: Option D — When the valid range of byte exceeds, the compiler will report an error
Detailed Academic Explanation:
When the valid range of byte exceeds, the compiler will report an error is the correct answer to “What will be the correct statement of the following C# code? enum color:byte { yellow = 500, green = 1000, pink = 1300 }”. This question is standard in competitive examination syllabi for Classes And Objects In C Sharp.
💡Key Conceptual Anchor:Classes And Objects In C Sharp
Question 4 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Choose the correct statement about enum used in C#.NET?
Correct Answer: Option B — Values of the enum elements cannot be populated from database
Detailed Academic Explanation:
Values of the enum elements cannot be populated from database is the correct answer to “Choose the correct statement about enum used in C#.NET”. This question is standard in competitive examination syllabi for Classes And Objects In C Sharp.
💡Key Conceptual Anchor:Classes And Objects In C Sharp
Question 5 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C# code? { struct abc { int i; } class Program { static void Main(string[] args) { abc x = new abc(); abc z; x.i = 10; z = x; z.i = 15; console.Writeline(x.i + " " + y.i) } } }
Correct Answer: Option B — 10 15
Detailed Academic Explanation:
10 15 is the correct answer to “What will be the output of the following C# code? { struct abc { int i; } class Program { static void Main(string[] args) { abc x = new abc(); abc z; x.i = 10; z = x; z.i = 15; console.Writeline(x.i + " " + y.i) } } }”. This question is standard in competitive examination syllabi for Classes And Objects In C Sharp.
💡Key Conceptual Anchor:Classes And Objects In C Sharp
Question 6 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C# code snippet? class maths { public int fact(int n) { int result; result = fact(n - 1) * n; return result; } } class Program { static void Main(string[] args) { maths obj = new maths(); Console.WriteLine(obj.fact(4)); Console.ReadLine(); } }
Correct Answer: Option D — Runtime Error
Detailed Academic Explanation:
Runtime Error is the correct answer to “What will be the output of the following C# code snippet? class maths { public int fact(int n) { int result; result = fact(n - 1) * n; return result; } } class Program { static void Main(string[] args) { maths obj = new maths(); Console.WriteLine(obj.fact(4)); Console.ReadLine(); } }”. This question is standard in competitive examination syllabi for Classes And Objects In C Sharp.
💡Key Conceptual Anchor:Classes And Objects In C Sharp
Question 7 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C# code? class A { public int i; private int j; } class B :A { void display() { base.j = base.i + 1; Console.WriteLine(base.i + " " + base.j); } } class Program { static void Main(string[] args) { B obj = new B(); obj.i = 1; obj.j = 2; obj.display(); Console.ReadLine(); } }
Correct Answer: Option D — compile time error
Detailed Academic Explanation:
compile time error is the correct answer to “What will be the output of the following C# code? class A { public int i; private int j; } class B :A { void display() { base.j = base.i + 1; Console.WriteLine(base.i + " " + base.j); } } class Program { static void Main(string[] args) { B obj = new B(); obj.i = 1; obj.j = 2; obj.display(); Console.ReadLine(); } }”. This question is standard in competitive examination syllabi for Classes And Objects In C Sharp.
💡Key Conceptual Anchor:Classes And Objects In C Sharp
Question 8 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the given modifiers can be used to prevent Method overriding?
Correct Answer: Option C — Sealed
Detailed Academic Explanation:
Sealed is the correct answer to “Which of the given modifiers can be used to prevent Method overriding”. This question is standard in competitive examination syllabi for Classes And Objects In C Sharp.
💡Key Conceptual Anchor:Classes And Objects In C Sharp
Question 9 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following keyword is used to change data and behavior of a base class by replacing a member of the base class with a new derived member?
Correct Answer: Option C — new
Detailed Academic Explanation:
new is the correct answer to “Which of the following keyword is used to change data and behavior of a base class by replacing a member of the base class with a new derived member”. This question is standard in competitive examination syllabi for Classes And Objects In C Sharp.
💡Key Conceptual Anchor:Classes And Objects In C Sharp
Question 10 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Choose the wrong statement about 'INTERFACE' in C#.NET?
Correct Answer: Option C — An interface could not contain signature of the indexer
Detailed Academic Explanation:
An interface could not contain signature of the indexer is the correct answer to “Choose the wrong statement about 'INTERFACE' in C#.NET”. This question is standard in competitive examination syllabi for Classes And Objects In C Sharp.
💡Key Conceptual Anchor:Classes And Objects In C Sharp
Question 11 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Selecting appropriate method out of number of overloaded methods by matching arguments in terms of number, type and order and binding that selected method to object at compile time is called?
Correct Answer: Option D — All of the mentioned
Detailed Academic Explanation:
All of the mentioned is the correct answer to “Selecting appropriate method out of number of overloaded methods by matching arguments in terms of number, type and order and binding that selected method to object at compile time is called”. This question is standard in competitive examination syllabi for Classes And Objects In C Sharp.
💡Key Conceptual Anchor:Classes And Objects In C Sharp
Question 12 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
If no access modifier for a class is specified, then class accessibility is defined as?
Correct Answer: Option C — private
Detailed Academic Explanation:
private is the correct answer to “If no access modifier for a class is specified, then class accessibility is defined as”. This question is standard in competitive examination syllabi for Classes And Objects In C Sharp.
💡Key Conceptual Anchor:Classes And Objects In C Sharp
Question 13 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C# code? static void Main(string[] args) { int a = 5; int s = 0, c = 0; Mul (a, ref s, ref c); Console.WriteLine(s + "t " +c); Console.ReadLine(); } static void Mul (int x, ref int ss, ref int cc) { ss = x * x; cc = x * x * x; }
Correct Answer: Option B — 25 125
Detailed Academic Explanation:
25 125 is the correct answer to “What will be the output of the following C# code? static void Main(string[] args) { int a = 5; int s = 0, c = 0; Mul (a, ref s, ref c); Console.WriteLine(s + "t " +c); Console.ReadLine(); } static void Mul (int x, ref int ss, ref int cc) { ss = x * x; cc = x * x * x; }”. This question is standard in competitive examination syllabi for Classes And Objects In C Sharp.
💡Key Conceptual Anchor:Classes And Objects In C Sharp
Question 14 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Number of constructors a class can define is?
Correct Answer: Option C — Any number
Detailed Academic Explanation:
Any number is the correct answer to “Number of constructors a class can define is”. This question is standard in competitive examination syllabi for Classes And Objects In C Sharp.
💡Key Conceptual Anchor:Classes And Objects In C Sharp
Question 15 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Correct way to overload +operator?
Correct Answer: Option D — all of the mentioned
Detailed Academic Explanation:
all of the mentioned is the correct answer to “Correct way to overload +operator”. This question is standard in competitive examination syllabi for Classes And Objects In C Sharp.
💡Key Conceptual Anchor:Classes And Objects In C Sharp
Question 16 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The data members of a class by default are?
Correct Answer: Option C — private
Detailed Academic Explanation:
private is the correct answer to “The data members of a class by default are”. This question is standard in competitive examination syllabi for Classes And Objects In C Sharp.
💡Key Conceptual Anchor:Classes And Objects In C Sharp
Question 17 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C# code? static void Main(string[] args) { int i = 10; double d = 35.78; fun(i); fun(d); Console.ReadLine(); } static void fun(double d) { Console.WriteLine(d); }
Correct Answer: Option C — 10 35.78
Detailed Academic Explanation:
10 35.78 is the correct answer to “What will be the output of the following C# code? static void Main(string[] args) { int i = 10; double d = 35.78; fun(i); fun(d); Console.ReadLine(); } static void fun(double d) { Console.WriteLine(d); }”. This question is standard in competitive examination syllabi for Classes And Objects In C Sharp.
💡Key Conceptual Anchor:Classes And Objects In C Sharp
Question 18 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
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); } } }
Correct Answer: Option C — a b
Detailed Academic Explanation:
a b is the correct answer to “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); } } }”. This question is standard in competitive examination syllabi for Classes And Objects In C Sharp.
💡Key Conceptual Anchor:Classes And Objects In C Sharp
Question 19 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The process of defining a method in a subclass having same name & type signature as a method in its superclass is known as?
Correct Answer: Option B — Method overriding
Detailed Academic Explanation:
Method overriding is the correct answer to “The process of defining a method in a subclass having same name & type signature as a method in its superclass is known as”. This question is standard in competitive examination syllabi for Classes And Objects In C Sharp.
💡Key Conceptual Anchor:Classes And Objects In C Sharp
Question 20 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Wrong statement about enum used in C#.NET is?
Correct Answer: Option D — An enum can have Single and Double values
Detailed Academic Explanation:
An enum can have Single and Double values is the correct answer to “Wrong statement about enum used in C#.NET is”. This question is standard in competitive examination syllabi for Classes And Objects In C Sharp.
💡Key Conceptual Anchor:Classes And Objects In C Sharp
Question 21 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the return type of destructor?
Correct Answer: Option D — none of the mentioned
Detailed Academic Explanation:
none of the mentioned is the correct answer to “What is the return type of destructor”. This question is standard in competitive examination syllabi for Classes And Objects In C Sharp.
💡Key Conceptual Anchor:Classes And Objects In C Sharp
Question 22 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C# code? class A { public int i; protected int j; } class B : A { public int j; public void display() { base.j = 3; Console.WriteLine(i + " " + j); } } class Program { static void Main(string[] args) { B obj = new B(); obj.i = 1; obj.j = 2; obj.display(); Console.ReadLine(); } }
Correct Answer: Option D — 1 2
Detailed Academic Explanation:
1 2 is the correct answer to “What will be the output of the following C# code? class A { public int i; protected int j; } class B : A { public int j; public void display() { base.j = 3; Console.WriteLine(i + " " + j); } } class Program { static void Main(string[] args) { B obj = new B(); obj.i = 1; obj.j = 2; obj.display(); Console.ReadLine(); } }”. This question is standard in competitive examination syllabi for Classes And Objects In C Sharp.
💡Key Conceptual Anchor:Classes And Objects In C Sharp
Question 23 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Access specifiers which can be used for an interface are?
Correct Answer: Option A — Public
Detailed Academic Explanation:
Public is the correct answer to “Access specifiers which can be used for an interface are”. This question is standard in competitive examination syllabi for Classes And Objects In C Sharp.
💡Key Conceptual Anchor:Classes And Objects In C Sharp
Question 24 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
A class consists of two interfaces with each interface consisting of three methods. The class had no instance data. Which of the following indicates the correct size of object created from this class?
Correct Answer: Option D — 24 bytes
Detailed Academic Explanation:
24 bytes is the correct answer to “A class consists of two interfaces with each interface consisting of three methods. The class had no instance data. Which of the following indicates the correct size of object created from this class”. This question is standard in competitive examination syllabi for Classes And Objects In C Sharp.
💡Key Conceptual Anchor:Classes And Objects In C Sharp
Question 25 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Choose the correct statements among the following:
Correct Answer: Option D — All of the mentioned
Detailed Academic Explanation:
All of the mentioned is the correct answer to “Choose the correct statements among the following:”. This question is standard in competitive examination syllabi for Classes And Objects In C Sharp.
💡Key Conceptual Anchor:Classes And Objects In C Sharp
Question 26 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C# code? class overload { public int x; int y; public int add(int a) { x = a + 1; return x; } public int add(int a, int b) { x = a + 2; return x; } } class Program { static void Main(string[] args) { overload obj = new overload(); overload obj1 = new overload(); int a = 0; obj.add(6); obj1.add(6, 2); Console.WriteLine(obj.x); Console.WriteLine(obj1.x); Console.ReadLine(); } }
Correct Answer: Option D — 7 8
Detailed Academic Explanation:
7 8 is the correct answer to “What will be the output of the following C# code? class overload { public int x; int y; public int add(int a) { x = a + 1; return x; } public int add(int a, int b) { x = a + 2; return x; } } class Program { static void Main(string[] args) { overload obj = new overload(); overload obj1 = new overload(); int a = 0; obj.add(6); obj1.add(6, 2); Console.WriteLine(obj.x); Console.WriteLine(obj1.x); Console.ReadLine(); } }”. This question is standard in competitive examination syllabi for Classes And Objects In C Sharp.
💡Key Conceptual Anchor:Classes And Objects In C Sharp
Question 27 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which reference modifier is used to define reference variable?
Correct Answer: Option B — ref
Detailed Academic Explanation:
ref is the correct answer to “Which reference modifier is used to define reference variable”. This question is standard in competitive examination syllabi for Classes And Objects In C Sharp.
💡Key Conceptual Anchor:Classes And Objects In C Sharp
Question 28 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C# code? class maths { int i; public maths(int x) { i = x; Console.WriteLine(" hello: "); } } class maths1 : maths { public maths1(int x) :base(x) { Console.WriteLine("bye"); } } class Program { static void Main(string[] args) { maths1 k = new maths1(12); Console.ReadLine(); } }
Correct Answer: Option A — hello bye
Detailed Academic Explanation:
hello bye is the correct answer to “What will be the output of the following C# code? class maths { int i; public maths(int x) { i = x; Console.WriteLine(" hello: "); } } class maths1 : maths { public maths1(int x) :base(x) { Console.WriteLine("bye"); } } class Program { static void Main(string[] args) { maths1 k = new maths1(12); Console.ReadLine(); } }”. This question is standard in competitive examination syllabi for Classes And Objects In C Sharp.
💡Key Conceptual Anchor:Classes And Objects In C Sharp
Question 29 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
"A mechanism that binds together code and data in manipulates, and keeps both safe from outside interference and misuse. In short it isolates a particular code and data from all other codes and data. A well-defined interface controls access to that particular code and data."
Correct Answer: Option D — Encapsulation
Detailed Academic Explanation:
Encapsulation is the correct answer to “"A mechanism that binds together code and data in manipulates, and keeps both safe from outside interference and misuse. In short it isolates a particular code and data from all other codes and data. A well-defined interface controls access to that particular code and data."”. This question is standard in competitive examination syllabi for Classes And Objects In C Sharp.
💡Key Conceptual Anchor:Classes And Objects In C Sharp
Question 30 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
To override a method in the subclass, the base class method should be defined as?
Correct Answer: Option D — All of the mentioned
Detailed Academic Explanation:
All of the mentioned is the correct answer to “To override a method in the subclass, the base class method should be defined as”. This question is standard in competitive examination syllabi for Classes And Objects In C Sharp.
💡Key Conceptual Anchor:Classes And Objects In C Sharp
Question 31 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Calculate the number of bytes a structure variable s occupies in the memory if it is defined as follows. class abc { int i; Decimal d; } struct sample { private int x; private Single y; private trial z; } sample s = new sample();
Correct Answer: Option D — 12 bytes
Detailed Academic Explanation:
12 bytes is the correct answer to “Calculate the number of bytes a structure variable s occupies in the memory if it is defined as follows. class abc { int i; Decimal d; } struct sample { private int x; private Single y; private trial z; } sample s = new sample();”. This question is standard in competitive examination syllabi for Classes And Objects In C Sharp.
💡Key Conceptual Anchor:Classes And Objects In C Sharp
Question 32 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is Recursion in CSharp defined as?
Correct Answer: Option C — Recursion is a process of defining a method that calls itself repeatedly
Detailed Academic Explanation:
Recursion is a process of defining a method that calls itself repeatedly is the correct answer to “What is Recursion in CSharp defined as”. This question is standard in competitive examination syllabi for Classes And Objects In C Sharp.
💡Key Conceptual Anchor:Classes And Objects In C Sharp
Question 33 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C# code? class maths { int i; public maths(int ii) { ii = 12; int j = 12; int r = ii * j; Console.WriteLine(r); } } class maths1 : maths { public maths1(int u) :base(u) { u = 13; int h = 13; Console.WriteLine(u + h); } } class maths2 : maths1 { public maths2(int k) :base(k) { k = 24; int o = 6 ; Console.WriteLine(k /o); } } class Program { static void Main(string[] args) { maths2 t = new maths2(10); Console.ReadLine(); } }
Correct Answer: Option C — 144, 26, 4
Detailed Academic Explanation:
144, 26, 4 is the correct answer to “What will be the output of the following C# code? class maths { int i; public maths(int ii) { ii = 12; int j = 12; int r = ii * j; Console.WriteLine(r); } } class maths1 : maths { public maths1(int u) :base(u) { u = 13; int h = 13; Console.WriteLine(u + h); } } class maths2 : maths1 { public maths2(int k) :base(k) { k = 24; int o = 6 ; Console.WriteLine(k /o); } } class Program { static void Main(string[] args) { maths2 t = new maths2(10); Console.ReadLine(); } }”. This question is standard in competitive examination syllabi for Classes And Objects In C Sharp.
💡Key Conceptual Anchor:Classes And Objects In C Sharp
Question 34 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which keyword is used to refer baseclass constructor to subclass constructor?
Correct Answer: Option C — Base
Detailed Academic Explanation:
Base is the correct answer to “Which keyword is used to refer baseclass constructor to subclass constructor”. This question is standard in competitive examination syllabi for Classes And Objects In C Sharp.
💡Key Conceptual Anchor:Classes And Objects In C Sharp
Question 35 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C# code? class test { public void print() { Console.WriteLine("Csharp:"); } } class Program { static void Main(string[] args) { test t; t.print(); Console.ReadLine(); } }
Correct Answer: Option C — Syntax error as t is unassigned variable which is never used
Detailed Academic Explanation:
Syntax error as t is unassigned variable which is never used is the correct answer to “What will be the output of the following C# code? class test { public void print() { Console.WriteLine("Csharp:"); } } class Program { static void Main(string[] args) { test t; t.print(); Console.ReadLine(); } }”. This question is standard in competitive examination syllabi for Classes And Objects In C Sharp.
💡Key Conceptual Anchor:Classes And Objects In C Sharp
Question 36 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which return statement correctly returns the output?
Correct Answer: Option A — public int cube(int x) { return (x + x); }
Detailed Academic Explanation:
public int cube(int x) { return (x + x); } is the correct answer to “Which return statement correctly returns the output”. This question is standard in competitive examination syllabi for Classes And Objects In C Sharp.
💡Key Conceptual Anchor:Classes And Objects In C Sharp
Question 37 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which statements among following are correct?
Correct Answer: Option D — All of the mentioned
Detailed Academic Explanation:
All of the mentioned is the correct answer to “Which statements among following are correct”. This question is standard in competitive examination syllabi for Classes And Objects In C Sharp.
💡Key Conceptual Anchor:Classes And Objects In C Sharp
Question 38 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these can be used to fully abstract a class from its implementation?
Correct Answer: Option C — Interfaces
Detailed Academic Explanation:
Interfaces is the correct answer to “Which of these can be used to fully abstract a class from its implementation”. This question is standard in competitive examination syllabi for Classes And Objects In C Sharp.
💡Key Conceptual Anchor:Classes And Objects In C Sharp
Question 39 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Select the class visibility modifiers among the following:
Private, protected, public, internal, protected internal is the correct answer to “Select the class visibility modifiers among the following:”. This question is standard in competitive examination syllabi for Classes And Objects In C Sharp.
💡Key Conceptual Anchor:Classes And Objects In C Sharp
Question 40 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C# code? namespace ConsoleApplication4 { abstract class A { int i; public abstract void display(); } class B: A { public int j; public override void display() { Console.WriteLine(j); } } class Program { static void Main(string[] args) { B obj = new B(); obj.j = 2; obj.display(); Console.ReadLine(); } } }
Correct Answer: Option B — 2
Detailed Academic Explanation:
2 is the correct answer to “What will be the output of the following C# code? namespace ConsoleApplication4 { abstract class A { int i; public abstract void display(); } class B: A { public int j; public override void display() { Console.WriteLine(j); } } class Program { static void Main(string[] args) { B obj = new B(); obj.j = 2; obj.display(); Console.ReadLine(); } } }”. This question is standard in competitive examination syllabi for Classes And Objects In C Sharp.
💡Key Conceptual Anchor:Classes And Objects In C Sharp
✓Link copied to clipboard
Continue Your Practice
Advance Html — Part 1
Master the next curriculum module with 40 exam-standard MCQs.
💡Examiner's Advisory for Programming & Software Development
In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.