Sei sulla pagina 1di 7

Interview questions for C#.Net 1. Whats the top .NET class that everything is derived from?

System.Object.

2. Does C# support multiple-inheritance?

No. It supports only user interfaces.

3. Who is a protected class-level variable available to?

It is available to any sub-class (a class inheriting this class).

4. Are private class-level variables inherited?

Yes, but they are not accessible. Although they are not visible or accessible via the class interface, they are inherited.

5. Describe the accessibility modifier "protected internal" ?

It is available to classes that are within the same assembly and derived from the specified base class.

6. What does the term immutable mean?

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.

7. Whats the difference between System. String and System.Text.StringBuilder classes?

System. String is immutable. System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.

8. Whats the advantage of using System.Text.StringBuilder over System. String?

String Builder 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.

9. Can you store multiple data types in System.Array?

No.

10. Whats the difference between the System.Array.CopyTo() and System.Array.Clone()?

The Clone() method returns a new array (a shallow copy) object containing all the elements in the original array. The Copy To () method copies the elements into another existing array. Both 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.

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

By calling Sort() and then Reverse() methods.

12. Whats the .NET collection class that allows an element to be accessed using a unique key?

HashTable.

13. What class is underneath the Sorted List class?

A sorted Hash Table.

14. Will the finally block get executed if an exception has not occurred?

Yes.

15. Whats the C# syntax to catch any possible exception?

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?

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.

Presentation (UI), Business (logic and underlying code) and Data (from storage or other sources). Questions on Classes

18. What is the syntax to inherit from a class in C#?

Place a colon and then the name of the base class. Example: Class MyNewClass : MyBaseClass

19. Can you prevent your class from being inherited by another class?

Yes. The keyword sealed will prevent the class from being inherited.

20. Can you allow a class to be inherited, but prevent the method from being over-ridden?

Yes. Just leave the class public and make the method sealed.

21. Whats an abstract class?

A class that cannot be instantiated. An abstract class is a class that must be inherited and have the methods overridden. An abstract class is essentially a blueprint for a class without any implementation.

22. When do you absolutely have to declare a class as abstract?

1. When the class itself is inherited from an abstract class, but not all base abstract methods have been overridden. 2. When at least one of the methods in the class is abstract.

23. What is an interface class?

Interfaces, like classes, define a set of properties, methods, and events. But unlike classes, interfaces do not provide implementation. They are implemented by classes, and defined as separate entities from classes.

24. Why cant you specify the accessibility modifier for methods inside the interface?

They all must be public, and are therefore public by default.

25. Can you inherit multiple interfaces?

Yes. .NET does support multiple interfaces.

26. What happens if you inherit multiple interfaces and they have conflicting method names?

Its up to you to implement the method inside your own class, so implementation is left entirely up to you. This might cause a problem on a higher-level scale if similarly named methods from different interfaces expect different data, but as far as compiler cares youre okay.

27. Whats the difference between an interface and abstract class?

In an interface class, all methods are abstract - there is no implementation. In an abstract class some methods can be concrete. In an interface class, no accessibility modifiers are allowed. An abstract class may have accessibility modifiers.

28. What is the difference between a Struct and a Class?

Structs are value-type variables and are thus saved on the stack, additional overhead but faster retrieval. Another difference is that structs cannot inherit.

What is .NET 4.0? It is latest version of DotNet framework offered by microsoft to develop software applications. Q2. What is .NET framework 4.0 .NET is a new framework produced by microsoft for developing and running software applications which includes web,desktop and mobile applications. It supports veriety of programming languages like C#,VB,C++,Java etc Q3. What are the new features of .NET 3.5? Main new features of .NET 3.5 are : a)VS 2008 Multi-Targeting Support b)In Built AJAX support for ASP.NET c)LINQ Support d)JavaScript Debugging Support e)Nested Master Page Support f)LINQ Intellisense and Javascript Intellisense support g)Organize Imports or Usings support h)Intellisense Filtering support i)Visual Studio 2008 Split View

j)Debugging .NET Framework Library Source Code support Q5. What is the advantages of using LINQ? Advantage of using LINQ is that we can write SQL queries in programming languages like C# or VB and we can check errors in queries at compile time. Q6. What is meant by VS 2008 Multi-Targeting Support? It means that we can create application for .NET 1.1 , .NET 2.0 and .NET 3.5 using VS 2008 Q7. What is Visual Studio 2008 Split View? Visual Studio 2008 Split View provides the option to see both source and design views by splitting the screen. Q8. What is javascript debugging support in Visual Studio 2008? In Visual Studio 2008 you can put the break point in javascript code and debug like any other language Q9. What is meant by In Built AJAX support for ASP.NET? It is not required to download ASP.NET Ajax Framework 1.0 as with .NET framework 2.0.It is in built now. Q10. What is Entity Data Model? Entity data model is a new way to handle data as entity. It is supported by Visual Studio 2008 SP1

Ques: 1 What does the keyword virtual declare for a method? Ans: The method or property can be overridden. Ques: 2 Tell me implicit name of the parameter that gets passed into the set property of a class? Ans: The data type of the value parameter is defined by whatever data type the property is declared as. Ques: 3 What is the difference between an interface and abstract class ? Ans: 1. In an interface class, all methods are abstract and there is no implementation. In an abstract class some methods can be concrete. 2. In an interface class, no accessibility modifiers are allowed. An abstract class may have accessibility modifiers. Ques: 4 How to Specify the accessibility modifier for methods inside the interface? Ans: They all must be public, and are therefore public by default. Ques: 5 Define interface class ?

Ans: Interfaces, like classes, define a set of properties, methods, and events. But unlike classes, interfaces do not provide implementation. They are implemented by classes, and defined as separate entities from classes. Ques: 6 When you declared a class as abstract? Ans: 1. When at least one of the methods in the class is abstract. 2. When the class itself is inherited from an abstract class, but not all base abstract methods have been overridden. Ques: 7 Define abstract class? Ans: 1. A class that cannot be instantiated. 2. An abstract class is a class that must be inherited and have the methods overridden. 3. An abstract class is essentially a blueprint for a class without any implementation Ques: 8 How to allowed a class to be inherited, but it must be prevent the method from being over-ridden? Ans: Just leave the class public and make the method sealed. Ques: 9 How to prevent your class from being inherited by another class? Ans: We use the sealed keyword to prevent the class from being inherited. Ques: 10 What class is underneath the SortedList class? Ans: A sorted HashTable. Ques: 11 What is the .NET collection class that allows an element to be accessed using a unique key? Ans: HashTable. Ques: 12 Difference between the System.Array.Clone() and System.Array.CopyTo()? Ans: 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 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 identacle object. Ques: 13 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. Ques: 14 What is the top .NET class that everything is derived from? Ans: System.Object.

Ques: 15 How can you automatically generate interface for the remotable object in .NET? Ans: Use the Soapsuds tool. Ques: 16 How to configure a .NET Remoting object via XML file? Ans: It can be done via machine.config and application level .config file (or web.config in ASP.NET). Application-level XML settings take precedence over machine.config. Ques: 17 What is Singleton activation mode? Ans: A single object is instantiated regardless of the number of clients accessing it. Lifetime of this object is determined by lifetime lease. Ques: 18 What security measures exist for .NET Remoting? Ans: None. Ques: 19 In .NET Remoting, What are channels? Ans: Channels represent the objects that transfer the other serialized objects from one application domain to another and from one computer to another, as well as one process to another on the same box. A channel must exist before an object can be transferred. Ques: 20 What are remotable objects in .NET Remoting? Ans: 1. They can be marshaled across the application domains. 2. You can marshal by value, where a deep copy of the object is created and then passed to the receiver. You can also marshal by reference, where just a reference to an existing object is passed.

Potrebbero piacerti anche