C #. Net classic Interview Questions and answers

Source: Internet
Author: User

From: http://www.leezao.cn/article.asp? Id = 465

 

 

This article focuses on several common C # And. Net classic interview questions, such as "differences between classes and structures in. Net", and "How many methods of passing values between ASP. NET pages ?", The answer is concise and concise, hoping to help readers who want to learn C # And. net.

 1. What is the difference between classes and structures in. Net?

A: The structure and class have a general syntax, but the structure is limited by more than the class. The structure cannot declare that there is a default constructor. The replicas of the structure are created and destroyed by the compiler. Therefore, the default constructor and destructor are not required. The structure is a value type, so changes made to the structure variables will not affect their original values, while the class is an application type. Changing the value of the variable will change its original value. The declarative structure uses the struck keyword, the declarative class uses the class keyword, and the structure passed to the method is passed through the value instead of the reference. Unlike classes, the New Keyword can be used for Schema Instantiation. Class.

2. What are the conditions for deadlock? How to overcome it?

A: The system has insufficient resources, the process promotion sequence is inappropriate, and the resource allocation is improper. Each resource can only be used by one process, and one resource requests resources, at this time, the resource is blocked, and the acquired resource is not put. When the process obtains the resource, it cannot be forcibly deprived before it is used up.

3. Can an interface inherit the interface? Can an abstract class implement interfaces? Can an abstract class inherit an object class?

A: An interface can inherit interfaces. An abstract class can implement interfaces. An abstract class can inherit object classes. However, a condition is that the object class must have a clear constructor.

 4. Can constructor be inherited? Can be overwritten?

A: constructor cannot be inherited, so it cannot be overwritten, but can be overloaded ).

  5. Can other threads enter the method of an object after a thread enters the method of an object?

A: No. The method of an object can only be accessed by one thread.

 6. Use the most effective method to calculate the number of equal 8 pairs?

Answer: 2 <3.

7. C # Can I directly perform operations on the memory?

A: This question is difficult to answer. It is also a big question. However, you can answer questions in this way. C # can directly operate on the memory. Although pointers are rarely used, C # can use pointers. When using pointers, you must add unsafe at the front.. net uses the garbage collection mechanism (GC) function, which replaces programmers. However, the Finalize method cannot be directly used in C, instead, the finalize () method of the base class is called in the destructor.

 8. What is the difference between error and exception?

A: Error indicates that the restoration is not impossible, but it is very difficult. Exception indicates an actual or implementation problem. It indicates that the program runs normally and cannot occur.

 9. What are the differences between final, finally, and finallize?

A: Final is used to declare attributes. Methods and classes indicate that attributes are unchangeable, methods cannot be overwritten, and classes cannot be inherited.

Finally is the part in the structure of the exception handling statement that is always executed.

Finallize indicates an object class method. When executed in the garbage collection mechanism, the method of the object to be recycled is called.

  10. What is the difference between hashmap and hashtable?

A: hashmap is a lightweight Implementation of hashtable. All non-thread-safe implementations implement the map interface. The main difference is that the hashmap key value can be null and the efficiency can be higher than that of hashtable.

  11. What is the difference between collection and collections?

  A: collection is the upper-level interface of the Collection class. collections is a help class for the Collection class. It provides a series of static methods for searching, sorting, and thread-safe operations on various sets.

 12. What is delegation in C? Is an event a delegate?

A: delegate is a safe way similar to function pointer, but it is much safer than pointer. It can pass a method as a parameter to another method, it can be understood as a reference to a function. An event is a message mechanism, which is a delegate without a method body.

13. What is the difference between override and overload?

A: override indicates the method used to override the base class. In addition, the method name, return type, parameter type, and number of parameters must be the same as that of the base class.

Overload indicates that the method of the base class is overwritten, but the method name can be different if it is the same.

  14. When you need to pass variable values in a bsstructure, you cannot use sessions, coolke, and application. How many methods do you have?

A: This. server. Transfer, querystring.

  15. Can I use the C # indexer to implement a digital index?

A: No. It can be of any type.

 16. Is there a new usage?

A: There are three types. The first type is instantiation, for example, new class ()

The second method is to hide the base class using public new.

Third, any type parameter in the generic class declaration must have a common no-argument constructor.

  17. Any one that copies an array to the arraylist?

A: foreach (Object o in array), arraylist. Add (0)

There are many methods. Think for yourself.

  18. Overview of reflection and serialization?

A: Reflection: it is still difficult to define the next launch. Let's talk about my understanding here. Reflection provides encapsulated assembly, module, and type object. You can use reflection to dynamically create a type instance, bind the type to an existing object, or obtain the type from the existing object type, then, call methods of the type, access fields, and properties.

Serialization: the process of converting an object to a format transmitted by another media. For example, to serialize an object, Use http to pass the object between the client and server over the Internet, and use deserialization on the other end to obtain the object from the stream.

 19, const and readonly?

A: const is used to declare constants during programming, and readonly is used to declare the runtime constant.

 20. What are the similarities and differences between UDP and TCP connections?

A: TCP is a transmission control protocol that provides connection-oriented and reliable byte stream services. When users and servers exchange data with each other, data can be transmitted only after a TCP connection is established before data interaction. TCP provides the time-out redial function to verify data. UDP is a User Datagram Protocol, a simple datagram-oriented transmission protocol, and an unreliable connection.

 21. How do processes and threads understand each other?

A: A process is a program running unit larger than a thread. It is a system running unit experienced by the operating system. A program must have at least one process and one process, there must be at least one thread. The thread division scale is smaller than the process, and the process has independent memory units. The thread is shared memory, this greatly improves the program running efficiency. multiple threads in the same process can be executed concurrently.

  22. How do I pass values between ASP. NET pages?

A: querystring, session, cookies, application, server. Transfer, respose. redictor.

  23. What is an application domain? What is managed code? What is a strong system? What is packing and unpacking? What is overload? What are the explanations of CTS, CLS, and CLR?

A: application domain: it is the isolation boundary for security, reliability, isolation, and version control, and uninstallation. It is generally created by the runtime host, and the application domain provides a safer and more useful processing unit.

Managed code: the code written by the CLR compilation language editor is called managed code.

Packing and unpacking: the process of converting the value type to the reference type is implicit. The opposite process is unpacking and explicit.

CTS is a public-type system, CLS is a public-language standard, and CLR public-Language Runtime Library.

Strongly typed system: each variable and object must have a declarative type.

24. What is the difference between the value type and the reference type?

A: The value of the value type is stored in the stack. Changing the value does not change the original value of the variable. The value of the reference type is stored in the stack, the referenced address is stored in the stack. changing its value changes the original value of the variable. The value type cannot contain null values. However, the null type can be assigned to the value type L.

 25. What authentication methods does Asp.net provide?

A: Windows, forms, and passport

 26. What are the meanings and functions of UDDI and WSDL?

A: UDDI is a unified description Integration Protocol. It is a set of web-based, distributed, and standardized information registration implementation standards for Web Services, it is also a protocol standard that allows other enterprises to discover and access web services provided for the enterprise itself. Standard-based specifications are provided for describing and discovering services, and a set of Internet-based implementations are also provided.

WSDL is an XML-based Web service interface.

 27. What is soap?

A: simple access protocol. Is a protocol for exchanging information and implementing remote calls in a distributed environment. Is an XML-based protocol. With soap, you can ignore any transmission protocol, but it is usually HTTP protocol that allows any type of objects or code to communicate with each other in any language on any platform. It is a lightweight protocol.

 28. How to deploy an Asp.net page?

A: There is a publishing mechanism in vs2003 and vs2005. vs2003 can be released and deployed in replication.

Vs2005 can be directly deployed to the corresponding location.

  29. How to understand the garbage collection mechanism in. Net?

A: The garbage collection mechanism in. Net refers to the collection and release of memory by reference programs. When an object is created with the New Keyword each time, the runtime database allocates memory for it from the managed heap, because the space is limited, and the final garbage collection mechanism needs to recycle the unused memory. The memory has been released and used again.

  30. What are the three basic principles of object-oriented?

A: encapsulation, inheritance, and polymorphism.

 31. What is the base class of all classes in. Net?

A: object.

  32. Can I use foreach to traverse the accessed object?

A: You need to implement the ienumerable interface and the getenumerator () method.

 33. What is the difference between heap and stack?

A: heap is a heap, and space is allocated and released by manual operations. It has a large free storage zone.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.