Understanding of several basic object-oriented concepts

Source: Internet
Author: User

I,Object-oriented is the transformation from Executor to Conductor

One thing to do now: Put the elephant in the refrigerator. 1. open the refrigerator. 2. Put it into the elephant. 3. Close the refrigerator door.

If you do this, it must first create a refrigerator that can open the door, pull the elephant into the door, and automatically close the door, then, call the refrigerator to "put the elephant in the refrigerator.

Are you willing to become an executor or a manager? Of course, it is a manager,

Ii. Classes and objects

Have you heard of the idiom "similar to things? Class is the collective name of a type of things with the same features. It is abstract and cannot be used directly. The object is a specific existence in the class. It can be seen and used directly.

Iii. Naming rules for variables/methods/classes

Variable naming rules:

1. If the variable is just one word, all lowercase letters are used. If there are multiple words, except the first word, the first letter of the other words is capitalized. If the variable name is an abbreviation of 1, such as "CCTV", each word must be capitalized.

2. The name must be meaningful. For example, string strName;

3. variables are nouns.

Naming rules for methods/classes:

1. Each word is capitalized. The method name is an action and the class name is a noun.

2. The name must be meaningful.

Iv. Differences between local variables and member variables

1. different scopes. member variables are defined under the class and outside the method. Local variables are defined in the method.

2. A local variable must be assigned a value. It does not have a default value, but a member variable has a default value (the default value of the value type is 0 and the default value of the reference type is null ).

5. deeply understand the following code

// Person and its field and method code void Main (string arg []) {Person p1 = new Person (); Person p2 = new Person (); // there is no relationship between multiple objects of the same class. The only relationship is that they are created based on the template of the same class. P1.name = "qkh"; p1.age = 18; p1.gender = false; p1.Sing ();}

 

 

 

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.