• +91 9971497814
  • info@interviewmaterial.com

CSharp Interview Questions Answers

Question 1 : How can you sort the elements of the array in descending order?

Answer 1 : By calling Sort() and then Reverse() methods

Question 2 : How do you inherit from a class in C#?

Answer 2 : Place a colon and then the name of the base class. Notice that it’s double colon in C++.

Question 3 : Can multiple catch blocks be executed?

Answer 3 :   No, once the proper catch code fires off, the control is transferred to the finally block (if there are any), and then whatever follows the finally block.

Question 4 : Can you inherit multiple interfaces?

Answer 4 : yes

Question 5 : Can you allow class to be inherited, but prevent the method from being over-ridden?

Answer 5 : Yes, just leave the class public and make the method sealed.

Question 6 : Are private class-level variables inherited?

Answer 6 : Yes,but they are not accessible, so looking at it you can honestly say that they are not inherited. But they are.

Question 7 : Can you create enumerated data types in C#?

Answer 7 : Yes.

Question 8 :   What is hiding in CSharp ?

Answer 8 :   Hiding is also called as Shadowing. This is the concept of Overriding the methods. It is a concept used in the Object Oriented Programming. E.g.  public class ClassA {  public virtual void MethodA() {   Trace.WriteLine("ClassA Method");  } } public class ClassB : ClassA {  public new void MethodA() {   Trace.WriteLine("SubClass ClassB Method");  } } public class TopLevel {  static void Main(string[] args) {   TextWriter tw = Console.Out;   Trace.Listeners.Add(new TextWriterTraceListener(tw));     ClassA obj = new ClassB();   obj.MethodA(); // Outputs “Class A Method"     ClassB obj1 = new ClassB();   obj.MethodA(); // Outputs “SubClass ClassB Method”  } }

Question 9 :  Can you store multiple data types in System.Array?

Answer 9 : No

Question 10 : Describe the accessibility modifier protected internal.

Answer 10 : It’s available to derived classes and classes within the same Assembly (and naturally from the base class it’s declared in).

CSharp Contributors

Rajeev Katiyar

Share your email for latest updates

Name:
Email:

Our partners