Three characteristics of object-oriented

Source: Internet
Author: User

Packaging

Actually use methods to hide the data of a class and control the user's permission to modify and access the class.

Encapsulation is an information hiding technology that is encapsulated in Java through the keyword private .

Inherited

Using existing classes as the basis for building new classes, the definition of new classes can add new data or new functionality, or use the functionality of the parent class, making it easy to reuse the original code and greatly shorten the development cycle.

public class Animal {private  int: age;  String sex= "Femaleanimal";  protected void Sleep () {  System.out.println ("I can Sleep");  }  Public Animal () {  System.out.println ("This Is super Class (Fulei)");  }  void Eat ()  {  System.out.println ("I can Eat");  }  void Call ()  {  System.out.println ("--------------");  }  } Class Dog extends animal{public   Dog () {}void call () {//TODO auto-generated Method Stub System.out.println ("------- -wangwang------");}} Class Cat extends animal{   void call () {  System.out.println ("-----miaomiao---------");}}

Polymorphic

Multiple word classes inherit common parent classes, defining references that use the same parent class to point to different child class objects

Coercion type conversion with instanceof keyword

Instance of means that an object is an instance of a class.

Three characteristics of object-oriented

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.