JAVA SE Lesson 1

Source: Internet
Author: User
Tags java se

1. A class is an abstract concept in which an object is a concrete representation of a class and is a concrete concept. There is a class first and then the object is generated by the class. The object is also called an instance (Instance).
2. The class consists of two parts: attributes and methods. Attributes are generally represented by nouns, and methods are generally expressed by verbs.
3. If multiple classes are defined in a Java source file, there can be at most one class in the class that is public, in other words, multiple classes defined may not be public.
4. In Java, when the parameters of a method are passed, regardless of whether the native data type or reference type is passed, the parameter is passed uniformly as a pass value (pass by value).
There is no concept of pass by reference in Java.
5. Method overloading (overload). Indicates that two or more methods have the same name, but the method parameters are different. The method parameter has two layers meaning: 1) The number of parameters is different.  2) parameter types are different. Note: The return value of the method has no effect on overloading.
6. Construction method Overloading: Just look at the parameters. if you want to invoke another constructor method in a constructor, you can call it by using this (), which represents the parameters of the target constructor method. This () must be used as the first statement of the constructor method, in other words, this () cannot have any executable code before it.
7. Inheritance (inheritence): Java is single-inheritance, meaning that a class can only inherit from another class (The inherited class is called the parent class "base class", the inherited class is called the subclass), and the inheritance in Java uses the extends keyword.
8. When a subclass object is generated, Java defaults to calling the parent class's constructor without arguments, and then executes the constructor to generate the object of the parent class. Next, the constructor of the subclass is called, and the object of the child class is generated. "To create an object of a subclass, you first need to generate the object of the parent class, and there is no child class object without the parent class object." For example: Without a father, there is no child ".
9. Super Keyword: Super represents a reference to the parent class object.
10. If a subclass uses super () to explicitly invoke a constructor method of the parent class, it will look for the constructor that corresponds to super () and will not look for the constructor of the parent class without parameters. As with this, super must also be the first execution statement of the constructor method, and no other executable statement can be preceded.
11.3 points on inheritance:
a) There is a parent class, and subclasses have
b) No parent class, subclasses can increase
c) The parent class has, subclasses can change
12. Considerations Regarding Inheritance
a) The construction method cannot be inherited
b) Methods and properties can be inherited
c) The constructor method of the subclass implicitly calls the parent class's constructor without arguments
D) When the parent class does not have a constructor method with no arguments, the subclass needs to use super to explicitly call the parent class's constructor, and super refers to a reference to the parent class

e) The Super keyword must be the first line statement in the constructor method.

13. Method override (Override): Also called overwrite, the subclass is the same as the method return type of the parent class, the method name is the same as the parameter, so we say that the child class and the parent class's methods constitute an overriding relationship.

14. Method overrides relationship to method overloads: Overloads two or more methods that occur inside the same class. Overrides occur between the parent class and the child class.
15. When two methods form an overriding relationship, the run () method of the parent class can be called through Super.run () in the subclass method, where Super.run () does not have to be placed in the first line of the statement, so the parent class object is already constructed and the parent class's run () is called first method or the run () method that calls the subclass first is determined by the logic of the program.
16. When defining a class, if the parent class of the class is not explicitly specified, then the class inherits from the Java.lang.Object class (a class provided by the JDK, the Object class is the direct or indirect parent of all classes in Java).
17. Polymorphism (polymorphism): We say that the subclass is the parent (the Rose is the flower, the man is the man), so the polymorphic means: the reference of the parent type can point to the object of the child class.

JAVA SE Lesson 1

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.