ASP. NET classic 60 interview questions, asp. net60 questions
1. 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.
2. List several methods for passing values between ASP. NET pages.
Answer. 1. Use QueryString, such ....? Id = 1; response. Redirect ()....
2. Use Session Variables
3. Use Server. Transfer
3. the rules for a column are as follows: 1, 1, 2, 3, 5, 8, 13, 21, 34 ...... calculate the number of 30th digits and use a recursive algorithm.
A: public class MainClass
{
Public static void Main ()
{
Console. WriteLine (Foo (30 ));
}
Public static int Foo (int I)
{
If (I <= 0)
Return 0;
Else if (I> 0 & I <= 2)
Return 1;
Else return Foo (I-1) + Foo (I-2 );
}
}
4. What is the delegate in C? Is an event a delegate?
A:
A delegate can substitute a method as a parameter into another method.
A delegate can be understood as a reference to a function.
Yes, it is a special delegate
5. Differences between override and overload
A:
The difference between override and overload. Overload means that the method name is the same. The parameters or parameter types are different and are reloaded multiple times to meet different needs.
Override is used to Override functions in the base class. To meet your needs.
6. If you need to pass variable values in a B/S system, but you cannot use Session, Cookie, and Application, how can you handle them?
A:
This. Server. Transfer
7. programmatically traverse all TextBox controls on the page and assign it a string. Empty?
A:
Foreach (System. Windows. Forms. Control control in this. Controls)
{
If (control is System. Windows. Forms. TextBox)
{
System. Windows. Forms. TextBox tb = (System. Windows. Forms. TextBox) control;
Tb. Text = String. Empty;
}
}
8. How can I program a Bubble sorting algorithm?
A:
Int [] array = new int
;
Int temp = 0;
For (int I = 0; I <array. Length-1; I ++)
{
For (int j = I + 1; j <array. Length; j ++)
{
If (array [j] <array)
{
Temp = array;
Array = array [j];
Array [j] = temp;
}
}
}
9. To describe the implementation process of the indexer in C #, can it be indexed only by numbers?
A: No. Any type can be used.
10. Evaluate the values of the following expressions and write out one or more implementation methods: 1-2 + 3-4 + ...... + M
A:
Int Num = this. TextBox1.Text. ToString ();
Int Sum = 0;
For (int I = 0; I <Num + 1; I ++)
{
If (I % 2) = 1)
{
Sum + = I;
}
Else
{
Sum = Sum-I;
}
}
System. Console. WriteLine (Sum. ToString ());
System. Console. ReadLine ();
11. Use. net for B/S structure. How many layers of structure do you use for development? What is the relationship between each layer and why do you need to layer it like this?
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.
12. In the following example
Using System;
Class
{
Public ()
{
PrintFields ();
}
Public virtual void PrintFields (){}
}
Class B:
{
Int x = 1;
Int y;
Public B ()
{
Y =-1;
}
Public override void PrintFields ()
{
Console. WriteLine ("x = {0}, y = {1}", x, y );
}
What is the output when new B () is used to create B's instance?
Answer: X = 1, Y = 0; x = 1 y =-1
13. What is an application domain?
A: The application domain can be considered as a lightweight process. Security. Small resource occupation.
14. What are the explanations of CTS, CLS, and CLR?
A: CTS: a general-purpose language system. CLS: general language specification. CLR: Common Language Runtime Library.
15. What is packing and unpacking?
A: From the value type interface to the Reference Type Packing. Converts a reference type to a value type Unbox.
16. What is regulated code?
A: unsafe: unmanaged code. Does not run through CLR.
17. What is a strong system?
A: RTTI: The type recognition system.
Which classes are required for reading and writing databases in 18.net? What are their roles?
Answer: DataSet: data storage.
DataCommand: Execute the statement command.
DataAdapter: a collection of data.
What are the authentication methods for 19.ASP.net? What are their principles?
Answer: 10. Windwos (default) IIS... From (form) account... Passport (key)
20. What is Code-Behind technology?
A: Code post-planting.
21. In. net, what does the accessory mean?
A: assembly. (Intermediate language, source data, resources, assembly list)
22. 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 23..net Remoting?
A: the server sends a process number and a program domain number to the client to determine the object location.
24. 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.
25. 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 type and is allocated to the memory stack.
26. Based on the delegate knowledge, complete the following code snippets in the user control:
Namespace test
{
Public delegate void OnDBOperate ();
Public class UserControlBase: System. Windows. Forms. UserControl
{
Public event OnDBOperate OnNew;
PrivatevoidtoolBar_ButtonClick (objectsender, System. Windows. Forms. ToolBarButtonClickEventArgs e)
{
If (e. Button. Equals (BtnNew ))
{
// Complete the following code to call the OnNew event of the OnDBOperate delegate signature.
}
}
}
A: if (OnNew! = Null)
OnNew (this, e );
27. 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
28. 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)
29. Based on the knowledge of thread security, analyze the following code. Will the deadlock occur when I> 10 is called when the test method is called? And briefly explain the reasons.
Public void test (int I)
{
Lock (this)
{
If (I> 10)
{
I --;
Test (I );
}
}
}
A: No deadlock will occur (but one int is passed by value, so each change is only a copy, so no deadlock will occur. But if you replace int with an object, the deadlock will occur)
30. 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.
31. 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.
32. Specify the following XML file to complete the algorithm flow chart.
<FileSystem>
<DriverC>
<Dir DirName = "MSDOS622">
<File FileName = "Command.com"> </File>
</Dir>
<File FileName = "MSDOS. SYS"> </File>
<File FileName = "IO. SYS"> </File>
</DriverC>
</FileSystem>
Draw a flowchart that traverses all file names (FileName) (use recursive algorithms ).
A:
Void FindFile (Directory d)
{
FileOrFolders = d. GetFileOrFolders ();
Foreach (FileOrFolder fof in FileOrFolders)
{
If (fof is File)
You Found a file;
Else if (fof is Directory)
FindFile (fof );
}
}
33. 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 continuous.
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)
34. object-oriented languages include ________, _________, and ________.
A: encapsulation, inheritance, and polymorphism.
35. To use foreach to traverse the accessed object, you need to implement the ____________ interface or the type of the declared ________________ method.
A: IEnumerable and GetEnumerator.
36. What is GC? Why does GC exist?
A: GC is a garbage collector. Programmers do not have to worry about memory management, because the Garbage Collector will automatically manage. To request garbage collection, you can call one of the following methods:
System. gc ()
Runtime. getRuntime (). gc ()
37. String s = new String ("xyz"); how many String objects are created?
A: There are two objects, one being "xyx" and the other being the reference object s pointing to "xyx.
38. What is the difference between abstract class and interface?
A:
The class that declares a method rather than implementing it is called abstract class. It is used to create a class that reflects some basic behaviors and declare a method for this class, however, this class cannot be implemented in this class. You cannot create an abstract instance. However, you can create a variable whose type is an abstract class and point it to an instance of a specific subclass. Abstract constructors or abstract static methods are not allowed. The subclasses of Abstract classes provide implementation for all Abstract methods in their parent classes. Otherwise, they are also Abstract classes. Instead, implement this method in the subclass. Other classes that know their behavior can implement these methods in the class.
An interface is a variant of an abstract class. All methods in the interface are abstract. Multi-inheritance can be achieved by implementing such an interface. All methods in the interface are abstract, and none of them have a program body. The interface can only define static final member variables. The implementation of an interface is similar to that of a subclass, except that the implementation class cannot inherit behaviors from the interface definition. When a class implements a special interface, it defines (to be given by the program body) all the methods of this interface. Then, it can call the interface method on any object that implements the interface class. Because there is an abstract class, it allows the interface name as the type of the referenced variable. Normally, dynamic Association editing will take effect. The reference can be converted to the interface type or from the interface type. The instanceof operator can be used to determine whether the class of an object implements the interface.
39. Do I use run () or start () to start a thread ()?
A: To start a thread is to call the start () method so that the virtual processor represented by the thread is runable, which means it can be scheduled and executed by JVM. This does not mean that the thread will run immediately. The run () method can generate the exit sign to stop a thread.
40. Can an interface inherit the interface? Can an abstract class implement the (implements) interface? Can an abstract class inherit a concrete class )?
A: The interface can inherit the interface. Abstract classes can be implemented (implements) interfaces, and whether abstract classes can inherit object classes, provided that object classes must have clear constructors.
41. Can Constructor be overwritten?
A: Constructor cannot be inherited, so Overriding cannot be overwritten, but Overloading can be overloaded.
42. Can I inherit the String class?
A: The String class is a final class, so it cannot be inherited.
43. If there is a return statement in try {}, will the code in finally {} following this try be executed? When will it be executed, before or after return?
A: Yes. It will be executed before return.
44. The two objects have the same value (x. equals (y) = true), but different hash codes are available, right?
A: No. It has the same hash code.
45. Does swtich work on byte, long, and String?
A: In switch (expr1), expr1 is an integer expression. Therefore, the parameters passed to the switch and case statements should be int, short, char, or byte. Long and string cannot apply to swtich.
47. After a thread enters a synchronized method of an object, can other threads access other methods of this object?
No. One synchronized Method of an object can only be accessed by one thread.
48. can abstract methods be both static, native, and synchronized?
A: No.
49. Does List, Set, and Map inherit from the Collection interface?
A: List, Set is Map, not
50. The elements in the Set cannot be repeated. How can we identify whether the elements are repeated or not? Is = or equals () used ()? What are their differences?
A: The elements in the Set cannot be repeated. Use the iterator () method to identify whether the elements are repeated or not. Equals () is used to determine whether two sets are equal.
The equals () and = Methods Determine whether the reference value points to the same object equals () is overwritten in the class, in order to return the true value when the content and type of the two separated objects match.
51. Does the array have the length () method? Does String have the length () method?
A: The array does not have the length () method. It has the length attribute. String has the length () method.
52. What is the difference between sleep () and wait?
A: The sleep () method is used to stop a thread for a period of time. After the sleep interval expires, the thread may not resume execution immediately. This is because at that time, other threads may be running and not scheduled to give up execution, unless (a) the thread "wakes up" has a higher priority.
(B) The Running thread is blocked for other reasons.
When wait () is a thread interaction, if the thread sends a wait () call to a synchronization object x, the thread will pause the execution and the called object will enter the waiting state, wait until the wake-up or wait time is reached.
53. short s1 = 1; s1 = s1 + 1; what is the error? Short s1 = 1; s1 + = 1; what is the error?
Answer: There is a mistake in short s1 = 1; s1 = s1 + 1; s1 is short type, s1 + 1 is int type, and cannot be explicitly converted to short type. It can be changed to s1 = (short) (s1 + 1 ). Short s1 = 1; s1 + = 1 is correct.
54. Let's talk about the differences between final, finally and finalize.
A:
Final-modifier (keyword) If a class is declared as final, it means that it cannot generate a new subclass and cannot be inherited as a parent class. Therefore, a class cannot be declared both abstract and final. Declare variables or methods as final to ensure that they are not changed during use. Variables declared as final must be declared with an initial value, which can only be read and cannot be modified in future references. Methods declared as final can only be used and cannot be reloaded.
Finally-The finally block is provided for troubleshooting. If an exception is thrown, the matched catch clause is executed, and the control enters the finally block (if any ).
Finalize-method name. Java technology allows you to use the finalize () method to clear objects from the memory before the Garbage Collector clears them. This method is called by the garbage collector when it determines that this object is not referenced. It is defined in the Object class, so all classes inherit it. Subclass overwrites the finalize () method to sort system resources or perform other cleanup tasks. The finalize () method is called before the Garbage Collector deletes an object.
55. How to handle hundreds of thousands of concurrent data records?
A: use stored procedures or transactions. When getting the maximum ID, update it at the same time. Note that the primary key does not have duplicate primary keys when it is not in auto increment mode. A stored procedure is required to obtain the maximum ID.
56. What are the major bugs in Session? What methods does Microsoft propose to solve them?
A: The Session is lost when the system is busy due to the process recycle mechanism in iis. You can use Sate server or SQL Server database to store the Session. However, this method is slow, the END event of the Session cannot be captured.
57. What is the difference between a process and a thread?
A: A process is the unit of resource allocation and scheduling by the system. A thread is the unit of CPU scheduling and scheduling. A process can have multiple threads which share the resources of the process.
58. What is the difference between stack and stack?
A:
STACK: the stack is automatically allocated and released by the compiler. Variables defined in the function body are usually on the stack.
Heap: usually assigned and released by programmers. The memory allocated by using new and malloc functions is on the heap.
59. What is the role of adding static before member variables and member functions?
A: They are called common member variables and common member functions, also known as class member variables and class member functions. They are used to reflect the status of the class respectively. For example, a class member variable can be used to count the number of class instances. class member functions are responsible for such statistical actions.
60. ASP. NET compared with ASP, what are the main advances?
A: asp interpretation form and aspx compilation form help improve the performance and protect the source code.
61. generate an int array with a length of 100 and insert 1-100 randomly into it, which cannot be repeated.
Int [] intArr = new int [100];
ArrayList myList = new ArrayList ();
Random rnd = new Random ();
While (myList. Count <100)
{
Int num = rnd. Next (1,101 );
If (! MyList. Contains (num ))
MyList. Add (num );
}
For (int I = 0; I <100; I ++)
IntArr = (int) myList;
Aspnet interview questions
1. main (){
Int a [100], I, j, k;
For (j = 1; j <= 99; j ++)
For (I = j + 1; I <= 100; I ++)
If (a [j]> a [I])
{
K = a [I];
A [I] = a [j];
A [j] = k;
}
For (I = 1; I <= 100; I ++)
Console. writeln (a [I])
}
2. request. session. cookies and application
3. select top 10 * from user where fid> 30
Problematic to group 38542045
Come and ask
Hope to get answers to the ASPNET interview questions
1. abstract class method! Only method names do not have method implementations! The subclass must implement the virtual function! 2. the B/s client only needs a browser to move all the programs running on the server! The implementation of the "thin client fat server mode" C/s mode requires the client's hardware resources! I haven't seen many specific things for a long time, and I can't remember them now! 3. server cache, client browser cache, URL, Server. transfer 4. 5. public Number_sum (int x) {if (X> 1) {return Number_sum (x-1)} Else {return 1 ;}} 6. for (int I = 1; I <10; I ++) {for (int j = 1; j <= I; j ++) {label1.text = label1.text + (I * j ). toString ();} label1.text = label1.tex + "\ n";} 8. using the Row_Number () function, you do not have to say how many pieces of data are required for a page. I cannot write the format for you: select row_number () over (order by field2 desc) as row_number, * from t_table order by field1 desc