Java BASICS (8) Object-oriented (3) and java basics object-oriented

Source: Internet
Author: User

Java BASICS (8) Object-oriented (3) and java basics object-oriented

Here are some of the knowledge points and code I summarized in my previous class. Most of the notes I think are very good and classic, sincerely hope that these will help those who want to learn!

It is inconvenient to upload code by module. There are also many things, and they are also clear! If you need it, you can leave your email in the comments. I will certainly send it to you for free! Thank you for making progress on this platform !! Remember that programmers are selfless !!!

Also very welcome to my blog to watch blog address: http://www.cnblogs.com/duscl/

 

/* 1: How to Create a help document (understanding) (1) Write a class (2) Add a document comment (3) you can use the javadoc tool to generate the javadoc-d directory-author-version ArrayTool. java2: I learned how to use the Math class (mastery) (1) Application Programming Interface (help documentation) (2) through the APIS provided by JDK? See day08 \ code \ 02 _ How to use the help document provided by JDK \ for example, how to use help document .txt (3) Math class A: Class B for mathematical operations: No constructor, because all of its members are static C: generate a random number public static double random (): [0.0, 1.0) D: how to generate a random number between 1 and int number = (int) (Math. random () * 100) + 1; E: Number play Game 3: code block (understanding) (1) included in. (2) classification: A local code block is used to limit the lifecycle of A variable and release it early to improve memory utilization. B: Construct a code block. Put the same code in multiple constructor methods here. Before executing each constructor, run the constructor code block first. C: The static code block initializes the class data only once. (3) What are the sequence of static code blocks, construction code blocks, and construction methods? Static code block> construct code block> Construct Method 4: Inherit (master) (1) extract the same members of multiple classes and define them into an independent class. Then let these classes have a relationship with the independent class, and these classes have the content. This relationship is called inheritance. (2) How does one represent inheritance in Java? What is the format? A: using the keyword extends to represent B: Format: class subclass name extends parent class name {} (3) benefits of inheritance: A: Improves code reusability B: improved code maintainability C: the relationship between classes and classes is the premise of polymorphism (4) Disadvantages of inheritance: A: enhanced coupling of classes. In this way, changes to a class will affect other classes related to the class. Principle: low coupling and high cohesion. Coupling: the relationship between classes and classes cohesion: ability to accomplish something by yourself B: Breaking encapsulation (5) characteristics inherited in Java A: classes in Java only support single inheritance B: in Java, multi-layer (heavy) Inheritance (inheritance system) (6) Inheritance Note: A: subclass cannot inherit the private member B of the parent class: subclass cannot inherit the constructor of the parent class, but can access C through super: do not inherit for some functions (7) When Will Inheritance be used? A: inheritance represents the relationship between is. B: Use the hypothesis (8) Java inherited member relationship A: member variable a: The member variable name of the subclass is different from the member variable name of the parent class. This is too simple B: the member variable name of the subclass is the same as the member variable name in the parent class. How can this problem be accessed? The sequence in which the subclass method accesses the variables: locate the local range of the subclass method and use it if any. Find the member range of the subclass and use it if any. Find the member range of the parent class and use it if any. If it cannot be found, an error is returned. B: constructor a: the constructor of the subclass will access the non-argument constructor of the parent class by default. The constructor is used to initialize the data of the parent class for the subclass to access B: what should I do if there is no construction method without parameters in the parent class? The subclass uses super to explicitly call other constructor of the subclass with parameters and uses this to call itself. However, there must be a constructor that accesses the parent class so that the parent class can provide a non-constructor C: member method a: The member method of the subclass is different from 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 can this problem be accessed? Access the search sequence of A method through A subclass object: if A method is found in A subclass, it is used in the parent class. If A method is not found, an error is reported. (9) two questions:: what is the difference between Override and Overload? Can Overload change the return value type? B: What are the differences between this and super and their respective roles? (10) Data initialization interview question A: initialization process of A Class B: Construction and execution process of the sub-parent class C: hierarchical initialization (11) case:: b: Analysis and Implementation of the case study of cats and dogs *\

 

Related Article

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.