About me

Wednesday, September 30, 2015

Best C# Language Interview Questions and Answers

31. What are methods?

   Methods are the building blocks of a class, in which they are associated together to share and process data to generate  the result. In other words, a method is a block of code that contains a series of assertions and illustrates the behavior of a class. While declaring a method you need to specify the access specifier, the return value, the name of the method, and the method parameters. All these associated together is called the signature of the method.

32. What is a namespace?

  Namespace is deliberated as a container that contains functionally related group of classes and other types.

33. Do events have return type?

   No, events do not have return type.

34. What is the function of the Try-Catch-Finally block?

   The try block encompasses those statements that can cause exception and the catch block handles the exception, if it occurs. Catch block contains the statements that have to be executed, when an exception occurs. The finally block always executes, irrespective of the fact whether or not an exception has occurred. The finally block is generally used to perform the cleanup process. If any exception occurs in the try block, the program control directly transfers to its corresponding catch block and later to the finally block. If no exception occurs inside the try block, then the program control transfers directly to the finally block.




35. How can you prevent a class from overriding in C# and Visual Basic?

  You can restrain a class from overriding in C# by using the sealed keyword; whereas, the NotInheritablekeyword is used to prevent a class from overriding in Visual Basic.



No comments:

Post a Comment