My Java Learning notes (ii)

Source: Internet
Author: User

1. A class is a template for constructing objects, and the process of constructing an object from a class is called creating an instance of the class.

2. The data in the object is called the instance domain, and the process of manipulating the data is called a method.

3. Encapsulation is the combination of data and behavior in a package, and the user of the object hides the way the data is implemented.

4. The process of building another class through a class is called inheritance.

5. Three main features of an object in OOP: behavior, status, and identity.

The behavior of an object is defined by a callable method.

Each object holds the information that describes the current feature, which is the state of the object.

Each object has a unique identity that is the identity of the object.

6. Common relationships between classes and classes

A. Dependence, that is, the relationship of Uses-a

B. Aggregation, the relationship of Has-a

C. Inheritance, that is, the relationship of Is-a

7. In the Java programming language, use the constructor to construct a new instance. A constructor is a special method used to construct and initialize an object. The name of the constructor should be the same as the name of the class.

Constructs a date class new date ();

And then you can use this variable.

System.out.println (New Date ());

New Date (). toString ();

8. There is an important difference between an object and an object variable, and an object variable does not actually contain an object, but simply refers to an object. The value of any object variable in Java is a reference to an object stored in another place.

9. You can explicitly set the object variable to null, and the surface object currently does not reference any objects. Applying a method on a null-worthy object can result in a run error.

10. Local variables are not automatically initialized to null and must be initialized by calling new or by setting them to null.

11. The method of modifying an instance domain is called a change method, and the method that accesses only the instance domain without modification is called an accessor method.

12. In a source file, there can be only one public class, but there may be any number of non-public classes.

13. The constructor has the same name as the class, which is an important difference from other methods. The constructor is always invoked with the execution of the new operator, and the constructor cannot be invoked on an already existing object to achieve the purpose of re-setting the instance domain.

Constructor Features:

A. The constructor has the same name as the class

B. The constructor can have 0, 1, or more parameters.

C. Each class can have more than one constructor.

D. The constructor does not have a return value.

E. Constructors are always called with the new operation.

Note that you do not define local variables in the constructor that have the same name as the instance domain.

14. Methods are used to manipulate objects and to access their instance domains. An implicit parameter is an object that appears in front of the method name, and the explicit argument is the value in parentheses after the method name. The keyword this can represent an implicit parameter.

15. The method can access the private data of the called object.

16. With regard to static domains, if the domain is defined as static, there is only one such domain in each class. Each object has a copy of itself for all instance domains.

17. A static method is a method that cannot be manipulated to an object. But he can access the static domain in his class.

My Java Learning notes (ii)

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.