Important static knowledge points and important static knowledge points

Source: Internet
Author: User

Important static knowledge points and important static knowledge points

Summary of important static class knowledge points:

1. When calling a static method, you can only call the method using the class name, but not the object. That is to say, static members do not need to instantiate objects.

2. Static members release resources only when the whole program is launched. Therefore, static members can be used throughout the application, which is equivalent to sharing data.

3. The static class constructor will call and execute only once before the first use of the static class.

4. When a static field is added to a common class, the system generates a static constructor for the class by default. [The static constructor cannot have an access modifier or a parameter]

5. Static classes cannot be instantiated and inherited.

6. Because static members release resources only when the whole program is launched, do not write static fields as much as possible. Generally, only static methods are used.

7. Static members in static and common classes

(1) Static classes: these are generally used as tool classes. Some tool functions, such as Math and Console, are static classes. Static classes only include static members.

(2) Static members in a common class: they can only be accessed by class names. Multiple objects share one static member. Static methods can only access static members.

When should I use static classes?

A: Generally, this class is a tool class and contains methods. To make it easier for users to call it, You can directly mark this class as a static class without instantiating an object, this class can only contain static members, but cannot contain instance members.

Under what circumstances do I only need to write a static member in a common class, and this class cannot be marked as static?

A: When this class needs to be instantiated or polymorphism is used (polymorphism must be inherited, but static classes cannot be inherited ). In this case, if a member in the class is the data shared by all objects, this member in the class can be marked as static, but the class is still an instance class.

8. The same memory (static storage zone) is always used after the static method or static variable is created, and multiple memories are created when the instance is used.

9. Static class inheritance:

Static classes cannot be inherited by other classes.

Static classes cannot inherit from other classes, but only from Object classes.

Static classes cannot use polymorphism (they cannot be inherited)

Sealed: sealed class. It cannot be inherited or the subclass cannot override the method of the parent class.

10. Nature of static classes: abstract + sealde

(1) abstract: cannot be instantiated

(2) sealed: cannot be inherited.


What are the differences between static and dynamic classes in java?

Static types are class and dynamic objects
Static types can be directly accessed by class names
Dynamic type accessed by Object

C # What are the important in-depth knowledge points?

Basic knowledge: vs ide usage, data type, enumeration, structure, inheritance, polymorphism, indexer, delegation, events, etc.
Database: SQL Server, My SQL, Oracle
Important technologies: WinForm, HTML, XML, JavaScript, ASP. NET, Web Service, AJAX, Sliverlight, JQuery, etc.
WCF is not an architecture. It is a group of data communication application development interfaces developed by Microsoft.
MFC is a relatively old architecture

The level is limited. Please advise

Related Article

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.