Java Course: 2.java Object-oriented

Source: Internet
Author: User

1. What is an object? An object is an instance of a class, a new object is created, and a different attribute is given to the object to materialize it. A class can have more than one object, an object can call a number of different methods, the equivalent of a dog-given calls, wagging the tail and so on. 2. Object-oriented and process-oriented differences:* The process emphasizes behavior, which is to analyze the steps needed to solve the problem, and then use the function to implement these steps one step at a time. * Object-oriented is based on process-oriented, constituting the problem transaction into individual objects, the object is not to complete a step, but to describe something in the whole problem-solving steps of the behavior.
  process-oriented object-oriented
design ideas top down, hierarchical, decomposition bottom-up, object, synthetic
Program Unit Function module Object
Design method program  =  algorithm  +  data structure program  =  object  =  data  +  method
advantages Independent, code-sharing approach to the way people think simulation of the objective world
Disadvantages inconsistent data and programs Maintenance Difficulties the disordered nature of the objective world The concept is immature
3. There are three main characteristics of object-oriented:* Inheritance is the technique of building a new class using the definition of an existing class, inheriting the method number or variable of the parent class, calling (inheriting: the subclass name +extends+ the parent class name) under the modifiers allowed, and invoking the parent class's method with the object of the subclass. Method overrides the method in the parent class after the output call is overridden by the method of the subclass, the variable cannot be overridden (overwritten), and the concept of "overriding" is only for methods. rewrite: Shift+alt+s selects the return Super.foots () that appears in the program of the Override/implenment methods class, meaning that the method of executing the parent class will output two values without deleting the words. Overrides are variable and method names unchanged, others can be changed.
* Encapsulation: wrapping something together and presenting it in a new and complete form;
the process of hiding properties, methods, or implementation details is called encapsulation;
encapsulation is a matter of selectively exposing or hiding certain information, which solves the problem of data security.
* Polymorphism: The rewriting of methods, overloading and dynamic connections constitute polymorphism. Polymorphism is also divided into design-time polymorphism and run-time polymorphism. Overloading is run-time polymorphic, and overrides are compile-time polymorphism.

Java Course: 2.java 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.