C #. Net classic interview questions (1)

Source: Internet
Author: User
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 class keyword is class, while the structure keyword is struct. The structure cannot declare that there is a default constructor, and a copy of the structure is 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 a reference type, changing the value of its variables will change its original value. 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: Yes. 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 replacesProgramBut 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.
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. The const field can only be initialized in the declaration of this field. Const is static by default.
Readonly is used to declare the runtime frequency. The readonly field can be initialized in the Declaration or constructor. Depending on the constructor, readonly can have different values. Readonly is set to static and must be declared first.

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, URL.

23. What is an application domain? What is managedCode? What is unmanaged 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. It is created by the Common Language Runtime Library around the objects created within the same application scope.

Managed code: the code written by the CLR compilation language editor is called managed code. Code executed by the Common Language Runtime Library environment.
Unmanaged code: code that is directly executed by the operating system outside the public Language Runtime Library environment.

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

Packing and unpacking: the process of converting the value type to the reference type is implicit. The opposite process is unpacking and explicit.
Strongly typed system: each variable and object must have a declarative type.

Http://www.cnblogs.com/paper/archive/2009/08/01/1536586.html


 
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.
Http://www.cnblogs.com/paper/archive/2009/08/01/1536540.html

25. What authentication methods does Asp.net provide?

A: Windows (IIS), forms, 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.

The stack is automatically allocated and released by the operating system, and the space on the stack is limited. During compilation, both the variable and function allocation memory are on the stack, and the parameter transfer during function calling is also on the stack.

34. Briefly describe the access permissions of private, protected, public, and internal modifiers.
A. Private: Private Members can be accessed within the class.
Protected: protects members, which can be accessed within the class and in the inheritance class.
Public: A Public member. It is completely public and has no access restrictions.
Internal: accessible within the same namespace.
35. If. NET is used as a B/S structure system, how many layers of structure are used for development? What is the relationship between each layer and why is this hierarchy required?
A: Generally, it is three layers.
Data access layer, business layer, and presentation layer.
The data access layer adds, queries, and modifies databases.
The business layer is generally divided into two layers. The business apparent layer communicates with the presentation layer, and the business rule layer Implements user password security.
The presentation layer adds a form to interact with users, for example, users.
Advantages: clear division of labor, clear organization, easy debugging, and scalability.
Disadvantage: increase costs.
Which classes are required for reading and writing databases in 36.net? What are their roles?
Answer: Dataset: data storage. Datacommand: Execute the statement command. Dataadapter: a collection of data.
37. What is code-behind technology?
A: Code post-planting.
38. In. net, what does the accessory mean?
A: assembly. (Intermediate language, source data, resources, assembly list)
39. What are common WebService call methods?
A: 1.use the wsdl.exe command line tool. 2. Use the Add web reference menu option in vs. net
What is the working principle of 40..net remoting?
A: the server sends a process number and a program domain number to the client to determine the object location.
41. In C #, use text or images to describe the differences between string STR = NULL and string STR =.
A: String STR = NULL indicates that no memory space is allocated to it, while string STR = "" indicates that it is allocated with a memory space of a null string.
42. What are the similarities and differences between classes and struct in DOTNET?
A: The class can be instantiated. It belongs to the reference type and is allocated to the memory stack. struct belongs to the value class type and is allocated to the memory stack.
43. Analyze the following code to complete filling
String strtmp = "abcdefg ";
Int I = system. Text. encoding. Default. getbytes (strtmp). length;
Int J = strtmp. length;
After the above code is executed, I = J =
Answer: I = 13, j = 10
44. in the sqlserver server, the given table Table1 contains two field IDs and lastupdatedate. ID indicates the updated transaction number, and lastupdatedate indicates the server time when the update is performed, use an SQL statement to obtain the last updated transaction number.
A: Select ID from Table1 where lastupdatedate = (select max (lastupdatedate) from Table1)
45. Briefly discuss your understanding of the remoting and WebService technologies under the Microsoft. NET architecture and their practical applications.
A: Ws uses http to penetrate the firewall. Remoting can improve the efficiency by using TCP/IP and binary transmission.
Http://www.cnblogs.com/paper/archive/2009/08/01/1536539.html
46. the company requires the development of an inherited system. windows. forms. listview components require the following special features: When you click the headers of columns in the listview, all rows in the view can be rearranged based on the values of each row in the click column (the sorting method is similar to that in the DataGrid ). Based on your knowledge, please briefly discuss your ideas
A: Based on the column header that you click, the ID of this column is taken out, sorted by this ID, and bound to listview.
47. Write an SQL statement: extract the 31st to 40th records in Table A (sqlserver, with an automatically increasing ID as the primary key. Note: The ID may not be consecutive.
Answer: solution 1: Select top 10 * from a where id not in (select top 30 ID from)
Solution 2: Select top 10 * from a where ID> (select max (ID) from (select top 30 ID from a) as)
48. What is GC? Why does GC exist?
A: GC is a garbage collector. Programmers don't have to worry about memory management, because the Garbage Collector will automatically manage it. To request garbage collection, you can call method 1 below:
System. GC ()
Runtime. getruntime (). GC ()
49. Do I use run () or start () to start a thread ()?
A: When a thread is started, it is called. Start () Method, which does not mean that the thread will run immediately, but enters the running state. Direct call Run () A method does not generate a thread. Instead, it is called as a normal method and executed immediately.
50. Can I inherit the string class?
A: The string class is a final class, so it cannot be inherited.

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.