Java Object-oriented encapsulation

Source: Internet
Author: User

    1. If a class contains properties and methods, each object of that class has its own properties, but no matter how many objects a class has, the objects share the same method

    2. Summary of method parameter passing: For method parameter parameter Passing in Java, whether it is passing a native data type or a reference type, unification is a value

    3. What type of reference can point to what type of object, such as a person type's application, can point to an object of type person, but cannot point to an object of type student

    4. Construction method: Constructs the method to complete the initialization work of the object property, the characteristic of the construction method:

      1 The name of the construction method must be exactly the same as the class name (including case)

      2 constructor method does not return a value, and even void does not appear

      3 If you do not construct a method for a class declaration when you define a class, the Java compiler automatically adds a constructor that has no parameters and the method body is empty for the class

      Public person () {}

      4 If you declare a constructor for a class when you define a class, the Java compiler will no longer add construction methods to the class

      5 The constructor method of the calling class cannot be displayed, and the constructor method is usually implicitly called with the New keyword

    5. The New keyword completes three things when you build the object

      1 Opening up memory space for objects

      2 constructor method for calling class

      3 Returns the address of the generated object,

    6. Default Construction Method: Constructor method has no parameters and the method body is empty

    7. When using new to generate an object, the following parentheses represent the constructor's argument list, and if the constructor does not receive arguments, then it is clear that the contents of the parentheses are empty, and if the constructor receives the arguments, the actual parameters in the parentheses need to be consistent with the formal parameters in the constructor definition (the number of parameters is consistent, parameter types are consistent, each assigned value in order)

Java Object-oriented encapsulation

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.