Object-oriented interview questions)

Source: Internet
Author: User

Http://wenku.baidu.com/view/055188323968011ca3009164.html

1. What is object-oriented
Object-oriented oo = Object-Oriented Analysis OOA + object-oriented design Ood + Object-Oriented Programming OOP;
The general interpretation is that everything is an object, and all things are considered as independent objects (units). They can complete their own functions, rather than dividing them into functions like C;
The pure OO language is mainly Java and C #. c ++ also supports Oo, and C is process-oriented.

2. 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: Current Program Set.

3. Five main objects in ADO. net
Connection: mainly to enable the connection between the program and the database. You cannot obtain data from the database if you do not use the linked object to open the database. This object is at the bottom layer of ADO. net. We can generate this object by ourselves or automatically generate it by other objects.
Command: commands can be used to send commands to databases, such as querying, adding, modifying, and deleting data to databases, and calling pre-stored programs in databases. This object is structured on the connection object, that is, the command object is connected to the data source.
Dataadapter: implements data transmission between data sources and Dataset. It can issue commands through the command object and put the obtained data into the DataSet object. This object is structured on the command object and provides many functions used with dataset.
Dataset:
This object can be regarded as a cache, which can keep the data queried from the database and even display the whole database. Dataset
Not only can multiple tables be stored
You can also use the dataadapter object to obtain data table structures, such as primary keys, and record the associations between data tables. DataSet object can be said to be ADO. net
This object architecture is on the dataadapter object, which itself does not have the ability to communicate with the data source; that is, we treat the dataadapter object
Data transmission between dataset objects and data sources.
Datareader: You can use
Datareader
Object. The datareader object only reads data from the data source in a descending order, and the data is read-only and does not allow other operations. Because datareader
When reading data, only one read per time is limited, and only read-only is allowed. Therefore, it not only saves resources but also improves efficiency. Use datareader
In addition to high efficiency, the network load can be reduced because you do not need to transmit all the data back.
Ado. net connection
Object To connect to the database, use the command or dataadapter object to execute the SQL statement, and return the execution result to datareader or
Dataadapter, and then use the obtained datareader or dataadapter object to operate the data results.

4. list several methods for passing values between ASP. NET pages.
1. Use querystring, such ....? Id = 1; response. Redirect ()....
2. Use session Variables
3. Use server. Transfer
4. Pass cookie values
5. Pass the application value

5. What is the delegate in C? Is an event a delegate?
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.

6. Differences 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.

7. can I describe the implementation process of the indexer in C # To see if it can only be indexed by numbers?
No. Any type can be used.

8. Three-tier architecture
Generally, the three-tier architecture divides the entire business application into: presentation layer (UI), business logic layer (BLL), and data access layer (DAL ).
The purpose of hierarchy differentiation is the idea of "high cohesion and low coupling.
Presentation layer (UI): In general, the interface is displayed to the user, that is, what the user sees when using a system.
Business logic layer (BLL): operations for specific problems can also be said to be operations on the data layer and data business logic processing.
Data access layer (DAL): transactions made at this layer directly operate on the database, and there is a vertical relationship between each layer, such as adding, deleting, modifying, updating, and searching data.
A layer-3 structure is a type of N-layer structure. Generally, layers depend downward, while Layers Code Before determining its interface (contract), the upper-Layer Code cannot be developed, and the changes to the lower-Layer Code interface (contract) will change the upper-Layer Code together.
Advantages: clear division of labor, clear organization, easy debugging, and scalability.
Disadvantage: increase costs.

9. MVC Mode
Model View Controller (MVC) Model-View-Controller
MVC
It is a typical parallel relationship. It doesn't mean who is going to be in the relationship. The model is responsible for the business and the view is responsible for the display, the Controller reads the data and fills the model. Then, the model is handed over to the view for processing. And each
To verify what is processed in the model. It forcibly separates application input, processing, and output. The biggest benefit of MVC is the separation of logic and page.

10. What is packing and unpacking?
Packing: Convert from the value type interface to the reference type.
Unbox: Convert from reference type to value type.

11. What is an application domain?
A boundary that is built by the Common Language Runtime Library around the objects created within the same application range (that is, any location in the sequence of object activation starting from the application entry point ).
The application domain helps isolate the objects created in one application from those created in other applications for predictable runtime behavior.
Multiple application domains can exist in a single process. The application domain can be understood as a lightweight process. Security. Small resource occupation.

12. What are the explanations of CTS, CLS, and CLR?
CTS: Common Type System common system type.
CLS: Common Language Specification general language specification.
CLR: Common Language Runtime Library.

13. What are the similarities and differences between classes and struct in DOTNET?
Class can be instantiated, which belongs to the reference type and is allocated to the memory stack.
Struct is a value type and is allocated to the memory stack.

14. What is the difference between stack and stack?
Stack is the memory space allocated during compilation, so you must have a clear definition of the stack size in your code;
Heap is the memory space dynamically allocated during the program running. You can determine the size of heap memory to be allocated based on the program running status.

15. Requirements for accessing objects with foreach Traversal
You need to implement the ienumerable interface or declare the type of the getenumerator method.

16. What is GC? Why does GC exist?
GC is the garbage collector. Programmers do not have to worry about memory management, because the Garbage Collector will automatically manage.
To request garbage collection, call one of the following methods: system. GC () runtime. getruntime (). GC ()

17. String S = new string ("XYZ"); how many string objects are created?
Two objects, one being "xyx" and the other being referenced objects pointing to "xyx.

18. What is the difference between the value type and the reference type?
1. Different Assignment Methods: variables based on value types directly include values. When a value type variable is assigned to another value type variable, the included values are copied. The value assignment of the reference type variable only copies the reference to the object, instead of copying the object itself.
2. The value type cannot be derived from a new type: All value types are implicitly derived from system. valuetype. But what is the same as the reference type is that the structure can also implement interfaces.
3. The value type cannot contain null values: However, the null type function allows null to be assigned to the value type.
4. Each value type has an implicit default constructor to initialize the default value of this type.

19. What are the similarities and differences between interfaces and classes in C.
Differences:
The interface cannot be instantiated directly.
The interface does not contain the implementation of methods.
The interface can be inherited multiple times, and the class can only be inherited individually.
Class definition can be split between different source files.
Similarities:
Interfaces, classes, and structures can all be inherited from multiple interfaces.
An interface is similar to an abstract base class: any non-Abstract type that inherits an interface must implement all the members of the interface.
Both interfaces and classes can contain events, indexers, methods, and attributes.

20. What is the difference between abstract class and interface?
Similarities:
They cannot be directly instantiated. They can all be inherited to implement their abstract methods.
It is the technical basis for abstract programming and implements many design modes.
Differences:
Interfaces support multi-inheritance; abstract classes cannot implement multi-inheritance.
An interface can only define abstract rules. abstract classes can either define rules or provide implemented members.
An interface is a set of behavioral norms. An abstract class is an incomplete class that focuses on the concept of a family.
Interfaces can be used to support callback. abstract classes cannot implement callback because inheritance is not supported.
The interface only contains the signatures of methods, properties, indexes, and events. However, fields and methods that contain implementations cannot be defined;
Abstract classes can define fields, attributes, and include implementation methods.
The interface can act on the Value Type (struct) and reference type (class); the abstract class can only act on the reference type. For example, struct can inherit interfaces rather than classes.

21. What is the difference between sleep () and wait?
The sleep () method suspends the current thread for the specified time.
Wait () releases the lock on the object and blocks the current thread until it acquires the lock again.

22. Can I inherit the string class?
The string class is a final class, so it cannot be inherited.

23. 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?
Will be executed, before return.

24. New Keyword usage
The new operator is used to create objects and call constructors.
The new modifier is used to hide an inherited member from a base class member.
The new constraint is used to restrict the types of parameters that may be used as type parameters in a generic declaration.
New Implementation Polymorphism

25. How to copy an array to arraylist
Implement 1 string [] S = {"111", "22222"}; arraylist list = new arraylist (); list. addrange (s );
Implement 2 string [] S = {"111", "22222"}; arraylist list = new arraylist (s );

26. What data sources can the datasouse of the DataGrid connect?
Datatable
Dataview
Dataset
Dataviewmanager
Any component that implements the ilistsource Interface
Any component that implements the ilist Interface

27. What is the difference between a thread and a process?
1. both threads and processes define some boundary. The difference is that processes define the boundary between applications, different processes cannot share code and data space, while threads define the boundary of code execution stack and execution context.
2.
A process can contain several threads and create multiple threads to complete a task at the same time, that is, multithreading. Different threads in the same process share code and data space. In a metaphor
Table A process. In the family, every Member is a thread. Every member in the family has the obligation to accumulate the wealth of the family, and has the right to consume the wealth of the family, when faced with a task
The court can also send several members to collaborate, while people outside the family cannot directly consume the property of their own families.

28. What is strong type and weak type? Which one is better? Why?
A strong type determines the type of data during compilation. The type cannot be changed during execution, but the weak type determines the type during execution.
No, either of them has its own advantages. Strong type security, because it has been determined in advance, and the efficiency is high.
It is generally used for compilation Programming Language Such as C ++, Java, C #, Pascal, etc. The weak type is not safe in comparison and may cause errors during running. However, it is flexible and mostly used in interpreted programming languages, such as JavaScript and VB

29. What is reflection?
An Assembly contains a module, and a module includes a type. There are members under the type. Reflection is the management assembly, module, and type object. It can dynamically create instances of the type, set the existing object type or obtain the existing object type. You can call the method of the type and the field attribute of the access type. It is created and used at runtime.

30. Can datetime be null?
No, because it is of the struct type, and the structure belongs to the value type. The value type cannot be null. Only the reference type can be assigned null.

31. Is the using () syntax useful? What is idisposable? How does it implement a deterministic termination?
Is used to create an idisposiable class in using. After using is completed, the dispose method of the object is called to release resources. I don't understand what is the end of certainty

32. Is the statement assembly. Load ("foo. dll") correct?
Error. The correct one is assembly. Load ("foo"); or assembly. loadfrom ("foo. dll ");

33. What are the major bugs in session? What methods does Microsoft propose to solve them?
Because of the Process recycle mechanism in IIS, sessions will be lost when the system is busy. You can use sate server or SQL Server database to store sessions. However, this method is slow, the end event of the session cannot be captured.

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

35. What is the difference between heavy load and coverage?
1. The method overwrites the relationship between the subclass and the parent class, and is a vertical relationship. The method overload is the relationship between methods in the same class, and is a horizontal relationship.
2. Override can only be composed of one method, or can only be composed of one method. Method Overloading is the relationship between multiple methods.
3. The overwrite request parameter list is the same; the reload request parameter list is different.
4. in the overwrite relationship, the method body called is determined based on the object type (the object type corresponds to the bucket type); the reload relationship, the method body is selected based on the real parameter table and the form parameter table during the call.

36. traverse all textbox controls on the page and assign them a string. Empty?
Foreach (system. Windows. Forms. 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;
}
}

37. Based on the knowledge of thread security, analyze the following code. Will deadlock occur when I> 10 is called when the test method is called? And describe the reasons.
Public void test (int I)
{
Lock (this)
{
If (I> 10)
{
I --;
Test (I );
}
}
}
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)

38. Write the output result of the program
Program code
Class class1
{
Private string STR = "class1.str ";
Private int I = 0;

Static void stringconvert (string Str)
{
STR = "string being converted .";
}

Static void stringconvert (class1 C)
{
C. Str = "string being converted .";
}

Static void add (int I)
{
I ++;
}

Static void addwithref (ref int I)
{
I ++;
}

Static void main ()
{
Int I1 = 10;
Int I2 = 20;
String STR = "str ";
Class1 c = new class1 ();
Add (I1 );
Addwithref (ref I2 );
Add (C. I );
Stringconvert (STR );
Stringconvert (C );
Console. writeline (I1 );
Console. writeline (I2 );
Console. writeline (C. I );
Console. writeline (STR );
Console. writeline (C. Str );
}
}

39. Write the output result of the program
Program code
Public abstract class
{
Public ()
{
Console. writeline ('A ');
}

Public Virtual void fun ()
{
Console. writeline ("A. Fun ()");
}
}

Public Class B:
{
Public B ()
{
Console. writeline ('B ');
}

Public new void fun ()
{
Console. writeline ("B. Fun ()");
}

Public static void main ()
{
A A = new B ();
A. Fun ();
}
}
 

40. Write the output result of the program
Program code
Public Class
{
Public Virtual void fun1 (int I)
{
Console. writeline (I );
}

Public void fun2 ()
{
A. fun1 (1 );
Fun1 (5 );
}
}

Public Class B:
{
Public override void fun1 (int I)
{
Base. fun1 (I + 1 );
}

Public static void main ()
{
B = new B ();
A A = new ();
A. fun2 (B );
B. fun2 ();
}
}

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.