"Java programming" Object oriented OOP (i)

Source: Internet
Author: User

Object-oriented concepts:

-----------------------

Object-oriented programming Oop:object oriented programming

Process-oriented Programming ooa:oriented object analyze

Object-oriented design ood:oriented


Object:

Class:


Package: Encapsulation

Inheritance: Inheritance

Polymorphic: Polymorphism


Attribute (member variable):

Behavior (member function):


Heap: Heap

Arrays and objects in the heap

Stack: Stack

Method in the Stack



Member variables:

---------------

Member variables are defined in the class and can be accessed throughout the class.

Member variables are established with the creation of an object and exist in the heap memory where the object resides.

The member variable has a default initialization value of NULL, or you can specify a default value



Local variables:

---------------

Local variables are defined only in local scopes, such as within functions, within statements, and so on.

Local variables exist in the stack memory.

The scope of the action ends, and the variable space is automatically freed.

Local variables do not have default initialization values.


constructor function:

---------------

Characteristics:

The function name is the same as the class name

Do not define return value types

There is no specific return value, and the object is definitely returned after creation.

If the class does not have a constructor defined, the JVM allocates an empty construct.

If the class defines a constructor, there is no empty construct.

Role:

Initializes the object.

Attention:

The characteristics of the default constructor.

Multiple constructors exist in the form of overloading.


Code block:

--------------------

Defined:

The code uses a separate {} enclosing content.

Classification:

To construct a code block:

One of the members of the class

Use a section of code enclosed in {}

When an object is created, it is called before the constructor.

Local code block:

Code blocks defined within a method

Static code block:

Constructs a block with the static decorated code, which is called once when the class is loaded and is no longer called. The initialization process for static member variables is usually placed.

"Java programming" Object oriented OOP (i)

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.