JAVASE basic knowledge Note 6

Source: Internet
Author: User

Java se Lesson 1
1. A class is an abstract concept. An object is a specific expression of a class.
Body concept. First, there is a class, and then the class will generate an Object ). Object again
It is called an Instance ).
2. A class consists of two parts: attributes and methods. Attributes are generally represented by nouns,
Methods are generally represented by verbs.
3. If multiple classes are defined in a java source file
One class can be public. In other words, multiple classes can be defined
Is public.
4. When passing method parameters in Java, no matter the native data class is passed
Type or reference type. pass by value is used for parameter transmission ).
There is no pass by reference concept in Java.
5. Method Overload ). Indicates that two or more methods have the same name,
The parameters are different. Different method parameters have two meanings: 1) the number of parameters is different.
2) The parameter types are different. Note: The Return Value of the method does not affect the overload.
.
6. overload of the constructor method: you only need to check the parameters. In a constructor
You can call another constructor using this (). this ()
Parameters in brackets indicate parameters of the target constructor. This () must be used as the structure
The first statement of the Creation method. In other words, there cannot be any execution before this ().
Line of code.
7. Inheritance: Java is a single inheritance, meaning that one class can only inherit from another class (the inherited class is called the parent class [base class, base class ].
Class), Java uses the extends keyword for inheritance.
8. When a subclass object is generated, Java first calls the structure of the parent class without parameters by default.
Method, and then execute the constructor to generate the object of the parent class. Next
Call the subclass constructor to generate the subclass object. [To generate a subclass
Object. First, you need to generate the parent class object. Without the parent class object, there is no subclass.
Object. For example, if there is no father, there will be no children ].
9. super Keyword: super indicates a reference to the parent class object.
10. If the subclass uses super () to explicitly call a constructor of the parent class
During execution, the constructor corresponding to super () will be searched, instead of going
Find the constructor without parameters of the parent class. Like this, super is required.
The first statement to be executed as the constructor. No other statements can be executed before.
Statement.
11. Inheritance:
A) There are parent classes and child classes.
B) if the parent class does not exist, the subclass can be added.
C) The parent class has some, and the subclass can be changed.
12. Notes on inheritance
A) constructor cannot be inherited
B) methods and attributes can be inherited.
C) The constructor of the subclass implicitly calls the constructor without parameters of the parent class.
D) when the parent class does not have a constructor without parameters, the subclass needs to use super to explicitly call the constructor of the parent class. super refers to references to the parent class.
E) The super keyword must be the first statement in the constructor.
13. Override (Override): it is also called overwrite. The method returned by subclass and parent classes
The same type, method name, and parameter are the same, so that subclass and parent
Class methods constitute the rewrite relationship.
14. Relationship between method rewriting and method overloading: overloading occurs within the same class
. Rewriting occurs between the parent class and the Child class.
15. When two methods form an override relationship, you can use
The run () method of the parent class is called in the form of super. run ().
In the first line of the statement, the parent class object has been constructed.
The run () method of the class or the run () method of the subclass is based on the Program Logic.
.
16. When defining a class, if the parent class of the class is not explicitly specified
This class will inherit from the java. lang. Object Class (a class provided by JDK, Object
Class is the direct or indirect parent class of all classes in Java ).
17. Polymorphism (Polymorphism): we say that child classes are parent classes (roses are flowers, male
People are people), so polymorphism means that the reference of the parent type can point to the subclass.
.

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.