Floating FB popout byF5debug

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


Question 121 – What is a Shallow Copy?

A shallow copy means the contents (each array element) contains references to the same object as the elements in the original array.

Question 122 – What is a Deep Copy?

A deep copy (which neither of these methods performs) would create a new instance of each element's object, resulting in a different, yet identical object. Basically it copies the source objects as well. So that there will be two different copies of the sources and objects.

Question 123 – What are the different String Compare options available?

String Functions
String.Compare Compares the values of two strings. Returns an integer value
String.CompareOrdinal Compares two strings without regard to local culture. Returns an integer value
String.CompareTo Compares the current string object to another string. Returns an integer value
String.StartsWith Determines whether a string begins with the string passed. Returns a Boolean value
String.EndsWith Determines whether a string ends with the string passed. Returns a Boolean value
String.Equals Determines whether two strings are the same. Returns a Boolean value
String.ReferenceEquals Returns true if both objects point to the same location in memory

Question 124 – What is a Statics Class

  • It is not possible to create instances of a static class using the new keyword.
  • A class can be declared static, indicating that it contains only static members.
  • If a class is declared as static then the variables and methods should compulsorily declared as static.
  • Static classes are loaded automatically by the .NET Framework common language runtime (CLR) when the program or namespace containing the class is loaded.
  • Static classes cannot contain a constructor, although it is still possible to declare a static constructor to assign initial values or set up some static state.

Question 125 – What are the advantages of using Static Class?

  • The advantage of using a static class is that the compiler can check to make sure that no instance members are accidentally added.
  • The compiler will guarantee that instances of this class cannot be created.

Question 126 – List some of the main features of a Static Class?

The main features of a static class are:

  • They only contain static members.
  • They cannot be instantiated.
  • They are sealed.
  • They cannot contain Instance Constructors

Question 127 – What is a Static Member?

  • A static method, field, property, or event is callable on a class even when no instance of the class has been created.
  • Static members are often used to represent data or calculations that do not change in response to object state; for instance, a math library might contain static methods for calculating sine and cosine.
  • Static class members are declared using the STATIC keyword.
  • Static members are preloaded in the memory.

Question 128 – What is a Static Variable?

  • A static variable is a variable that will be the same in all instances of a class.
  • The initial value of a static variable is the default value of the variable's type.
  • A field declared with the static modifier is called a static variable. A static variable comes into existence before execution of the static constructor.
  • Normally each class as its own copy of all variables. If you declare some as static, then they will have the same value in each instance of a class.

Question 129 – What is a Static Method?

  • Static methods show have static keyword as the method definition
  • Static methods are accessed without creating an instance of the class object
  • Static methods will not have “this” functionality to access the method
  • Static methods cannot access non static members of the class.

Question 130 – What is a Nested Class?

  • A nested class is one that is created inside another class.
  • Nested classes have access to the private members of the outer class. So a scenario where this is the right way would be when creating a Comparer (ie. implementing the IComparer interface).
  • Nested classes are very useful for implementing internal details that should not be exposed.

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

  • Comment
  • Preview

Recent Posts

Random Posts

Most Viewed

URL Shortner

Create your own short urls!!!

Site Counter

free counters


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