. Net question set (2)

Source: Internet
Author: User

1. What is the use of the using keyword? What is idisposable?

Using can declare the introduction of namespace and release unmanaged resources. The idisposiable class is created in using, and the dispose method of the object is automatically called after using, release resources. Using is equivalent to try ...... Finally, more convenient to use.

 

2. Assembly. Load ("foo. dll"); is this statement correct?

Error. The correct one is assembly. Load ("foo"); or assembly. loadfrom ("foo. dll ");

 

3. Main differences between XML and HTML

(1) XML is case-sensitive and HTML is not.

(2) In HTML, if the context clearly shows where the paragraph or list key ends, you can omit the ending mark such as </P> or </LI>. In XML, the end mark cannot be omitted.

HTML: <br>

XML: </img> <br/>

(3) In XML, an element with a single tag but no matching ending tag must end with one/character. In this way, the analyzer does not need to find the end mark.

(4) In XML, attribute values must be placed in quotation marks. Quotation marks are usable in HTML.

(5) In HTML, You can have attribute names without values. In XML, all attributes must have corresponding values.

XML is used to store and transmit data, and HTML is used to display data.

 

4. String STR = NULL and string STR = "" indicate the differences.

A: String STR = NULL indicates that no memory space is allocated to it, while string STR = \ "\" assigns it a memory space of a null string. String STR = NULL: no string object. String STR = "" Has A String object.

 

5. Write an SQL statement: extract the 31st to 40th records in Table A (sqlserver, using the 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)

Solution 3: Select ID, row_number () over (order by ID) as rownum from a where rownum between 31 and 40 (recommended)

 

6. The object-oriented language is ________. _________. ________.

A: encapsulate. inherit. polymorphism.

 

7. In. net, all serializable classes are marked _____?

A: [serializable]

 

8. hosted in. netCodeWe don't have to worry about memory vulnerabilities. This is because ______?

A: GC.

 

9. What is an application?ProgramDomain? What is regulated code? 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 respectively?

Application domainProvides isolation boundaries for security, reliability, version control, and uninstallation of an assembly. The application domain is often created by the runtime host, which directs the Common Language Runtime Library before running the application. The application domain provides a safer and more useful processing unit, which can be used by the Common Language Runtime Library to provide isolation between applications.

Controlled Code:In. any code running in the. NET environment is managed code ),. net external code also runs on Windows, which is called uncontrolled code ).

Code developed using a language compiler based on the Common Language Runtime Library is called managed code. managed code has many advantages, such as cross-language integration. cross-language exception handling. enhanced security. version Control and deployment support. simplified component interaction model. debugging and analysis services.

Strong LanguageIt is a language that can prohibit any code that violates the type system, or can capture all wrong languages that violate the type system. We can say that C ++ is strongly compatible with C because C ++ prohibits implicit conversions in some C, such as converting void * to any pointer type.

Packing and unpackingThe value type can be regarded as an object. Binning the value type package it into an instance of the object reference type. This allows the value type to be stored in the garbage collection heap. The value type is extracted from the object.

Each type of member has a unique signature. A Method signature consists of a method name and a list of parameters (the order and type of parameters. As long as the signature is different, you can define multiple methods with the same name in one type. When two or more methods with the same name are defined, they are called overload.

CTS Common Type System)

A specification that determines how the Runtime Library of a common language defines the use and management types.

CLR Common Language Runtime Library

. NET Framework provides a runtime environment called a Common Language Runtime Library. It runs code and provides services that make the development process easier.

CLS public Language Specification

To fully interact with other objects, regardless of the language in which these objects are implemented, objects must only disclose the common functions of all languages they must interact. To this end, the public language specification (CLS) is defined, which is a set of basic language functions required by many applications.

 

10. What is code-behind technology.

It is code hiding. in ASP. NET, the display logic and processing logic are separated by the ASPX page pointing to the CS file, which facilitates the creation of web applications. For example, the division of labor, the artist and the programming can work separately, and it is difficult to maintain the code and HTML code as in ASP.

 

11. An interface is a reference type. You can declare methods, properties, indexers, and events in the interface, but cannot declare public domains or private member variables.

 

 

12. In ADO. net, the following statements about the executenonquery () method and executereader () method of the command object are false: (c ).

A) SQL statements for insert. Update. Delete and other operations are mainly executed using the executenonquery () method;

B) executenonquery () method returns the number of rows affected by SQL statement execution.

 C) the SQL statement of the select operation can only be executed by the executereader () method;

D) The executereader () method returns a datareder object;

Answer: executescalar → select getdate ().

 

 

13. Which of the following statements about the indexer in C # is true? (c)

A) The index must have two or more parameters.

B) The indexer parameter type must be integer.

 C. The indexer has no name.

D) None of the above

 

14. To create a multi-document application, set the (d) attribute of the form to true.

A) drawgrid;

B) showintaskbar;

C) enabled;

D) ismdicontainer;

 

15. If treeview1 = new Treeview () is set, treeview1.nodes. Add ("Root Node") returns a value of the (a) type.

A) treenode;

B) int;

C) string;

D) Treeview;

 

16. Which of the following statements about XML is false is (d ).

A) XML provides a method to describe structured data;

B) XML is a simple, platform-independent and widely used standard;

C) XML documents can carry various types of information;

D) XML is only used to generate structured documents;

 

17. The following C # code is used to define an interface:

Public InterfaceIfile {IntA;IntDelfile () {=3;}VoidDisfile ();}

Which of the following statements about the above Code is false? (d ).

A) errors in the above Code include: variables cannot be defined in the interface, so the int A code line will have an error;

B) errors in the above Code include: interface method delfile is not allowed to be implemented, so specific implementation functions cannot be written;

C) code void disfile (); declares that there is no error and the interface can return no value;

D) code void disfile (); It should be written as void disfile () {}; null and null are different.

 

18. There is a button control mybutton in ASP. NET. If you click the control and navigate to another page http://www.abc.com, the correct code is (c ).

A) Private void mybutton_click (Object sender, system. eventargs e) {redirect ("http://www.abc.com ");}

B) Private void mybutton_click (Object sender, system. eventargs e) {request. Redirect ("http://www.abc.com ");}

C) Private void mybutton_click (Object sender, system. eventargs e) {reponse. Redirect ("http://www.abc.com ");}

D) Private void mybutton_click (Object sender, system. eventargs e) {request. Redirect ("http://www.abc.com"); Return true ;}

 

19. Declare a delegate Public Delegate int mycallback (int x); then the prototype of the callback method generated by the delegate should be (B ).

A) void mycallback (int x );

B) int receive (INT num );

C) string receive (int x );

D) uncertain;

 

20. What is the difference between stringbuilder and string?

A: A new instance is generated when string operations (such as value assignment and concatenation) are performed, whereas stringbuilder does not. Therefore, it is best to use stringbuilder when splicing a large number of strings or frequently performing operations on a string. Do not use string

If you want to operate on a growing string, use the stringbuilder class instead of the string class. The two classes work in different ways: the string class is a traditional way of modifying strings. It can indeed add a string to another string, but in.. Because the system first writes two strings to the memory, then deletes the original string object, creates a String object, and reads the data in the memory and assigns it. This process takes a lot of time. The stringbuilder class under the system. Text namespace is not like this. It provides the append method, which can be used to modify strings in the existing object, which is simple and direct. Of course, the efficiency difference between the two is usually not noticed, but if you want to add a large number of operations to a string, the time consumed by the stringbuilder class and the string class are not an order of magnitude.

 

21. Describe the difference between attributes and indexer. 

Attribute Indexer

ID by name. Use a signature.

Access through simple name or member access. Access through element access.

It can be a static member or an instance Member. It must be an instance Member.

The get accessors of the attribute have no parameters. The get accessors Of The indexer have the same parameters as those of the indexer.

The Set accessors of the property include the implicit value parameter. In addition to the value parameter, the set accessors Of The indexer also have the same parameters as those of the indexer.

 

22. Describe the difference between const and readonly.

The const keyword is used to modify the declaration of a field or a local variable. The value of the specified field or local variable cannot be modified. Constant declaration introduces one or more constants of a given type.

The const data member declaration must contain the initial value, and the initial value must be a constant expression. Because it needs to be fully evaluated during compilation.

A const member can be initialized using another const member, provided that there is no circular dependency between the two.

Readonly evaluates the value assignment during the runtime, so that we can postpone the initialization of the object until the runtime while ensuring "read-only access.

The readonly keyword is different from the const Keyword: the const field can only be initialized in the declaration of this field. The readonly field can be initialized in the Declaration or constructor. Therefore, the readonly field may have different values based on the constructors used. In addition, the const field is the number of compiling times, while the readonly field can be used for running times.

Readonly can only be initialized in the Declaration or constructor, and cannot be initialized in the static modifier constructor.

References:

Http://www.cnblogs.com/royenhome/archive/2010/05/22/1741592.html

Http://www.cnblogs.com/jams742003/archive/2010/03/23/1692913.html

Http://www.cnblogs.com/wayfarer/archive/2006/04/27/386658.html

 

23. Please explain ASP. What is the relationship between web pages and hidden classes in. Net?

An ASP. NET page generally corresponds to a hidden class. Generally, a hidden class is specified in the ASP. NET page declaration. For example, the declaration of a page tst1.aspx is as follows:

<% @ Page Language = "C #" codebehind = "tst1.aspx. cs" autoeventwireup = "false" inherits = "t1.tst1" %>

Codebehind = "tst1.aspx. cs" indicates the code file used when the page is compiled. inherits = "t1.tst1" indicates the hidden class used when the table is running.

 

24. What is viewstate? Can I disable it? Can all controls be disabled?

Viewstate is a mechanism for saving the state. The enableviewstate attribute can be disabled if it is set to false. The most powerful example is label. textbox's different performance after viewstate is disabled.

 

25. What do you know about Web service?

A: If you want other users to use some programs you write through web services, you can also add the [webmethed] tag to the methods you write to implement web services. [When writing a program, I want to implement some other websites that have already been implemented, and use web services to visualize the code into XML. You can use the XML generated by others' codes to find the information you need to implement some functions of your own program.

 

26. Under what circumstances will you use the virtual method? What is the difference between it and the interface?

Answer: When a subclass redefined a method of the parent class, the method of the parent class must be defined as virtual.

There cannot be a method body in the interface definition. Virtual methods are acceptable.

During implementation, the subclass can not redefine the virtual method, but if a class inherits the interface, this interface must be implemented.

 

27. optional items:

(1) which of the following statements is true? B C

A. The interface can contain virtual methods.B. A class can implement multiple interfaces. C. The interface cannot be instantiated.D. The interface can contain implemented methods.

 

(2) read records from the database. You may use the following methods: B c d.

A. executenonqueryB. executescalar C. Fill D. executereader

 

(3) For a class that implements the idisposable interface, which of the following tasks can be executed for tasks defined by applications related to the release or reset of unmanaged resources? (Multiple options) (ABC)

A. Close B. Dispose C. FinalizeD. Using e. Quit

 

(4) which of the following statements about ref and out are true? (Multiple choice) (ACD)

A. When using the ref parameter, the parameter passed to the ref parameter must be initialized first.

B. When the out parameter is used, the parameter passed to the out parameter must be initialized first.

C. If the ref parameter is used, the parameter must be passed to the method as the ref parameter explicitly.

D. When the out parameter is used, the parameter must be passed to the method as the out parameter explicitly.

 

28. single choice:

(1) Among the following options, (c) is the reference type.

A) Enum type B) struct typeC) string typeD) int type

 

(2) which of the following statements about the hidden code files in ASP. NET is true? (c)

A) the logic of a web form page program consists of Code. The Code is created to interact with the form. The programming logic is unique in a file that is different from the user interface. This file is called a "code hidden" file. If it is created in C #, it will have the ". ascx. cs" extension.

B) The code hidden files on all web forms pages in the project are compiled into. EXE files.

C) The code hidden files of all web forms pages in the project are compiled into the dynamic link library (. dll) file of the project.

D) None of the above are correct.

 

(3) which of the following statements is false? (d)

A) the class cannot be inherited multiple times, but the interface can;

B) abstract classes can define members, but interfaces cannot;

C) abstract classes and interfaces cannot be instantiated;

D) A class can have multiple base classes and multiple base interfaces;

 

29. What are the similarities and differences between datareader and dataset?

DatareaderDuring use, sqlconnection is always used and database operations are performed online. Only one piece of data is loaded in the memory at a time. Therefore, the occupied memory is very small and is read-only.

DatasetThe data is loaded into the memory at a time. abandon database connection .. when read is complete, the database connection (non-connection mode) is abandoned and all data is loaded into 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 (dynamic operation reads data into the memory)

 

30. Public static const; int A = 1; is there an error in this code?

Error: const cannot be modified to static because it is static after being defined as a constant (const ).

 

Author: forevernome
Source: http://www.cnblogs.com/ForEvErNoME/
You are welcome to repost or share it, but be sure to declare it Article Source. If the article is helpful to you, I hope you can Recommendation Or Follow

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.