C# इंटरव्यू प्रश्न और उत्तर (Top 20 Questions in Hindi)
1. C# क्या है?
C# एक object-oriented programming भाषा है जिसे Microsoft द्वारा .NET Framework के लिए विकसित किया गया है। यह Java जैसी high-level language है।
2. Value Type और Reference Type में क्या अंतर है?
Value Type | Reference Type |
---|---|
Stack में स्टोर होते हैं | Heap में स्टोर होते हैं |
Direct data contain करते हैं | Reference contain करते हैं |
int, float, bool | class, array, string |
3. Boxing और Unboxing क्या है?
Boxing: जब Value type को Object type में बदला जाता है।
Unboxing: जब Object को वापस Value type में बदला जाता है।
int x = 10;
object obj = x; // Boxing
Unboxing: जब Object को वापस Value type में बदला जाता है।
int y = (int)obj; // Unboxing
4. Constructor क्या होता है?
Constructor एक special method होता है जो object create करते समय अपने आप call होता है। इसमें कोई return type नहीं होती।
class Demo {
public Demo() {
Console.WriteLine("Constructor Called");
}
}
5. Destructor क्या होता है?
Destructor एक special method होता है जो object destroy होने पर call होता है। यह resources को clean करने के लिए use होता है।
~Demo() {
// cleanup code
}
6. Static और Non-Static में क्या अंतर है?
Static members class level पर होते हैं और object बनाने की जरूरत नहीं होती। Non-static members object-specific होते हैं।
7. Interface और Abstract Class में क्या अंतर है?
Interface | Abstract Class |
---|---|
सभी methods abstract होते हैं। | Concrete और abstract दोनों methods हो सकते हैं। |
Multiple inheritance को support करता है। | Single inheritance only। |
8. Method Overloading और Overriding क्या है?
- Overloading: एक ही नाम के methods जो अलग parameters के साथ हों।
- Overriding: Base class के virtual/abstract method को derived class में redefine करना।
- Overriding: Base class के virtual/abstract method को derived class में redefine करना।
9. Properties क्या होती हैं?
Properties fields को access करने के लिए wrapper होती हैं। इसमें get और set accessors होते हैं।
public int Age {
get { return age; }
set { age = value; }
}
10. Delegate क्या है?
Delegate एक type-safe function pointer है जो methods को dynamically call करने में use होता है।
delegate void MyDelegate(string msg);
11. Event क्या है?
Event delegate के ऊपर आधारित होता है जो किसी action के response में trigger होता है।
12. Exception Handling क्या होती है?
Exception handling errors को handle करने की process है। इसमें try-catch-finally blocks use होते हैं।
13. Sealed Class क्या है?
Sealed class को inherit नहीं किया जा सकता।
sealed class MyClass { }
14. Namespace क्या होता है?
Namespace logically classes और methods को group करने का तरीका है।
15. Indexer क्या होता है?
Indexer एक class को array की तरह access करने की सुविधा देता है।
public int this[int index] {
get { return arr[index]; }
set { arr[index] = value; }
}
16. Extension Method क्या है?
Existing class में नई methods add करने का तरीका है बिना उसे modify किए।
public static class MyExtension {
public static void Print(this string str) {
Console.WriteLine(str);
}
}
17. Async और Await क्या है?
Async/await asynchronous programming के लिए use होते हैं ताकि UI freeze न हो।
18. LINQ क्या है?
LINQ (Language Integrated Query) data query करने की syntax है जो SQL जैसी होती है लेकिन C# code में होती है।
var result = from s in students where s.Marks > 60 select s;
19. Nullable Type क्या होता है?
जब value type में null assign करना हो तो ? के साथ Nullable बनाया जाता है।
int? age = null;
20. Difference between == and Equals()?
-
-
==
operator reference या value comparison करता है (depends on override)।-
equals()
method value comparison के लिए use होती है।
0 Comments