ASP. NET interview questions [Abstract]

Source: Internet
Author: User
First, let's talk about your understanding of object-oriented (that is, the understanding of the three major features, encapsulation, inheritance, and polymorphism)
Encapsulation: Just like a box, you don't need to know what is in it, just know its usefulness.
Inheritance: Like a parent-child relationship, a son is a father's inheritance.
Polymorphism: for example, a father has multiple sons and each son has different characteristics.

encapsulation means that the object data and the commands used to operate the data are all part of the object itself. encapsulation can hide data in the external world as much as possible. For example, if you declare the keyword private before defining a variable, constant, or function in a module, You encapsulate it to reduce its possibility of being contaminated by the outside world.
the inherited idea is that after you define an object, you can expand the object and create some new objects. For example, you have defined a base class human. The attributes include stature, weight, age, and gender. If you want to define another class student at this time and find that this class has all the attributes of the above human base class, and also has its own unique attributes such as school, grade, class, studentid, etc, in this case, you do not have to rewrite all its attributes. You only need to declare that the student class inherits from the human class. In VB.. NET is declared with the inherits keyword. Inheritance improves the efficiency of writing Code .
polymorphism refers to the ability to implement a public interface in different ways and classes. For example, you have defined blademaster, deathknight, daemonhunter, and Archmage and created their instances respectively, at this time, you send a message "useultimateskill" to each instance. The four instances will accomplish different things. The blademaster will launch a sword storm and deathknight will summon dead bodies around you, daemonhunter will be transformed, while Archmage will achieve instantaneous movement of troops. Each class can respond to a specific message in a different way. This is the essence of polymorphism!

in Object-Oriented Design:
class: it is an object template. just like drawing a car.
Object: a specific instance of the class.
method: Execute an operation and return an object.
attribute: feature of an object

Process-oriented is to analyze the steps required to solve the problem, and then use functions to implement these steps Step by step. You can call these steps one by one. Object-oriented refers to dividing a problem transaction into various objects. The object is created not to complete a step, but to describe the behavior of a thing in the whole process of solving the problem.
For example, wuziqi, the process-oriented design is the first step to analyze the problem:
1. Start the game,
2. sunspots first,
3. Draw pictures,
4. Determine whether to win or lose,
5. It's white's turn,
6. Draw pictures,
7. Determine whether to win or lose,
8. Return to step 2,
9. output the final result.
The above steps are implemented using separate functions, and the problem is solved.

The object-oriented design solves the problem from another idea. The entire Wuzi game can be divided:
1. Both sides of the black and white sides share the same behavior,
2. The checkerboard system is responsible for drawing pictures,
3. The rule system is responsible for determining such as foul and win/lose.
The first type of object (Player Object) is responsible for accepting user input, and notifying the second type of object (board object) of the changes in the layout of the pawns, when the checker object receives the changes of the pawns, it is responsible for displaying the changes on the screen. At the same time, it uses the third type of objects (rule system) to determine the game board.
It can be seen that object-oriented is to divide the problem by functions rather than steps. The same is drawing board games. Such behavior is distributed across multiple steps in the process-oriented design, and different drawing versions may appear, because the designers usually take into account the actual situation for a variety of simplification. In the object-oriented design, plotting can only appear in the chessboard object, thus ensuring the unity of drawing.
The unified functions Ensure the scalability of the object-oriented design. For example, I want to add the regret function. If I want to change the process-oriented design, I need to change the input, judgment, and display steps, even steps must be adjusted on a large scale in sequence. If it is object-oriented, you only need to modify the chessboard object. The checkerboard system saves the chess spectrum of both sides of the black and white, and simply backtrack the Board object. The display and rule judgment do not need to be taken into account, at the same time, the calling sequence of the object function is not changed, but the changes are only partial.
Here we can clearly see the difference between object-oriented and process-oriented.

 

No matter how many years of programming experience we have, it is very difficult to fully master the idea of object-oriented. The learning of Object-oriented thinking is what we constantly learn from and summarize, abstract The entity that appears in the real world. Everything is an object. we abstract a class of things with the same attributes and behaviors into a class and encapsulate data in the class. Generally, fields are used as private member variables, external access is not allowed. The attributes and methods in the class provide other interfaces that coordinate with the object. To send a message to an object, you can only call the attributes or methods of the object, you cannot directly access the Private Members of the object, so that the data is encapsulated.
 

Understanding of Object-Oriented Programming
1. object-oriented methods support three basic activities: Identifying objects and classes, describing the relationships between objects and Classes
And define the behavior of objects by describing the functions of each class.
2. The most important concept in Object-Oriented Programming (OOP) is class, which refers to the data type, and object refers to the instances and variables of the data type.
. Class can be defined as an abstract description of a group of objects. Each object has its own specific state, but can perform the same operation.
3. There are two main tasks of the class:
I. The class defines the abstraction related to it. No matter how complicated it is, you can use classes to describe real-world entities. Of course, classes can be used to describe subsystems when they are very complex.
Ii. Class is Program Modular basis.
4. Inheritance: Use existing classes to define new classes without re-establishing them. Child classes inherit element and object methods from its parent class (base class. Inheritance is a powerful language structure with the following rules and skills:
I. Inheritance represents specialization. Subclass can be treated as a special case of the parent class.
Ii. inheritance is also used for generalization.
Iii. inheritance is actually a way to avoid code duplication.
IV. The compiler can be better understood. The parent class has some type compatibility with the subclass.
5. Polymorphism: Use a program variable to reference objects of different classes. perform operations on the variable according to the object class currently connected to the variable. Polymorphism allows an operation to be applied to an object so that the object responds in a manner that matches its type.


Second, let's briefly talk about the action principle of Asp.net (mainly the Il language and the overview of secondary compilation)

Third, the concept of a three-layer structure

Fourth, let's briefly talk about some important objects and controls (Objects: connection, command, adapter, and reader) in ado.net. Control: DataGrid, datalist, repater)

Fifth, the concept of dataset ..

1. What are the meanings of using and new keywords in C?

Using introduces a namespace, or automatically calls its idespose after an object is used. New instantiates an object, or modifies a method. This method is completely rewritten.

2. Differences between datareader and Dataset

The biggest difference between datareader and dataset is that datareader always occupies sqlconnection and operates databases online .. any operation on sqlconnection will cause datareader exceptions .. because datareader only loads one piece of data in the memory each time, the occupied memory is very small .. because of the special nature and high performance of datareader. so datareader is only in .. after reading the first article, you cannot read the first article again ..
Dataset loads data in memory at one time. abandon database connection .. the database connection is abandoned after reading .. because dataset loads all data in the memory. therefore, memory consumption is relatively high... but it is more flexible than datareader .. you can dynamically Add rows, columns, and data. perform a back-to-back update operation on the database...

3. Similarities and Differences between interfaces and classes in C #

Interfaces and classes are classes. Different things, interfaces only contain methods or attribute declarations, and do not contain code for specific implementation methods. interfaces can implement multiple inheritance While classes can only be single inheritance, the class that inherits the interface must implement the methods or attributes declared in the interface. The interface mainly defines a standard and Unified Call method, which plays an increasingly important role in large projects.

4. Please describe several common methods for passing parameters between pages in. NET and describe their advantages and disadvantages.

Six types: querystring, session, cookies, application, server. Transfer, respose. redictor
Session (viewstate) is simple but easy to lose
Application global
Cookies are simple but may not be supported and may be forged.
Input tType = "hidden" is simple and may be forged
The URL parameter is simple and displayed in the address bar with a limited length.
The database is stable and secure, but its performance is relatively weak.
Use querystring, such ....? Id = 1; response. Redirect ()....
Use server. Transfer

5. Differences between override and overload

Override is used to override the method of the parent class. The method or operator with the same name has different types of parameters.

What is the error handling mechanism of 6..net?

The. NET error handling mechanism adopts the try-> catch-> finally structure. When an error occurs, it is thrown layer by layer until a matching catch is found.

7. Briefly describe the access permissions of private, protected, public, and internal modifiers.

PRIVATE: a private member that 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.

8. Write an SQL statement: Retrieve the 31st to 40th records in Table A (sqlserver, with the Automatically increasing ID as the primary key, note: the ID may not be consecutive .)
Select top 10 * from a where id not in (select top 30 ID from)

9 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.

10Can an interface inherit an 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.

11Can constructor be inherited? Can be overwritten?

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

12 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.

13What 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.

14What 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.

15 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.

16What 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.

17What 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.

18 is there a usage for new?

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.

19 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.

20Const and readonly?

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

21 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.

22. 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.

I will try to write a few words (show data)

Dal:

Public dataset getdataset (string SQL)
{
Open ();
Sqldataadpater adapter = new sqldataadpater (SQL, connection );
Dataset dt = new dateset ();
Adapter. Fill (DT );
Close ();
Return dt
}
Bll:
Cate. CS

Public class Cate
{
Private _ name;
Public string name
{
Set {_ name = value ;}
Get {return _ name ;}
}
Public void loaddata ()
{
Dataset DS = getdataset ("select catename form Cates ");
_ Name = Ds. Tables [0]. Row [0] ["catename"];
}
}

PDL:
Cate = new Cate ();
Cate. loaddata ();
Response. Write Cate. Name;

---------
Success

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.

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.

 

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.