*
Previous C# Question Answers-21 - 30 C# Question Answers-41 - 50 Next

C# (C-Sharp) Question Answers - 31-40

31. Explain Single Delegate?

A single delegate can be used to invoke one method.

32. Explain the use of virtual, sealed, override, and abstract.

  • virtual: Allows method/property to be overridden in derived class.
  • sealed: Prevents class from being inherited.
  • override: Provides new implementation of a base class member.
  • abstract: Abstract class cannot be instantiated. Abstract members must be overridden in derived classes.

33. Explain types of Constructors in C#?

There are 5 types of constructor in C#

  • Default Constructor
  • Parameterized Constructor
  • Copy Constructor
  • Static Constructor
  • Private Constructor

34. Explain types of Delegates?

There are three types of delegates in C#.

  • Single Delegate
  • Multicast Delegate
  • Generic Delegate

35. Explain what’s happening in the first constructor?

public class c { 
  public c (string a) : this() {;}; 
  public c () {;} 
} 

The first constructor calls the base constructor.

36. How can you overload a method?

By using:

  • Different parameter data types
  • Different number of parameters
  • Different order of parameters

37. How can you sort the elements of the array in descending order?

Call Sort() and then Reverse() methods.

38. How do you generate documentation from the C# file commented properly with a command-line compiler?

Compile it with the /doc switch.

39. How does the generational garbage collector in the .NET CLR manage object lifetime?

The garbage collector uses three generations:

  • Gen 0: Newly created objects. Collected frequently. Survivors promoted to Gen 1.
  • Gen 1: Contains longer-lived objects from Gen 0. Collected less often.
  • Gen 2: Longest-lived objects (promoted from Gen 1). Collected least often.

40. How many processes can listen on a single TCP/IP port?

Single

Back to Index
Previous C# Question Answers-21 - 30 C# Question Answers-41 - 50 Next
*
*