[Interview question 1]

Source: Internet
Author: User

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

Private: private member, accessible only within the class

Protected: protected member, which can be accessed within the class and in the inherited class

Public: public Member, completely public, not restricted by Access

Internal: accessible within the current Assembly.

Protected internal: the two are a union, not an intersection. Can be accessed by the subclass of the class (no matter which program set this subclass belongs to) and can be accessed by the class of the same assembly

 

2. Reload, the difference between rewriting and hiding

Overload: indicates a series of methods with the same method name and different parameter lists in the same scope. Different return values have different types and cannot constitute heavy loads. The method is called based on different parameters during overload.

Override: an inheritance occurs when override is used in the subclass to redefine the methods declared in virtual or abstract in the parent class. The subclass method and the access modifier of the parent class method return values. The method name and parameter list are the same. When rewriting, both the access subclass and the parent class pointing to the subclass call the subclass method.

Hide: when the operation continues, the new keyword is used in the subclass to redefine the method in the parent class. The method name and parameter list of the subclass method and parent class method are the same. When hidden, the access subclass calls the subclass method, and the access to the parent class that points to the subclass calls the method of the parent class.

 

3.List ASP. NETThere are several ways to pass values between pages.

Answer. 1. Use QueryString, such ....? Id = 1; response. Redirect ()....

2. Use Session Variables

3. Use Server. Transfer

4. Use Application

5. Use Cache

6. Use the Item attribute of HttpContext

7. Use Files

8. Use the database

9. Use cookies

 

4.The rule for one column is as follows: 1, 1, 2, 3, 5, 8, 13, 21, 34 ......30thWhat is the number of digits,Use recursive algorithms.

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. C #What is the delegate in? 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

 

7.Programmatically traverse all TextBox on the pageControl and assign it to string. Empty?

For (int I = 0; I <Page. controls; I ++) {foreach (object item in Page. controls [I]. controls) {if (item is TextBox) {TextBox txt = (TextBox) item txt. text = string. empty ;}}}

Recursive call

Private void FindAllTextBoxByPageControl (ControlCollection controlCollection)
{
For (int I = 0; I <controlCollection. Count; I ++)
{
If (controlCollection [I]. GetType () = typeof (TextBox) // System. Web. UI. WebControls. TextBox
{
(ControlCollection [I] as TextBox). Text = String. Empty;
}
If (controlCollection [I]. HasControls ())
{
// Recursion (important). Otherwise, the program will exit.
FindAllTextBoxByPageControl (controlCollection [I]. Controls );
}
}
}

 

// Call Method

 

FindAllTextBoxByPageControl (Page. Controls );

 

 8.How can I program a bubble sort algorithm?

int[] intArray=new int[5]{4,1,6,9,3};int temp;for(int i=0;i<intArray.Length;i++){     for(int j=i+1;j<intArray.Length;j++)     {          if(intArray[i]<intArray[j])         {                temp=intArray[i];                intArray[i]=intArray[j];                intArray[j]=temp;          }         }}

9.Describe C #In the implementation process of the indexer, can only be indexed by numbers? (The indexer encapsulates attributes,For details, see msdn)

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

 

int Num = 10;        int Sum = 0;        for (int i = 0; i < Num + 1; i++)        {            if ((i % 2) == 1)            {                Sum += i;            }            else            {                Sum = Sum - i;            }        }        Response.Write(Sum.ToString());

11.Use. netDo B/SThe structure of the system. How many layers of structure are used for development? What is the relationship between each layer and why?

A: layer by MVC

Generally 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?

X = 1, y = 0

 

13.What is an application domain?

A: The application domain can be considered as a lightweight process. Security. Small resource occupation.

 

14. CTS, CLS, CLRWhat are their explanations?

Answer: CTS: Common Type System general Type System

CLS: Common Language Specification

CLR: Common Runtime Ange Runtime Common Language Runtime Library

 

 15.What is packing and unpacking?

Packing refers to converting from value type to reference type, and unpacking refers to converting from reference type to value type.

 

6.What is regulated (Managed)Code?

Managed Code refers to the code that runs on the CLR of the Common Language Runtime Library.

Unsafe: Non-hosted code that does not run through CLR. The programmer allocates and releases the memory space on his/her own.

 

17.What is a strongly-named assembly?

A: The Assembly must be encrypted and signed. A Strongly-named assembly can be deployed in the Global Assembly Cache to become a public assembly.

 

18. netWhich classes are required for reading and writing databases? What are their roles?

Connection is used for database Connection.

DataSet, which can store data from multiple tables

DataTable dataset, used to store the data of a table

A collection of DataAdapter data for filling.

DataCommand is used to execute statements.

DataReader read-only Dataset

 

19.ASP.netWhich authentication methods are available? What are their principles?

A:

Iis Control for Windows (default)

Form Account Control

Passport (key)

 

20.What is Code-Behind?Technology?

Code hiding technology to separate pages from Codes

 

21. In. netWhat do Accessories mean?

Assembly (intermediate language, source data, resources, assembly list)

 

22.Common WebService callsWhich methods?

1.use wsdl.exe command line tool

2. Use the add service reference menu in vs.net

 

23. net RemotingWhat is the working principle?

The server sends a process number and a program domain number to the client to determine the object location.

 

24. In C#, String str = nullAnd string str = ""Try to use text or images to illustrate the differences.

String str = null indicates that memory space is not allocated to str, and string = "" indicates the memory space allocated to str to be empty.

 

25.Please describe in dotnetClass)And structure (struct)?

Class is a reference type. It can inherit other classes, implement interfaces, and be used as a base class and stored in the heap.

Struct is a value type and can implement interfaces. It cannot be used as a base class or inherit from other classes and is stored in the stack.

26.Based on the delegate (delegate)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

 

Private void toolBar_ButtonClick (object sender, 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. SQLSERVERIn the server, table 1 is specified.There are two field IDS, LastUpdateDate, IDIndicates the updated transaction number, LastUpdateDateIndicates the server time when the server is updated. Use an SQL statement.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:Method I> 10Will it cause a deadlock?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.Brief Introduction to Microsoft. NETRemoting in architectureAnd webserviceUnderstanding and practical application of the two technologies.

A: webservice 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 inheritance System. Windows. Forms. ListViewClass components, to achieve the following special features: Click ListViewWhen each column header is selected, all rows in the view can be rearranged according to the values of each row in the clicked column (The sorting method is as follows: DataGridSimilar). 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 XMLFile 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>

Print all file names (FileName) Flow chart (Please 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 statementStatement: Extracts TableMedium 31stTo 40thRecord (SQLServer,Automatically increasing IDAs the primary key,Note: IDIt 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.The object-oriented language has ________Sex ,_________Sex ,________Sex

A: encapsulation, inheritance, and polymorphism.

 

35.Use foreachWhich of the following statements must be implemented to traverse the accessed object ________________Interface or declaration ________________Method type.

A: IEnumerable and GetEnumerator.

36. GCWhat is it?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. abstract classAnd interfaceWhat is the difference?

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.To start a thread, run () is used ()Or start ()?

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 an interface?Implements)Interface?Can an abstract class inherit a concrete class )?

A: The interface can inherit the interface.

Abstract classes can be implemented (implements) interfaces. abstract classes can inherit object classes, provided that the object classes must have clear constructors.

 

 

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.