Recently began to organize the things you learn, to organize the object-oriented
What is object-oriented?
At first, "object-oriented" refers to the design method of encapsulation, inheritance and polymorphism in programming. Object-oriented thinking has been involved in all aspects of software development. For example, object-oriented analysis (Ooa,object oriented analyses), object-oriented designs (Ood,object oriented design), and the object-oriented programming implementations we often say (Oop,object oriented Programming).
What is polymorphic?
In object-oriented languages, many different implementations of interfaces are polymorphic. The description of polymorphism is referenced by Charlie Calverts--polymorphism is a technique that allows you to set a parent object to be equal to one or more of his sub-objects, and after assignment, the parent can operate differently depending on the attributes of the child object currently assigned to it (excerpt from the "DELPHI4 Programming Technology Insider" )。 In short, refer to the parent class reference to the Child class object
What is inheritance?
Inheritance is the inheritance of the attributes and methods of the parent class: The reusability of the code, the ability to extend the properties and methods of the parent class;
What is encapsulation?
Encapsulation is the encapsulation of internal properties, exposing only a subset of the interface to the consumer call. The integrity of the internal code is ensured. In general, we write good code to change a property value, it is best not to change the source code, but should be to call you start to write a method to change. So that's what I understand in encapsulation.
What are the advantages of object-oriented?
1. Easy Maintenance 2. High Quality 3. High efficiency 4. Easy to expand
Object-oriented disadvantages?
Lack of overall planning, easily lead to reasonable structure department
How is it reflected in the code?
Package Com.ehealth.obj;class cat{public Cat () { System.out.println ("This is a cat."); public void Call () { System.out.println ("...."); }} public class Objtest {public static void Main (string[] args) { cat c=new cat (); C.call (); }}
this keyword
Points to the current object this can also be used to call other constructors of the current object.
Static keyword
Static objects, which are initialized the first time the object is created. belongs to the public area of the class.
Super keyword
Using super in a constructor means using the constructor of the parent class. When the call is not displayed, it means that the parent class's parameterless constructor is called by default. If the parent class does not have a parameterless constructor, an error occurs. All classes inherit a class with object.
Inheritance and Permissions
Inheritance is using the extends keyword public: All places are visible private: all places are invisible Protect: Subclass visible Default:: Same package visible
Overloading and rewriting
Overloading: The method name is the same as the parameter overrides: The method name must be the same as the parameter and return type.
This article from "ehealth" blog, declined reprint!
Java Learning notes----facing objects