Java Object-oriented concepts

Source: Internet
Author: User

Object-oriented three features: encapsulation, inheritance, and polymorphism.

The process of Java development is to find the right library object to use, and no objects to create new objects. Find objects, create objects, use objects, and maintain relationships between objects.

Class is the description of things in real life, and objects are the real individuals of such things. Corresponding to Java programming, the description is the class structure defined by class,

An object is an entity that is built through new application heap memory. Defining a class is describing things, that is, defining properties and behaviors. Attributes and behaviors become members of the class together

(Member variables and member methods).

The difference between a member variable and a local variable:

1. Scope: the member variable acts on the whole class, the local variable acts in the function or the statement;

2. Storage location: The member variable is in heap memory because the object exists in memory and is locally in the stack memory.

Anonymous objects:

Car c=new car ();  c.num=5; Equivalent to New Car (). num=5;

If new Car (). num=5;  New Car (). color= "Blue"; New Car (). Run; Three objects created

Functional function problems

Main () {Car c=new car (); Show (c);} public static void Show (Car c) {c.num=3;c.color= ' black '; C.run ();}

Parameter c is a copy, but because only one object is created, C actually contains pointers, and C and parameter C in the main function are all points to the heap control object.

  

Java Object-oriented concepts

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.