Java Chinese document production and inheritance

Source: Internet
Author: User

1: How to make a Help document (learn)
(1) Write a class
(2) Adding documentation comments
(3) can be generated by Javadoc tool
javadoc-d Directory-author-version Arraytool.java
2: Learning the Math class from the API provided by the JDK (master)
(1) API (Application Programming Interface)
Application programming Interface (Help documentation)
(2) How to use it?
Please refer to
Day08\code\02_ How to use the Help document provided by the JDK \ How to use the Help document.
(3) Math class
A: A class that operates on mathematics
B: There is no construction method, because its members are static
C: Generate random numbers
public static Double Random (): [0.0,1.0]
D: How to generate a random number between 1-100
int number = (int) (Math.random () *100) +1;
E: Guess number Games
3: Code block (understanding)
(1) code enclosed in {}.
(2) Classification:
A: Local code block
used to limit the life cycle of variables, release early, and improve memory utilization.
B: Building blocks of code
The same code in multiple construction methods can be put here, before each construction method executes, the construction code block is executed first.
C: Static code block
initializes the data for the class and executes only once.
(3) static code block, construct code block, construct method order problem?
static code blocks > Constructing code blocks > Construction Methods

4: Inheritance (Mastery)
(1) The same members in multiple classes are extracted to define a separate class. Then let the multiple classes and the independent class produce a relationship,
These are the things that these classes have. This relationship is called inheritance.
(2) How is inheritance represented in Java? What is the format ?
A: Use keyword extends to express
B: Format:
Class subclass name extends parent class name {}
(3) Benefits of inheritance:
A: Improved reusability of the Code
B: Improved maintainability of the Code
C: Let the class and the class have a relationship, is the precondition of polymorphism
(4) Disadvantages of inheritance:
A: To enhance the coupling of the class. Such a change in a class will affect other classes related to that class.
principle: Low coupling, high cohesion.
coupling: Class-to-Class relationships
the ability to accomplish something by oneself
B: Breaking the encapsulation
(5) Characteristics of inheritance in Java
The A:java class only supports single inheritance for single-inheritance----> Classes
Multi-layer (heavy) inheritance in B:java (inheritance system)------> Interface Multiple Inheritance
(6) Considerations of succession:
A: Subclasses cannot inherit private members of parent class
B: Subclasses cannot inherit the constructor of a parent class, but can access it through Super
C: Do not inherit for part of the function
(7) When do I use inheritance ?
A: Inheritance embodies: is a relationship.
B: Using the Assumption method
(8) member relationships in Java inheritance
A: member variables
A: The member variable name of the subclass is not the same as the member variable name in the parent class, this is too simple
B: The member variable name of the child class is the same as the member variable name in the parent class, how is this accessed?
the method of the subclass accesses the lookup order of the variables:
find the local scope of the subclass method and use it.
in the subclass of the member scope to find, there is the use.
in the member scope of the parent class, it is used.
If you can't find it, you'll get an error.
B: Construction Method
A: The constructor of a subclass is accessed by default to access the parent class's parameterless construction method
is for subclasses to access the initialization of the parent class data
B: What if there is no parameterless construction method in the parent class?
subclasses explicitly invoke a parameter construct with super
subclasses use this to invoke other constructs of their own, but there must be a construct that accesses the parent class .
to have the parent class provide an argument-free construct
C: Member Method
A: The member method of the subclass is not the same as the member method name in the parent class, this is too simple
B: The member method of the subclass is the same as the member method name in the parent class, how is this accessed?
to access the lookup order of a method through a subclass object:
look in the subclass and use it.
Look in the parent class and use
If you can't find it, you'll get an error
(9) Two face questions:
the difference between A:override and overload? Can overload change the return value type?
What are the differences between B:this and super and their respective roles?
(10) data initialization of the face question
A: Initialization process for a class
B: The construction of the child parent class execution Process
C: Hierarchical Initialization

Java Chinese document production and inheritance

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.