Object-Oriented Programming (2)

Source: Internet
Author: User

Java Naming conventions: capitalize the first letter of the classThe first letter of the variable name and method name should be lowercase using the hump mark

A variable of the underlying type consumes only one stack of memory in memory. A variable of reference type has a pointer-like stack memory in memory and a heap memory. One of the methods in Java can be called only through an actual object

The overloads of a method are multiple methods in a class that can be defined with the same method name, but with different parameters. A method name, like a parameter name, does not constitute an overload unless the return value is different.

Use the new keyword to create an object. Each object of the same class has a different storage space for member variables. Each object of the same class shares its methods. A non-static method is called on an object.

The This keyword is a reference to itself. This can be seen as a variable, and the value is a reference to the current object.

Static keyword static member variable only one, all methods common one static variable.

The overriding method must have the same method name, parameter list, and return value as the overridden method. The overriding method cannot use more restrictive access than the overridden method.

This is a reference to the current object. Super is a reference to the inherited parent class in the current object.
During the construction of a subclass, you must call the construction method of its parent class. If super is used, it must be written at the top of the subclass construction method. If the subclass constructor method does not explicitly call the base class construction method, and there is no parameterless constructor in the base class, the compilation error occurs.

The two classes that use = = Compare the addresses of the two classes, and the result will always be false if the addresses are not equal to each other. The default equals and = = Effect are the same.

Dynamic binding and polymorphic and late binding in Java are a concept. Dynamic binding refers to the actual type of the referenced object that is judged during execution, and its corresponding method is called according to the actual type.

Three prerequisites for polymorphism: 1, to have inheritance. 2, to have a rewrite. 3. The parent class reference points to the subclass object.

When you decorate a class with the abstract keyword, this class is called an abstract class. When using abstract to modify a method, this method is called an abstract method. This method or class is defined as an abstract class when a method or class needs only a definition that does not need to be implemented. When a class contains abstract methods, the class must be declared abstract. Abstract classes cannot be instantiated and can not be created by new.

Object-Oriented Programming (2)

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.