Object Oriented Java Basics (ii)

Source: Internet
Author: User

Relationships between classes (objects), such as college-professor, college-graduate, Professor-Graduate.

Inheritance is a general and special relationship; For example: Athlete-ball player-basketball player.

The aggregation relationship is a whole and a part of the relationship, including aggregation and combination of 2 types, such as team-captain and team members, human-head, body and feet.

Interfaces are implemented relationships, and multiple kinds of objects implement the same interface, but the functionality of the interface is set according to its own needs.

Polymorphism: Staff-transport (driving (), braking ())-motorcycles, bicycles, cycling.

A variable type other than the base type in the Java language is referred to as a reference type, and objects in Java are manipulated by reference. Like what:

string s; declares a reference variable of type string, but does not point it to an object. At this point the Java default initial value is null.

S=new string ("Hello World"); Creates a string object with the new statement and points it to it, which can be done later with S. The value of S is the address that the heap memory assigns to the object, and s actually points to the address, after which the operation is performed on the value in that address.

How do I classify and object in memory Central?

A class is a static concept, located in a code area that is typically stored in a method area, and is placed in a permanent generation in the Sun Company's series JDK. The object is new, in heap memory, and each member variable in the class has a different value in different objects (except for static variables) and only one copy of the method, which takes up memory when executed.

object creation and use:

You must use the New keyword to create an object, using an object (reference). A member variable to refer to a member variable of an object; A method that invokes an object (a parameter list).

Each object of the same class has different storage spaces for member variables, and each object of the same class shares the methods of that class. 71



This article is from the "one step, one step" blog, please be sure to keep this source http://summerflowers.blog.51cto.com/5202033/1918741

Object Oriented Java Basics (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.