C # Interview Question and Answer
01. Does C# support multiple-inheritance?
Ans : No.
02. Who is a protected class-level variable available to?
Ans : It is available to any sub-class (a class inheriting this class).
03. Are private class-level variables inherited?
Ans : Yes, but they are not accessible. Although they are not visible or accessible via the class interface, they are inherited.
04. Describe the accessibility modifier “protected internal”.
Ans : It is available to classes that are within the same assembly and derived from the specified base class.
05. What’s the top .NET class that everything is derived from?
Ans : System.Object.
06. What does the term immutable mean?
Ans : The data value may not be changed. Note: The variable value may be changed, but the original immutable data value was discarded and a new data value was created in memory.
07. What’s the difference between System.String and System.Text.StringBuilder classes?
Ans : System.String is immutable. System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.
08. What’s the advantage of using System.Text.StringBuilder over System.String?
Ans : 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.
09. Can you store multiple data types in System.Array?
Ans : No.
11. How can you sort the elements of the array in descending order?
Ans : By calling Sort() and then Reverse() methods.
12. What’s the .NET collection class that allows an element to be accessed using a unique key?
Ans : HashTable.
13. What class is underneath the SortedList class?
Ans : A sorted HashTable.
15. What’s the C# syntax to catch any possible exception?
Ans : A catch block that catches the exception of type System.Exception. You can also omit the parameter data type in this case and just write catch {}.
16. Can multiple catch blocks be executed for a single try statement?
Ans : No. Once the proper catch block processed, control is transferred to the finally block (if there are any).
17. Explain the three services model commonly know as a three-tier application.
Ans : Presentation (UI), Business (logic and underlying code) and Data (from storage or other sources).
0 comments:
Post a Comment