Record -.Net engineers face questions summary (1)

1, overloading and rewrite what's the difference, have any effect

Rewriting: refers to the subclass defined in the parent class method is repeated, there is a parent-child relationship of inheritance in .Net, only the virtual to virtual methods and abstract methods and absract labeled in order to be rewritten, the method in the base class modifier must be virtual, in the method of the subclass must specify override

Overload (Overloading): refers to a method of the same name exists in the same class, different values ​​of the parameter list and return type.

Method of rewriting rules:

1, the parameter list must be exactly the same as the method is overridden, otherwise it could not be called to rewrite but overloading.

2, the return type must always return the same type of method is overridden, but otherwise could not be called to rewrite overloaded.

3, limited access modifier must be greater than the access modifier is rewritten method (public> protected> default> private)

4, override method must not throw new abnormalities or abnormal ratio is overridden method stated broader examination type.

Overloading rules:
1, must have a different list of parameters;
2, can have different return types, as long as the list of different parameters on it;
3, can have different access modifiers;
4, you can throw different exception

 

2, virtual, abstract, the respective roles of the sealed

A method for modifying the virtual keyword or attribute declaration, in this case, a method or property is called virtual members. Derived class may be rewritten change inside
sealed overwritten or can not be inherited by its modified method or class, the role of sealed keyword: sealed in a class declaration using prevent other such class inheritance; in the method declaration expand the use of the sealed modifier prevents class override this method
abstrct modified class can not be instantiated, an abstract class can only declare a reference, you can not create object

 

 

3, brief const, static, readonly, volatile keyword roles and differences

const: static constant, has been modified static, can not be modified

static: Static modified class

readonly: dynamic constants can be modified static, static readonly and const very similar

volatile: is a variable modifier, volatile keyword indicates a field thread modification can be performed simultaneously by multiple. The field is not declared as volatile compiler optimization (assuming that access by a single thread) restrictions. This ensures that the fields are up to date at any time presented  value. Field volatile modifier is typically used to access by multiple threads but do not use the lock statement to serialize access

 

 

4, a brief introduction of several filter types MVC

Interceptor (Interceptor):
Action (NET MVC comes with)
the Result (NET MVC comes with)
Exception (NET MVC comes with)

Request to filter out unwanted - stopped and checked to verify the user's data, the data processing as pre - Action passed
method used is written in Action [ResultFillters]
interceptor role: code reuse, interceptors can be multiplexed
start condition is: before entering the controller operating
a single responsibility: the chef is only responsible for cooking, and leave everything early, bad calls out.
interceptors achieved by IHttpModeule interfaces
for the scene: payment center.

Filter (Filter):
As in the configuration used when something, such as to filter out vulgar words, dangerous characters, takes place before the request controller.
Can also filter some of the url, if not address registration request to the interface are filtered out.

Sequence: Filter - interceptor -Action 

 

5, the difference between the Call and the JS Apply

Apply: call a method of an object, to replace the current object with another object. For example: B.apply (A, arguments); i.e., A B object application object method.

Call: call a method of an object, to replace the current object with another object. For example: B.call (A, args1, args2); i.e. the object A calls object B method.

Apply the same point with the Call:

(1), meaning the method is the same, i.e., a method function is the same;

(2), the role of the first parameter is the same;

Call and Apply of different points:

(1), Call plurality of parameters can be passed;

(2), Apply only two arguments, so it is often used as the second parameter passed in the form of an array

The meaning of existence:

Realization (multiple) inheritance

 

6. The role of closure JS, as well as common usage scenarios encountered

The concept: a bound with many variables and environmental variables expressions (usually a function), these variables are thus part of the expression.

use:

       1, reads the internal variable function
       2, so that the values of these variables remain in memory. F1 will not be cleared automatically after the call.
       3, easy call local variables context. Encourages code encapsulation.
The reason: f1 and f2 is the parent function, f2 is assigned to a global variable, f2 is always present in memory, there is a dependence f1 and f2, f1 and therefore there is always the memory, and not at the end of the call, the garbage collection recovery .

Features:

  1. As a function of a reference variable, when the function returns, it is in the active state.
  2. A closure stack area is that when a function returns, without a release of resources.

 

Use scenario:

1, self-executing anonymous function

2. Result Cache

3, the package

4, implement classes and inheritance

 

 

7. What is the unpacking and packing

The boxed value type is converted to the reference type of process; reference is to convert unboxing a value type of process type
int I = 10;
Object O = I; // packing
int j = (int) o; // demolition box

Disadvantages:
take up memory and Cpu

 

8, Vachar and char What is the difference

char is a type of fixed length, varchar is a variable length type.
char types such as: char (10) if only temporarily with a 3-byte, then the rest is not occupied by a space character make up
vachar how much use is the number of
char can store up to 255 characters
vachar can store up to 65,532 characters
char access speed than vachar, but is space for time
char of storage is English character occupies 1 byte of characters occupies 2 bytes of storage and is varchar each English character occupies 2 byte, 2 bytes also characters;

 

9, String and StringBuilder What is the difference?

String: immutable character sequence
StringBuilder: variable sequence of characters
such as, will continue to be created when a character in memory String spliced with a new string object, the allocation of new space, if the string is spliced to use StringBuilder, if simply create a new String object can be used
as S = String "1234";
Console.WriteLine (S);
S + = "789";
Console.WriteLine (S);
output is: 12341234789
wherein a first output is 1234, but the second is actually to create a new memory, the memory point to the new address, in which there are two string heap, although references only the second, but the first in 1234 but it is still in memory

String The reason is not deleted and are retained: String is a reference type, such as String s = "1234"; string Str = "1234"; wherein str points to s. To ensure efficient use of memory
to modify objects StringBuffer StringBuilder class and can be many times, and does not generate new unused objects.

Large amounts of data operation StringBuffer multithreaded operating string buffer;
operating large data string buffer StringBuilder single thread operation.

StringBuilder class is presented in Java 5, the biggest difference between it and the StringBuilder StringBuffer that the method is not thread-safe (can not synchronize access).
Since the StringBuffer StringBuilder compared to the speed advantage, so in most cases recommend using the StringBuilder class. However, in the case of application requires thread-safe, you must use the StringBuffer class.

Speed: StringBulider> StringBuffer> String

 

 

10, you have used the transaction, the understanding of affairs

In a relational database, can be composed of a SQL, SQL can also be composed of a few days by the
characteristics

Consistency (consistency): the sum of money Joe Smith and John Doe remains unchanged.

Atomicity (Atomicity): Joe Smith and John Doe less money to increase the money at the same time.

Persistence (durability): These final changes to the data to be stored in the database
isolation (isolation): fully executed before the transaction is successful, does not affect other matters, it will not be affected by other transactions

Database transactions:

1, he can provide a method to recover from a failed state to the normal operation of the database

2, when a plurality of applications access the database concurrently, it is possible to provide a method for the isolation of these applications, the operation can be prevented from mutual interference between the respective applications

System transactions:

3, when a series of business operations, either all executed or not executed all

The scene may be used: during the three data table is modified, has been revised and a first data table, when the table data of the second modification, a sudden power failure, the transaction may be used.

 

11, the difference value and reference type

string belongs to a reference type. int type values ​​belonging to

1. The value of the type of data stored in the memory stack; stack type of reference data is stored in the memory, and the memory cell storing only the objects in a heap
address.
2. Value Type access speed, access speed slower reference type.
3. The data indicate that the actual value, a reference type indicates a pointer pointing to the data stored in the heap or reference

 

12, the handwritten ajax javascript code

function Test(){
var val=1;
$ajax({
type:"get";
url:"login";
async:ture;
data:"value+=":val;
dataType:json;
success:function(data){
}
error:function(data){
}
})
}

 

13, bubble sort handwriting

public static void ArraySort()

{
int[] Arr = { 9, 8, 7, 6, 5, 4, 3, 2, 1 };

int t = 0;

// from small to large

for (int i = 0; i <Arr.Length - 1; i ++) // total of N-1 times

{
For (int J = 0; J <arr.length -. 1 - I; J ++) // per trip total of (N-1- number of passes) comparisons
{
IF (Arr [J]> Arr [J +. 1] )
{
T = Arr [J];

Arr [j] = Arr [j + 1];

Arr[j + 1] = t;
}
}
}
foreach (int i in Arr)
{
Console.Write(i + ",");
}
}
public static void Main()
{
ArraySort();
}

 

14, ref and out what is the difference?

When ref-type parameters, the parameters passed must be initialized.
When out parameter that must process initializes
out when needed for multiple return values return, ref with the reference to the modified method is called the caller.
ref wear into the internal parameters can be directly used in the function, and the need to initialize out in order to use the method in
ref has an intake, and out out without

 

 

15, delegates and events of what relationships are, why use commission

Delegates provide a method of packaging the way, the event is a certain action has occurred, the event is based on the commission of
the same delegate can call different methods when the program is running, as long as the change in his method can be cited, therefore commissioned conditioner the method is not when compiling the decision, but the program is running into determined.

 

 

16, what is different interfaces and classes, and the same points

Different points:
not be instantiated directly interfaces, and classes can
interface contains methods and attributes only, no methods implemented
interface multiple inheritance, while only single inheritance class
class concept of class division, can be defined in different source split between files
realized and expression of a set of different meanings, the interface specification is to define a main, uniform call the method, constrained class, class methods function

The same point:
interfaces and classes and structures can be inherited from multiple interfaces
similar abstract base class interface: any type of non-abstract interfaces inherit all of the members must implement interfaces
interfaces and classes can contain events, indexers, methods and properties

 

 

17, why should we try to use the DataReader, rather than DataSet

Because the DataReader has been occupied with Sqlconnection, any operation will be on sqlconnnection makes DataReader exception, because every time you load only one data, taking up less memory
Dataset is a one-time all the data out fully loaded, in memory. The memory occupied by a large, flexible than DataReader, because you can dynamically add rows, columns, data. And return the database update operations.

 

 

18, the generic meaning of each

class A<T>where T:new()

where T indicates that the constraint on the relationship between the type of variable
where T: A type of data representing variables inherited from A, or A itself
where T: new () creates an instance of T should be specified enough to use the function

T refers to a placeholder

 

 

19. What is object-oriented thinking

Inheritance: subclass inherits all of the data and the operation of the parent class
Package: abstract data types and data packaged together based on the operation, data is protected abstract data types encapsulated
polymorphism: coexistence of different methods, but a program with the same name case, there are two forms: overloading and rewrite

 

 

20, the difference between the difference between heap and stack, heap and stack

Heap: dynamic allocation of memory space during the run, and storage is an array of objects (that is, in fact, an array of objects), any new establishment is in the heap, the heap is stored entities (objects)

Stack: compiled during the allocated memory, stack memory is a first memory area, are stored in local variables, all methods are defined in the local variable (global variable is outside a method)

Stack's life cycle is generally very short, run out on release, and will be stored in the entity heap garbage collection from time to time of recovery

 

 

 

21, Fibonacci number, the calculated value of the thirtieth

F(n-1)+F(n+1)

第三十是832040

public static Fn(int i)
{
if(i<=0)
{
return 0;
}
else if(i>0&&i<=2){return 1}

else{return F(i-1)+F(i+1)}
}

}

 

 

22, which is connected to a database table method, what is the difference

Left (Left) and the Join Right (Right) the Join call connection because the data do not correspond may occur, according to the data recorded right and left, and the corresponding field of a table do collar blanking process
such as : select * from table1 left join table2 on table1.id = table2.id;

left join (left join) check out all the table data, table2 in line with table1.id = table2.id of data, not as null
right the Join (right link) and left join opposite
inner join (equijoins): Only check of the data table1.id = table2.id

 

 

 

23, the difference between database tables and innodb engine of myisam

Innodb: a transactional engine support, providing a commit, rollback, crash recovery of transaction-safe storage engine, all of the content stored in one or more files, support for Oracle. Lock mechanism
advantages are: provides the ability to control matters, when a set of commands to perform all the success, or any results of a command error all commands are rolled back
Disadvantages are: slow, large disk space


myisam: is a non-transactional engine, improve the retrieval and storage of speed, and full-text search engine, you can use Full text indexing, data query for frequent applications, a table is divided into three documents - the definition of storage, storage of data , keep crude index.
Advantages are: fast read, do not take up a lot of resources.
Disadvantages are: 1, 2 does not support transactions, fault tolerance is not good, after a disk crash, the data is gone

 

 

 

24, when to use GET, when used Post

GET method will produce a very long URL, the URL may exceed the length of the tour is limited, insecurity, others can see the parameters
in general use for data queries GET, get data from the server
POST generally form submission, making deletions general data, the server transmits data to change the POST

 

 

25, to talk about how to use Redis, and how to determine whether the cached data updates, and see what effect the cache

Cache Cache is generally not often get the data, we can not always ensure the database is always consistent and
the cache has the advantage of reducing the database query and manipulate
data cache shortcomings can not be fully guaranteed and consistent database

To use are: to determine whether there is data in the cache, there is no caching of data from the database query and modify data update cache

Cache speed is faster reasons: keep memory operation, single-threaded operating, non-blocking I / O multiplexing mechanism (that is, a courier car, in order to get the parcel customers)
Redis expiration policies:

Regularly delete: Set the timer, check the key, random checks every 100ms (if all the checks, Redis will get stuck)
inert Delete: When a key request of, redis checks has expired, if the expiration will be removed.
+ Delete to delete the timing inert without reason: it periodically delete delete key, did not go to the request, the memory will be higher. You need to use the mechanism to eliminate memory (no memory on the error, or delete key recent memory is not less, no random memory delete key)

 

26, using the MVC, as well as an understanding of the MVC

MVC is divided into three layers:
V = view View presentation layer
C = Controller user interaction layer, processing the data acquired from the back to the Model View
M = Model service logic processing, but also across BLL Model and the DAL.
Advantages:
1, carry out their duties without disturbing each other. Changes in demand that layer three, only need to change the code corresponding layer without affecting other layers in the code
2, in favor of division of labor, to do page, do business, do business, do make the underlying underlying
shortcomings :
1, access to the inefficient model data, view multiple calls may only obtain sufficient data displayed on the data did not change unwanted access, damage the operating performance

 

 

27, what is the understanding of the ES, how to use the ES (ES7, remove the Type grouping)

Is based on open source Lucene search engine, is essentially a distributed database that allows multiple computers to run multiple ES
has indexed - nodes - cluster concept, a set of nodes in a cluster, the index recorded a single document called the Document, and more a Document make up an index, each document is JSON format. With the concept of fragmentation, the default is 5, primary and secondary fragmentation, the equivalent load balancing, automatically root
after routing control according to load balancing into other fragments to query data for a slice of a problem, but also through other node to recover.
Tokenizer can be installed as IK segmentation
method of obtaining data is obtained corresponding to the GET request to connect the specified Json data query (HTTP request)
to establish before mapping Mapping index, corresponding to the field structure of the database

 

28, databases and sub-partition table

Zoning: The partition according to the time, such a region is 2018-2019. A data table is divided into N blocks, logically consists of a table, the physical block is actually composed of N
sub-tables: the table in accordance with a predetermined rule to be decomposed into N separate physical storage space table, as a table according to the type of 1/2/3/4/5 tYPE table is divided into five
priority partition, and sub-table.
After partition data is present in a table, but a table according to the part table sucked into N a field to the table, thus reducing the amount of data in each table, to speed up the query speed and write speed

Data stored in the sub-libraries sucked without server

 

 

29, truncate and delect, drop what is the difference

Remove delect is performed every row deleted from the table, and this deletion operation in a transaction log records to roll back the
truncate is disposable delete all the data in the table, not logging, not roll back, the removal process does not activate the delete trigger associated with a table, execution speed
drop to delete the entire table
truncate only for table
delect can view the operating table and
to drop> truncate> speed delect

 

 

30, what is the interface

The interface is simply a convention appreciated, such a class or interface structure to achieve consistency in the form of
the interface is generally divided into two types.
First, the inside of the interface program: and a method of interaction between the between the module and the module. Such as login and post, post must be logged in to post need to call the login interface.
Second, the system interface to the outside: To obtain each other's resources or information from other sites, the other side will not open the database, then the other party will provide a method for obtaining query data out of the specified data, such as shopping sites need to call or micro letter Alipay payment interface.
Interface is divided into two types:
API interfaces: http protocol, distinguished by path, requests and content are key-value format, the content is generally returned json format, get and post methods methods are more commonly used.
webservice Interface: soap is transmitted through http protocol, and requests are returned in xml format

 

Guess you like

Origin www.cnblogs.com/xuzy-x/p/11701126.html