Sie sind auf Seite 1von 2

C# ques and ans

Title: Recent C# Interview Questions & Answers

Q : What is the C# syntax to catch any possible exception?


A : A catch block is that the catches the exception of type System .Exception.
You can also omit the parameter data type in this case and just write catch {}.

Q :What is the difference between System.String and


System.Text.StringBuilder classes?
A : System.String is a immutable. System.StringBuilder was designed with
the purpose of having a mutable the string where as a variety of operations
can be performed.

Q : What’s the syntax to inherit from a class in C#?


A: A Place is a colon and then the name of the base class.
Example: class MyNewClass : MyBaseClass

Q : When do you correctly have to declare a class as abstract?


A : When the class itself is the inherited from an abstract class, but not all
base abstract methods have been overridden.
When at least one of the methods in the class is abstract class.

Q : What’s the difference between a Struct and a Class?


A : Structs are the value-type variables and are thus saved on the stack,
additional overhead but faster retrieval. Another difference is struct can not
inherit.

Q :What are the different ways of method can be overloaded?


A: There are three types of ways can be overloaded,
Different parameter data types,
Different number of parameters,
Different order of parameters.

Q : Which is the following is used to denote comments in C#?


A : All are correct, all are supported forms of commenting. It is just that /// is
specifically for functionality in XML documentation.

Q : What is true about readonly variable in C# code?


A : B is the right choice. Since readonly field can only be initialized at the
time of
construction of the object. Read only means if you want to initialize the
readonly property that intialize it inside the constructor.

Q : What’s an interface class?


A : It is an abstract class with the public abstract methods all of which is
must be implemented in the inherited classes.

Q : What is a delegate?
A : A delegate is a object encapsulates a reference to a method. In C++ they
were referred to as function pointers.

Q : What is a multicast delegate?


A Multicast delegate is that points to and eventually fires off several
methods.

Q : What is the difference between the Trace class and Debug class?
A :Documentation looks the same. Use Debug class for debug builds, use the
Trace class for both debug and release builds.

Q : What is Inheritance?
A :Inheritance is a process of acquiring attributes and behaviors from the
another object (normally a class or interface). Gives you ability to provide is-a
relationship. Acquires attributes and behaviors from another. When a class
acquires attributes and behaviors from another class.

Q : What is a Destructor?
A : A destructor is a deallocating the memory.

Q : How a base class method is hidden?


A : Hiding a base class method by declaring a method in the derived class
with keyword new. This will override the base class method and old method
will be suppressed.

This question has been viewed 1498 times so far.

Das könnte Ihnen auch gefallen