2016/1/17 Note 1, object-oriented programming OOP 2, class

Source: Internet
Author: User

The development of OOP programming in object-oriented programming 1, low maintenance workload for process reusability
2, object-oriented reusability High Maintenance easy
Concept 1, object objects A concrete thing is an instance of a class
2, class-class entities that share the same attributes and behavior collectively

Features: 1, encapsulation: The core idea of OOP
Encapsulating properties and behaviors, hiding details
Ensure internal data integrity
2, Inheritance: Subclasses automatically inherit properties and behaviors of all parent classes
Java is a single-inheritance of all classes of the parent class object
3, Polymorphic: Overloading of methods overriding subclasses overriding the method of the parent class
A variety of forms of the Manifest class

Class 1, attribute: Refers to member variable to make data type make variable name and method sibling
2, method (also called function) ① format return value type method name (parameter data type parameter name) {method body}
② can have no return value, using void to represent
③ can be used without parameters, denoted by ()
Variables defined in the ④ method are local variables
There are four manifestations of the ⑤ method, which are embodied in the same day work.
The first form has no return value and the parameter parameter is equivalent to the vector
The second form has a return value of no parameters
The third form has a return value with parameters
Fourth form no return value no parameter
⑥return returns a keyword with a return value
3, definition: Define class keyword is class name {class Body}
4, Construction Method: ① method Name and class name to be consistent
② no return value, no void is required
③ generally used to initialize the properties of an object
④ If there is no construction method, automatically creates a constructor that defaults to no parameters if there are
The method of constructing the parameter has to use the method of constructing without parameters.
Manually loading car () {}
⑤ permission modifier (access rights)
Public common unrestricted cross-package cross-class can be called
Private only the inside of the class can be accessed
Protected protected By default this can be accessed within this package. Point to the existing class itself
Class property methods can be decorated

2016/1/17 Note 1, object-oriented programming OOP 2, class

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.