Object-oriented --- outline notes

Source: Internet
Author: User

Object-oriented Summary
1 Encapsulation
Class 1: overall use of feature Behavior
2 Method: A piece of business logic
3. access modifier: data access permission
2 Inheritance
1 extends
2. Only one class can be inherited, but multiple interfaces can be implemented.
3. After the Child class inherits the parent class
{
Subclass Member
Parent class member
}
3 polymorphism
1. Multiple forms to improve scalability and Maintenance
1.1 References of the same type point to different objects and have different manifestations-cut
1.2 different functions are available when an object is of different shapes.
2. Upward shape
Reference of the parent class to the subclass object
3 forced conversion
3.1 The referenced object belongs to this type.
3.2 The referenced object implements this interface.
3.3 Conversion failed, classcastexception type conversion failed
We recommend that you add instanceof before turning it over.

Object-oriented content
Class 1
Object
2. Heavy Load
Constructor
Reference Type
Array
3. Memory Management
Inheritance

==========================================

4 rewrite

Two classes (parent)
The same signature method has different bodies.
The child overrides the parent
What types can be clicked?
After rewriting, call the method to view the object.
Aoo
Boo
Aoo g ()

========================================================== ====================

Access Modifier
Packge Import

========================================================== ========================
Static
Member variable static variable class: Class Name. When to use static variable name: all objects share this data
Instance variables
Static Method class name. The static method name is not passed by implicit this, and you cannot access the instance variable.
When to use a method, the processing is only related to the method parameters and has nothing to do with the object.
Blocks belong to the class Method Area
The class is only executed once when it is loaded.
When to initialize static Resources

========================================================== ==============================
Final immutable
Variable value cannot be changed
Method cannot be overwritten
Class cannot be inherited

========================================================== ==============================
5 abstract class abstract modifier quilt class inherits encapsulate public members
Interface declaration specifies a standard specification to limit the behavior of sub-classes


6 Polymorphism
Internal class

Define the internal class of a member
One class Outer can be scheduled on another class of inner
Outer. This is omitted by default (the external Class Object of the current class)
Internal class objects are generally created only in external class
Inner generally only serves outer
Inner can directly access outer members. This. name includes private

Bytes -------------------------------------------------------------------------------------

Four internal classes: anonymous internal class members internal class static internal class local internal class
1. Member internal class
Class femalemonkey {
Class liuwm {
}
} // Equivalent to the constructor period of the member Method

2 static class femalemonkey {
Static class liuwm {
}
} // The external referenced object must be static.

3 partial public void eat (){
(Only final) class banana {

}
}
4 Anonymous class new tread () {}; // implementation Interface

========================================================== ======================================

Object-oriented --- outline notes

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.