Java Classes and objects (i)

Source: Internet
Author: User

Object-oriented Basic concepts

Object-oriented is a new method of program design, or a novel program design specification, its basic idea is to use object, class, inheritance, encapsulation, message and other basic concepts to design. It constructs the software system from the real world objective objects (i.e. object), and uses the human natural thinking mode as far as possible in the system construction.

Object: An object is an entity used in the system to describe an objective thing, which is a basic unit of a system. Objects consist of properties and a set of services that manipulate properties.

Class: Many things are summed up, divided into some is the human in the understanding of the objective world is often used by the way of thinking. The principle of classification is abstract. A class is a collection of sets of objects with the same properties and services, providing a uniform abstract description of all objects that belong to the class, including properties and two main parts of the service. In an object-oriented programming language, a class is a stand-alone program unit that should have a class name and consist of two main parts: a property description and a service description. The relationship between a class and an object is like the relationship between a mold and a casting, the result of the instantiation of the class is the object, and the abstraction of a class of objects is the classes.

Message: A message is a service request made to an object that includes the object identity, service identity, input information, and answer information of the service. Services are often referred to as methods or functions.

Basic object-oriented features:

1, encapsulation: The object's attributes and services into a separate unit of the same, and as far as possible to hide the internal details of the object.

2, Inheritance: The special class of the object has its general class of all the properties and services, called the special class to the General class inheritance. For example: Passenger ships can inherit from ships, adults can inherit from humans. In addition, a class can inherit properties and services from multiple generic classes, called multiple inheritance. In Java, the general class is usually called the parent class (superclass, superclass), and the special class is a subclass (subclass).

3. Polymorphism: When a property or service defined in a generic class is inherited by a special class, it can have different data types or behave differently, which makes the same property or service have different semantics in the generic class and its various special classes. For example, the drawing method for geometry, ellipse and polygon are subclasses of geometry, and the drawing method functions differently.

Java Classes and objects (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.