Object-Oriented Programming (2) -- objects and classes, object-oriented programming objects

Source: Internet
Author: User

Object-Oriented Programming (2) -- objects and classes, object-oriented programming objects
Concepts of objects and Classes

  • Object: a specific thing;
  • Class: abstract)

First, there are specific objects, then abstract the image parts of each object, and summarize the classes. Then, we can review other objects through the classes.

Summary of objects and Classes

Relationship between objects and classes: special to general, specific to abstract

  • Class, which is called Class;
  • Objects are called objects and instances. In the future, we will talk about objects of a class and instances of an Object.
  • Class, can be seen as a Class Object template, the object can be seen as a specific instance of this class.
  • A class is an abstract concept used to describe objects of the same type. The class defines the static and dynamic attributes of this class of objects.
  • Objects are the core of Java programs. in Java programs, "Everything is an object ".

Reference)

In Java, variable types except basic types are called reference types.

Ps: describes the following data types:

Basic data types (8 types ):

Numeric type: INTEGER (byte, short, int, long) floating point type (float, double)
Character Type: char
Boolean: boolean
Reference Type:

Class: class
Interface: interface
Array

Objects in Java areReferenceTo operate on it.

Class has attributes and method composition class attributes
  • Attribute field, or member variable
  • Attribute is used to define the data or static attributes contained in this class or this class object.
  • The attribute applies to the entire class body.
  • You can initialize a member variable when defining it. If it is not initialized,Java uses the default value for initialization.. (Value: 0, 0.0; char: \ u0000; boolean: false; all reference types: null)

Attribute Definition Format:

Class Method
  • In object-oriented, the basic unit of the entire program is class, and methods are subordinate to class

Method Definition Format

In Java, the method parameters are passed as follows:Value Transfer!

Variable Scope

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.