Floating FB popout byF5debug

Interview Questions and Answers on .Net Framework, OOPS, ASP.Net, C#.Net, SQL Server, WCF Series – Part 11



Question 101 - What is a Parameterized constructor?

Constructor that accepts arguments is known as parameterized constructor. There may be situations, where it is necessary to initialize various data members of different objects with different values when they are created. Parameterized constructors help in doing that task.


Question 102 - What is a Singleton Class?

  • A singleton class is such kind of class in which only one object is created throughout the life time of the class.
  • A Singleton class is used when you wish to restrict instantiation of a class to only one object.


Question 103 - What is a Partial Class?

  • It is possible to split the definition of a class or a struct, or an interface over two or more source files
  • Each source file contains a section of class definition, and all parts are combined at compile time.
  • All the partial definitions must proceeded with the key word "Partial".
  • All the partial types must be defined within a same assembly and module.
  • Method signatures (return type, name of the method, and parameters) must be unique
  • The partial types must have the same accessibility.
  • If any part is sealed, then the entire class is sealed.
  • If any part is abstract, the entire class is abstract.
  • Inheritance at any partial type applies to the entire class.


Question 104 - What is a Partial Method?

  • A partial method is like a usual method in a class except that the user may or may not implement it.
  • A partial method gets executed only when it has an implementation.
  • Definition of a partial method is in one part of the partial class and implementation in another, but it is legal to have both in the same part of the partial class. Also you can use a partial method in a partial structure but not in partial interface.
  • Partial methods are indicated by the partial modifier.
  • Partial methods must be private.
  • Partial methods must return void.
  • Partial methods must only be declared within partial classes.
  • Partial methods do not always have an implementation. 
  • Partial methods can be static and generic.
  • Partial methods can have arguments including ref but not out. 
  • You cannot make a delegate to a partial method.


Question 105 - What is a Delegate?

  • Delegate in C# is similar to a function pointer in C or C++.
  • Delegate is type which  holds the method(s) reference in an object. It is also referred as a type safe function pointers.
  • Delegate allows the programmer to encapsulate a reference to a method inside a delegate object.
  • The delegate object can then be passed to code which can call the referenced method, without having to know at compile time which method will be invoked.
  • An interesting and useful property of a delegate is that it does not know or care about the class of the object that it references.


Question 106 - What is a Syntax of Single class delegate?

  • Syntax - delegate result-type identifier ([parameters]);
        • result-type: The result type, which matches the return type of the function.
        • identifier: The delegate name.
        • parameters: The Parameters, that the function takes.


Question 107 - What are the advantages of Delegates?

  • Encapsulating the method's call from caller.
  • Effective use of Delegate improves the performance of application.
  • Used to call a method asynchronously.
  • A delegate type maintains three important pieces of information :
        • The name of the method on which it make calls.
        • Any argument (if any) of this method.
        • The return value (if any) of this method.


Question 108 - What is a Multicast Delegate?

  • Delegate wraps a method. Calling delegate results in calling the method. It is possible to wrap more than one method in a delegate. This is known as a multicast delegate.
  • If you make a call to a multicast delegate it will call all the functions it wraps in the order specified. Please note that functions in this case should not return any values.


Question 109 - What is an Event?

  • An event in C# is a way for a class to provide notifications to clients of that class when some interesting thing happens to an object.
  • An event is a way for a class to allow clients to give it delegates to methods that should be called when the event occurs. The most familiar use for events is in graphical user interfaces.
  • Event Handlers in the .NET Framework return void and take two parameters.
  • The first parameter is the source of the event; that is the publishing object.
  • The second parameter is an object derived from EventArgs.
  • Events are properties of the class publishing the event.
  • The keyword event controls how the event property is accessed by the subscribing classes.


Question 110 - What is a Hash Table?

  • Stored in two dimensional array and have a link format of Key and Value.
  • The Hashtable object contains items in key/value pairs. The keys are used as indexes.
  • The data type of Hashtable is object and the default size of a Hashtable is 16.
  • The keys are used as indexes. We can search value by using their corresponding key.
  • Items are added to the Hashtable with the Add() method.
  • A close friend of Hashtable is Array (came from C/C++), it is an instance of System.Array class.

Disclaimer – F5debug Interview Questions & Answers Series:

You may recopy extracts from these pages ("the material") to individual third party websites or to any intranet websites, but only if:

You acknowledge www.f5debug.net as the source of the material. Such acknowledgment should include reference to www.f5debug.net in the copy of the material and should also include “© Karthikeyan Anbarasan, www.f5debug.net ". You inform the third party that these conditions apply to him/her and that he/she must comply with them.

About Author: Karthikeyan Anbarasan, Microsoft MVP (Most Valuable Professional) in ASP.NET/IIS Architecture. He is the Founder and Chief Editor of the www.f5debug.net website and has authored books on Windows Phone and Business Intelligence(SSIS). He is also a Passionate Speaker and a Blogger on Microsoft Technologies.

You can Join Me On: Facebook, Twitter, Google Plus, LinkedIn

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

Recent Posts

Random Posts

Most Viewed

URL Shortner

Create your own short urls!!!

Site Counter

free counters

Disclaimer

This is a personal weblog. The opinions expressed here represent my own and not those of my employer. For accuracy and official reference refer to MSDN/ TechNet. I have documented my personal experience on this blog.

Protected by Copyscape Web Plagiarism Finder

Site Meter