Java object-oriented features description

Source: Internet
Author: User

Extends, implements, abstract and interface

Extends: inheritance, which corresponds to a class, cannot inherit two parents at the same time, just as a man cannot be two fathers at the same time.

corresponding to the interface, an object can be combined with multiple interfaces, just as a car is a combination of engine, wheel, etc.

Interface: interfaces, interfaces cannot be used directly, must be implemented before they can be used, cannot be inherited, and the methods inside the interface are abstract methods.

Implements: implementation, for the implementation of interface, interface must be implemented in order to use, just like the host mouse interface, you must implement the mouse to docking on the interface to use.

Abstract: Abstraction, abstract class is a kind of class, but must through subclass to implement abstract method, like bird is an abstract class, must inherit the bird as Eagle, Sparrow class or chicken class can be manifested.

Abstract methods, the same needs to be described in detail before the method can be used.

Override and Overload

Override: Override, override the method of the parent class, the parameter list of the method is consistent, the return type is consistent, and the method content is changed.

Overload: Overloads, that is, the same class, the method name, the parameters must be different, the return type can be different or the same.

Polymorphic:

Polymorphism is the same approach, with different implementations on different objects. Implemented by inheriting and overriding methods, and then pointing to the various child objects with references to the parent class.

Java object-oriented features description

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.