Pages

Friday, 18 September 2015

C#.Net fresher Interview Questions and Answers pdf free download

141. What’s the C# syntax to catch any possible exception? 
A catch block that catches the exception of type System.Exception. You can also omit the parameter data type in this case and just write catch {}.

142. Can multiple catch blocks be executed for a single try statement? 
No. Once the proper catch block processed, control is transferred to the finally block (if there are any).

143. Explain the three services model commonly know as a three-tier application. 
Presentation (UI), Business (logic and underlying code) and Data (from storage or other sources).

144. What is the syntax to inherit from a class in C#?
Place a colon and then the name of the base class.
Example: class MyNewClass : MyBaseClass

145. Can you prevent your class from being inherited by another class? 
Yes. The keyword “sealed” will prevent the class from being inherited.

146. Can you allow a class to be inherited, but prevent the method from being over-ridden? 
Yes. Just leave the class public and make the method sealed.

147. When do you absolutely have to declare a class as abstract? 
1. When the class itself is inherited from an abstract class, but not all base abstract methods have been overridden.
2. When at least one of the methods in the class is abstract.

148. What’s the difference between an interface and abstract class? 
In an interface class, all methods are abstract - there is no implementation. In an abstract class some methods can be concrete. In an interface class, no accessibility modifiers are allowed. An abstract class may have accessibility modifiers.

149. What is the difference between a Struct and a Class? 
Struts are value-type variables and are thus saved on the stack, additional overhead but faster retrieval. Another difference is that struts cannot inherit.

150. Why are there five tracing levels in System.Diagnostics.TraceSwitcher?
The tracing dumps can be quite verbose. For applications that are constantly running you run the risk of overloading the machine and the hard drive. Five levels range from None to Verbose, allowing you to fine-tune the tracing activities.

151. Will the finally block get executed if an exception has not occurred?
Yes.

More Questions & Answers:-

No comments:

Post a Comment