Documente Academic
Documente Profesional
Documente Cultură
🏠 Python ▾ Selenium QA Agile Angular SQL MySQL Java Linux C C# Web PHP Android
25 C# OOPs Interview Questions Every Programmer Should Read Example: Python sockets
C# Interview | By Meenakshi Agarwal
This post is for programmers gearing for their first C# OOPs interview. C# is the most popular
object-oriented programming language used by millions of developers. So every interviewer rates your
C# programming skills based on how well-versed you are in OOPs concepts.
Hence, we picked 25 key OOPs questions for C# programmers. It is a quick way to brush up
programming skills and knowledge of C# OOPs concepts. We’ve clubbed both the theoretical and
coding questions together so that you can focus on coding as well as theory.
If you also like to explore additional C# topics for interview prep, then do visit the C# interview
section to check hundreds of programming questions and answers.
However, before you proceed, please have a look at the below questions/areas that you must also
prepare for securing a C# programming job.
So we leave you here to ponder the answers and drill the areas mentioned above.
Now, it’s time that you put your C# programming skills to test as the 25 C# questions are waiting for
you next.
Q-1. Which of the following represents the process of defining two or more methods within the
same class having the same name but different parameters list?
a) Method overloading
b) Method overriding
▲
c) Encapsulation
d) None of the mentioned
https://www.techbeamers.com/csharp-oops-interview-questions-set-3/ 1/13
9/19/2019 25 C# OOPs Interview Questions and Answers for Programmers
a)
c)
using System;
class Program
{
static void Main(string[] args)
{
int i = 5;
int j = 6;
calc(ref i);
calc(6);
Console.WriteLine(i);
Console.ReadLine();
}
static void calc(ref int x)
{
x = x * x;
}
static void calc(int x)
{
Console.WriteLine(x * x * x);
}
}
d)
a)
a)
Q-6. Which of the following keywords can be used to overload user-defined types by defining
static member functions?
a) op
b) opoverload
c) operator
d) operatoroverload
e) udoperator
c)
Q-8. Which of the following modifier applies when a virtual method is redefined by a derived
class?
a) overloads
b) override
c) overridable
d) virtual
e) base
b)
https://www.techbeamers.com/csharp-oops-interview-questions-set-3/ 3/13
9/19/2019 25 C# OOPs Interview Questions and Answers for Programmers
Q-9. Which of the following keyword should be prefixed to a member of the base class to allow
overriding in the derived class?
a) overload
b) override
c) new
d) virtual
e) base
d)
Q-10. Which of the following members of the class allow declaring them as virtual?
a) Methods
b) Properties
c) Events
d) Fields
e) Static fields
a) b) c)
using System;
class sample
{
public int x;
public double y;
public int sum(int a, int b)
{
x = a + b;
return x;
}
public int sum(double c, double d)
{
y = c + d;
return (int)y;
}
public sample()
{
this.x = 0;
this.y = 0;
}
}
class Program
{
static void Main(string[] args)
{
sample s = new sample();
int a = 4;
double b = 3.5;
s.sum(a, a);
s.sum(b, b);
Console.WriteLine(s.x + " " + s.y);
Console.ReadLine();
}
}
a) 4, 3.5
b) 8, 0
c) 7.5, 8 ▲
d) 8, 7
https://www.techbeamers.com/csharp-oops-interview-questions-set-3/ 4/13
9/19/2019 25 C# OOPs Interview Questions and Answers for Programmers
d)
using System;
class sample
{
public static void func1()
{
Console.WriteLine("Printing func1");
}
public void func2()
{
func1();
Console.WriteLine("Printing func2");
}
public void func2(int k)
{
Console.WriteLine(k);
}
}
class Program
{
static void Main(string[] args)
{
sample s = new sample();
sample.func1();
s.func2(20);
Console.ReadLine();
}
}
a) Printing func1
20
b) Printing func1
Printing func2
20
c) Printing func1
20
Printing func2
d) Compile time error
a)
using System;
class sample
{
public int func(int k, int y)
{
return k + y;
}
public int func1(int t, float z)
{
return (t+(int)z);
}
}
class Program
▲
{
static void Main(string[] args)
https://www.techbeamers.com/csharp-oops-interview-questions-set-3/ 5/13
9/19/2019 25 C# OOPs Interview Questions and Answers for Programmers
static void Main(string[] args)
{
sample s = new sample();
int i;
int b = 90;
int c = 100;
int d = 12;
float m = 14.78f;
i = s.func(b, c);
Console.WriteLine(i);
int j = (s.func1(d, m));
Console.WriteLine(j);
Console.ReadLine();
}
}
a) 190, 26.78f
b) 0, 26.78f
c) 190, 26
d) 190, 0
c)
using System;
class sample
{
public int func(int num1)
{
return(num1 > 0 ? num1 :num1 * -1);
}
public long func(long num2)
{
return(num2 > 0 ? num2 :num2 * -1);
}
public double func( double num3)
{
return(num3 > 0 ? num3 :num3 * -1);
}
}
class Program
{
static void Main(string[] args)
{
sample s = new sample();
int i = -25;
int j ;
long l = -100000l ;
long m;
double d = -12.34;
double e;
j = s.func(i);
m = s.func(l);
e = s.func(d);
Console.WriteLine(j + " " + m + " " + e);
Console.ReadLine();
}
}
a) 1 1 1
b) 0 0 0
c) 25 100000 12.34
d) -25 -100000 -12.34
c)
https://www.techbeamers.com/csharp-oops-interview-questions-set-3/ 6/13
9/19/2019 25 C# OOPs Interview Questions and Answers for Programmers
)
Q-15. Which of the following represents the process where a method in a subclass has same
name & type signature as a method in its superclass?
a) Method overloading
b) Method overriding
c) Method hiding
d) None of the mentioned
b)
Q-16. Which of the following modifiers can be used to prevent Method overriding?
a) Static
b) Constant
c) Sealed
d) final
c)
using System;
class BaseClass
{
public int i;
public void Print()
{
Console.WriteLine(i);
}
}
class DeriverdClass: BaseClass
{
public int j;
public void Print()
{
Console.WriteLine(j);
}
}
class Program
{
static void Main(string[] args)
{
DeriverdClass d = new DeriverdClass();
d.i = 1;
d.j = 2;
d.Print();
Console.ReadLine();
}
}
a) 0
b) 2
c) 1
d) Compile time error
b)
https://www.techbeamers.com/csharp-oops-interview-questions-set-3/ 7/13
9/19/2019 25 C# OOPs Interview Questions and Answers for Programmers
b)
a) b) d)
using System;
class BaseClass
{
public void Print()
{
System.Console.WriteLine("BaseClass");
}
}
class Program
{
public static void Main()
{
BaseClass b;
b = new BaseClass();
b.Print();
b = new DerivedClass();
b.Print();
}
}
c)
▲
using System;
class BaseClass
{
https://www.techbeamers.com/csharp-oops-interview-questions-set-3/ 8/13
9/19/2019 25 C# OOPs Interview Questions and Answers for Programmers
{
public virtual void Print()
{
System.Console.WriteLine("BaseClass");
}
}
class Program
{
public static void Main()
{
BaseClass b;
b = new BaseClass();
b.Print();
b = new DerivedClass();
b.Print();
}
}
b)
using System;
class BaseClass
{
public virtual void Print()
{
System.Console.WriteLine("BaseClass");
}
}
class Program
{
public static void Main()
{
BaseClass b; ▲
b = new Derived2Class();
b.Print();
}
https://www.techbeamers.com/csharp-oops-interview-questions-set-3/ 9/13
9/19/2019 25 C# OOPs Interview Questions and Answers for Programmers
}
}
d)
using System;
class BaseClass
{
public virtual void Print()
{
System.Console.WriteLine("BaseClass");
}
}
class Program
{
public static void Main()
{
BaseClass b;
b = new Derived2Class();
b.Print();
}
}
d)
using System;
class BaseClass
{ ▲
public virtual void Print()
{
https://www.techbeamers.com/csharp-oops-interview-questions-set-3/ 10/13
9/19/2019 25 C# OOPs Interview Questions and Answers for Programmers
System.Console.WriteLine("BaseClass");
}
}
class Program
{
public static void Main()
{
BaseClass b;
b = new DerivedClass();
b.Print();
d)
Q-24. Which of the following are correct for methods of a class that becomes applicable to
method overloading?
a) Type of arguments may differ
b) Return type of methods need not be same
c) Number of arguments may vary
d) Names of methods to be different
e) Variation in the order of arguments.
a) c) e)
using System;
abstract class BaseClass
{
public abstract string Print(); ▲
}
https://www.techbeamers.com/csharp-oops-interview-questions-set-3/ 11/13
9/19/2019 25 C# OOPs Interview Questions and Answers for Programmers
class Program
{
static void Main(string[] args)
{
DerivedClass d = new DerivedClass();
string text = d.Print();
Console.WriteLine(text);
Console.Read();
}
}
c)
If you like to share any feedback or your experience, then use the comment box to reach to us.
Keep Learning,
TechBeamers
RELATED
15 C# Interview Questions 20 C# Programming Questions
Every Programmer Should On Object Oriented Concepts
Know
☛ About Us
https://www.techbeamers.com/csharp-oops-interview-questions-set-3/ 12/13
9/19/2019 25 C# OOPs Interview Questions and Answers for Programmers
Python Tutorial Python Interview Questions AngularJS Questions ☛ Privacy Policy
☛ Disclaimer
Selenium Python Tutorial SQL Interview Questions JavaScript Questions
☛ Contact Us
Selenium Webdriver Tutorial Selenium Interview Questions Web Developer Questions
Python Tips & Tricks Linux Interview Questions PHP Interview Questions-2
© 2019 TechBeamers.com
https://www.techbeamers.com/csharp-oops-interview-questions-set-3/ 13/13