Review of Java object-oriented fundamentals

Source: Internet
Author: User

This keyword usage:
represents a reference to the current object, that is, when the member property and method are called, the object that is currently being called
calls another constructor method (which must be placed in the first row);

Super keyword
points to a pointer to its own (direct) parent class object. You can call the parent class's member properties and methods
Call one of the constructors in the parent class

Object-oriented three features:
Inheritance
Inheritance is the derivation of new classes from existing classes, which can absorb the data properties and behaviors of existing classes, and can extend new capabilities.
subclasses have properties and methods that are not private to the parent class
Java does not support multiple inheritance, the inheritance relationship is a generalization of the subclass that is passed, the subclass is the specialization (materialization) of the parent class
encapsulates the properties of the object, and the method describes the action of the Thing
The first abstraction, the abstraction of things into a class, followed by encapsulation, the properties and actions of the object to hide, only the specific methods to retain the external contact
Polymorphic
Methods of rewriting, overloading and dynamic connections constitute polymorphism;
for methods defined in the parent class, if the subclass overrides the The method, then a reference to the parent class type will call this method in the subclass, which is the dynamic connection.
Transform up (the reference of the parent object to the child class object), the downward transition (the parent object's reference is strongly turned into a subclass type)

access permission modifier:
Public: Classes under the same package and under different packages can access the
Protect: The same package can access the class, subclass  can access
Default: Classes under the same package can be accessed, subclasses cannot access
Private: Other classes cannot access the

static modifier
Static decorated content is subordinate to the class, not directly to the object's
Loaded with the load of the class, precedence over the existence of the object
Satic decorated members are shared by all objects of that type
can directly access the static member

final modifier
The final decorated value cannot be modified, the method cannot be overridden, The "macro substitution"/"macro variable" problem that the class cannot inherit after the
final modifier variable (at compile time the final variable can be replaced directly by its own value)
refers to the actual object, but it stores the address of the object being pointed to, so Its value cannot be modified and does not imply that the object it points to cannot be modified by

Abstract modifier: Decorated classes and methods
The abstract modifier class, which makes this class an abstract class, will not generate object instances
The abstract modification method, which makes this method an abstraction, is that only the declaration and not the implementation, requires the subclass to inherit the implementation.

Interface (interface)
Interface has no construction method
Interface supports multiple inheritance
The methods in the interface are implicitly specified as public abstract
The variables in the interface are implicitly specified as public static final

Inner class:
Local inner class
You can only use variables declared in methods as final types in the definition method.
Anonymous inner class
There are no class names, there are no keyword modifiers such as extends and implements.
Implicitly inherits a parent class, or implements an interface.
Static Inner class
Only static member variables and static methods of external classes can be accessed.
Declaring a method: (In a Class)
public static Class Innerclass
Build Method:
Outerclass.innerclass inner = new Outerclass.innerclass ();
member Inner class
You can access static and non-static methods and member variables for external classes.
Declaring a method: (In a Class)
public class Innerclass
Build Method:
Outerclass.innerclass inner = new Outerclass (). New Innerclass ();

Review of Java object-oriented fundamentals

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.