.net face questions must be asked of object-oriented series

Last month left, finishing past few days some common interview questions, organized into a series to share with you, is to give the opportunity to those who are prepared, the interview made rockets, work tighten the screws, do not panic, encourage each other.
1.net will face questions asked of the basic concepts of series and grammar
2.net will face questions asked series of object-oriented
3.net will face questions asked series of design patterns
4.net set of interview questions must be asked of the series, exceptions, generics
5.net must face questions to ask a simple algorithm series
6.net will ask questions face series database
7.net will ask questions face of the web front-end series

Directory problem

1. Access modifiers which usually has five kinds
2. polymorphic understanding
3. What is the constructor
4. rewritten and overloading the difference between
5.class and the similarities and differences between struct
6. Are constructor can be rewritten?
7. briefly three characteristics of object-oriented
8. abstract classes and interfaces What is the difference?
9. execution order of class
10. inheritable interface is the interface? Whether abstract class can implement (implements) interfaces? Abstract class is inheritable implementation class (concrete class)?
11. inherited the biggest benefit?
12. Please tell references and objects?
13. What is an anonymous class, what benefits
14. What are reference types, what type of value, what is the difference
15.C # Is there a static constructor, if there is what to do with of?
16. How to understand the static variables? The difference between static and non-static members?
17. Why use interfaces in the project? What are the benefits of the interface is? What is for interface development?

1. Access modifiers which usually has five kinds

public: public, unrestricted access to
internal: can be accessed within the project
internal protected: The project parent-child class can access
protected: subclasses can access
private: protected and can only be used in Ben class, fully enclosed outside

2. polymorphic appreciated

Explanation: The same operation acting on different objects to achieve different results.
Effect: increased flexibility code reusability, readability
achieved: by a derived class, the base class virtual method override, override override base class methods.

3. What is the constructor

The concept: the same method name and type constructor does not return type
role: to complete the target of an initiating
create a new object of a class, the system will automatically call the constructor to initialize a new object,
if there is no written definition, then the system will automatically providing a public constructor with no arguments

4. rewriting difference overloaded and

Override methods: Keyword with override modified, derived classes override the base class methods, the method name, return type, parameters must be the same,
overloaded methods: Method name must be the same, the parameter list must not be the same type of return may not be the same.
Action: rewriting main object-oriented polymorphism, overloading is to achieve different objects instantiated

Similarities and differences 5.class and the struct?

Similarities:
1. interfaces can be implemented
in different points:
1.class is a reference type, value type struct
2.class allow inheritance, inherited, struct not allowed, the interface can inherit
3.class variables can be initialized, not struct
4.class can no-argument constructor, struct can not, must be a constructor parameter, and there is a reference in the constructor must initialize all members of
usage scenarios:
1.class more suitable for large and complex data, performance when multiple levels of abstraction and object hierarchy. When applied to a new type Struct combined into a number of frequently used data, such as point represents, rectangular, etc. it is mainly used to store data lightweight objects, simple partial value.
2.Struct have performance advantages, Class has the advantages of object-oriented extensions.

6. Are constructor can be rewritten?

Constructor constructor can not be inherited, and therefore can not be rewritten, but can be overloaded

7. briefly three characteristics of object-oriented

Encapsulation, inheritance, polymorphism.
Packaging: through the implementation details of the object attributes hidden, just outside the provision of public access methods.
Inheritance: by subclass inherits the base class inherits the abstract classes, inheritance interface implementation.
Polymorphism: by overwriting override base class methods, overwriting virtual methods implemented.
Benefit is easy to maintain, easy to expand.
The disadvantage is: lower than the process-oriented performance.

8. abstract classes and interfaces What is the difference?

The same point: can not be instantiated directly
1. abstract modification using the abstract class, the interface with the interface modifying
2. abstract class methods may be implemented, it may not be implemented, a method of abstract class must use abstract modification process interface does not allow to achieve
3. abstract class only single inheritance, multiple inheritance interface supports
4. the abstract class has a constructor method, an interface can not have constructors
5. Interface is responsible only for the function defined by the specification class interface, (which function) , while the definition of abstract class that is responsible for functions that are implemented function (which implements functions)

9. class execution sequence

Execution order: the parent class, subclass, static blocks, static fields, block non-static, non-static fields, constructors, methods

10. Is the interface inherit the interface? Whether abstract class can implement (implements) interfaces? Abstract class is inheritable implementation class (concrete class)?

Interface can be inherited interfaces, abstract classes can implement interfaces, abstract class can inherit implementation class, but only if the implementation class must have explicit constructor.

11. inherited the biggest benefit?

The parent class members reuse, increase code readability, flexibility.

12. Please tell references and objects?

And inseparable when referencing objects, an object can generate an address in the heap, that points to a reference address on the stack which

13. What is an anonymous class, what good

No definition, no name of the class, can be used once discarded. The benefits are simple, casual, temporary.

14. What are reference types, what type of value, what is the difference

Reference type: class, interfaces, delegates, strings, arrays
value types: plastic, float, structures, enumerations, bool
difference value and reference type that directly store the value of the actual type of the variable data, and a reference type variable is stored in the address data, i.e., the referenced object.
The default value is 0 value type, reference type null.

15.C # There is no static constructor, if there is what to do with?

There.
Features:
static constructor neither the access modifier, and no parameters.
Before creating the first instance, or to any static member, it will automatically call a static constructor to initialize the class.
You can not directly call a static constructor. In the process, the user can not control when performing a static constructor.
Usage:
When a class uses the log file, using this configuration will function writes entries to the log file.

16. How to understand the static variables? The difference between static and non-static members?

Static variables belong to the class, not part of the object; and all the objects enjoyed; static member was loaded plus class time.

17. Why use interfaces in the project? What are the benefits of the interface is? What is for interface development?

Interface is a constraint, the method described class public / public properties, have not achieved any
benefits are: a clear structure, easy to understand the communication between the classes, scalability, reusability improved.
Interface-oriented development refers to the abstract-oriented programming protocol, implementers when implementing

Guess you like

Origin www.cnblogs.com/zhangmumu/p/11408026.html