Here are Tricky OOPS Interview Questions that are commonly asked and used to differentiate experienced developers 👇
1. Can we achieve Encapsulation without properties? 🤔
Answer: Yes.
Encapsulation is about restricting access, not about properties specifically.
public class Test
{
private int x;
public void SetX(int value)
{
x = value;
}
public int GetX()
{
return x;
}
}
Properties are just syntactic sugar.
2. Can a class be abstract and sealed at the same time? ❌
Answer: No.
-
abstract→ must be inherited -
sealed→ cannot be inherited
They contradict each other.
3. Difference between Method Overloading vs Overriding (Tricky version)
| Overloading | Overriding |
|---|---|
| Same class | Base + Child |
| No inheritance required | Requires inheritance |
| Compile-time | Runtime |
| Can change return type? ❌ | Same return type (mostly) |
4. Can we override a private method? ❌
Answer: No.
Because private methods are not visible in child class.
class A
{
private void Test() { }
}
class B : A
{
// cannot override
}
5. Can constructor be virtual? ❌
Answer: No.
Constructors cannot be inherited, so no polymorphism.
6. Can we override static method? ❌
Answer: No.
Static methods belong to class, not object.
But we can hide using new
class A
{
public static void Test()
{
Console.WriteLine("A");
}
}
class B : A
{
public new static void Test()
{
Console.WriteLine("B");
}
}
This is method hiding, not overriding.
7. What is difference between abstract class and interface (Tricky)
| Abstract Class | Interface |
|---|---|
| Can have constructor | Cannot |
| Can have fields | Cannot (traditionally) |
| Multiple inheritance ❌ | Multiple inheritance ✅ |
| Access modifiers allowed | Public by default |
8. Can interface contain method implementation?
Answer: Yes (C# 8+)
public interface ITest
{
void Method1()
{
Console.WriteLine("Default implementation");
}
}
This is a very tricky modern question.
9. What happens here? (Polymorphism trap)
class A
{
public virtual void Show()
{
Console.WriteLine("A");
}
}
class B : A
{
public override void Show()
{
Console.WriteLine("B");
}
}
A obj = new B();
obj.Show();
Answer: B
Because runtime decides → Runtime polymorphism
10. What happens if method is not virtual?
class A
{
public void Show()
{
Console.WriteLine("A");
}
}
class B : A
{
public void Show()
{
Console.WriteLine("B");
}
}
A obj = new B();
obj.Show();
Answer: A ❗
Because no polymorphism → method hiding
This question is very frequently asked.
11. Can we create object of abstract class? ❌
Answer: No.
But we can use reference:
Animal animal = new Dog();
12. Which OOPS concept is used here?
public void Print(object obj)
Answer: Polymorphism
Because object accepts any type
13. What is diamond problem? 💎
Multiple inheritance conflict:
A
/ \
B C
\ /
D
Interfaces solve this problem.
14. Is inheritance always good? ❌
Answer: No.
Prefer:
Composition over inheritance
This is senior-level answer.
15. What is method hiding vs overriding?
| Hiding | Overriding |
|---|---|
Uses new |
Uses override |
| Compile-time | Runtime |
| Not polymorphism | Polymorphism |
Most Important Tricky Questions (Top 5) ⭐
-
Can constructor be virtual?
-
Can we override static method?
-
Can interface have implementation?
-
Method hiding vs overriding?
-
What happens when base reference holds child object?
Best One-Line Interview Answer
OOPS tricky questions mainly test understanding of polymorphism, method overriding, method hiding, and abstraction behavior.
