C# Frequently Asked Interview Questions and Answers in MNCs

7/15/2009 No Comment

Microsoft C#.NET Frequently Asked Interview Questions and Answers in top MNCs.

Please help us by providing feedback in the comments section.

A protected class-level variable available to what in C#?
Answer : Protected class-level variable  is available to any sub-class  ie a class inheriting this particular class.

What do you mean by the accessibility modifier “protected internal”.
Answer : When you specify "Protected Internal" it means that it is available to classes that are within the same assembly and derived from the specified base class.

Can private class-level variables be inherited in C#?
Answer : Yes, they can be inherited but they are not accessible. Although they are not visible or accessible via the class interface, they can be inherited.

Does C# support multiple-inheritance?
Answer : No, multiple inheritance is not supported in C#.NET

Name the top .NET class that everything is derived from?
Answer : System.Object is the top .NET class

Explain what is the main difference between System.String and System.Text.StringBuilder classes in C#.NET?
Answer : 
NET types used to represent mutable or immutable strings. System.String is immutable. System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.

What’s the advantage of using System.Text.StringBuilder over System.String?
Answer : StringBuilder is more efficient in cases where there is a large amount of string manipulation. Strings are immutable, so each time a string is changed, a new instance in memory is created.

Can you store multiple data types in System.Array?
Answer : No.

What class is underneath the SortedList class?
Answer : A sorted HashTable.

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


Explain the main  difference between the System.Array.CopyTo() and System.Array.Clone()?
Answer : The Clone() method returns a new array (a shallow copy) object containing all the elements in the original array. The CopyTo() method copies the elements into another existing array. Both are used to perform 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. 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.

Explain the meaning of the term immutable in C#?
Answer : Immutable means that data value may not be changed. However we have to note that the variable value may be changed, but the original immutable data value was discarded and a new data value was created in memory.

Name the .NET collection class that allows an element to be accessed using a unique key?
Answer : HashTable.


Name the three services model commonly know as a three-tier application.
Answer : The three tiers are Presentation (User Interface), Business Tier (Logic and Underlying Source Code) and Data Tier (from storage or other data sources).

Is it possible that multiple catch blocks be executed for a single try statement?
Answer : No, not possible. Once the proper catch block processed, control is transferred to the finally block.


Describe the syntax to catch any possible exception in C#?
Answer : In C#, a catch block catches the exception that is of the type System.Exception. However, you can also omit the parameter data type in this case and just write catch {}.for convenience.

No comments :

 

Aired | The content is copyrighted and may not be reproduced on other websites. | Copyright © 2009-2016 | All Rights Reserved 2016

Contact Us | About Us | Privacy Policy and Disclaimer