java-Overview of Object characteristics

Source: Internet
Author: User

java-Overview of object characteristics the connection between an object and an object Dependent
Associate
aggregations can be independent
Combination not independent
inheriting the relationship of the subclass parent class
Two packaging Java files
Packaging Java Files
Jar CVFM Test.jar ***.MF ***.class class file

Unpacking Run

Java-jar Test.java

Three inheritance
subclasses (derived classes) inherit the parent class (the base class), inheriting from the inherited relationship, and facing the object is the interaction between different objects.

Keyword extends

public class S extends f{}

Private methods and variables cannot be inherited

four overriding and overloading of methods
cover
subclasses override the parent class with the same name method
1 method names
are the same
2 parameters Consistent

3 Subclass method modifier greater than or equal to parent class modifier

4 have an inheritance link
5 appears in different classes, that is, subclasses and parent classes
Overloaded

Overloads of the method appear in a class

Five polymorphic
Parent Class object = new Subclass
The object points to the child class

If the parent class and child class have overridden the method, the object still calls the subclass's override method
Object can be used as a parameter to a method

six this and super
1
This
THIS.A ();

Invoke with Point

2 Super

The precondition is that the subclass inherits the parent class

using super in subclasses
The parent class first constructs

Subclasses are constructed

Super () Represents the constructor method for calling the parent class

SUPER.A () represents the method that invokes the parent class


Seven abstract classes and interfaces

Abstract class

Keyword abstract

GCA, Animal class

1 can have member variables

2 can have a construction method

3 can have modifiers

4 can have an abstract method, no method body method (no curly braces), containing the ABSTACT keyword public abstract void eat ();

5 abstract methods of abstract classes must be overridden by the quilt class to instantiate

Interface

The interface is also a special abstract class

1 contains member variables that are more advanced than abstract classes

2 All are abstract methods, abstract, can have non-abstract class

3 The member variables of the struct must be initialized, and the contents of the parentheses are added by default
(public static final) int age = 10;

4 inheriting public class Stu implement person{} Subclasses must implement all abstract functions of the interface







java-Overview of Object characteristics

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.