20172325 2017-2018-2 "Java Programming" Eighth Week study summary

Source: Internet
Author: User

20172325 2017-2018-2 "Java program design" Eighth Week study summary textbook study summary

1. About Bindings

    • Binding: A request event is generated when executing a program, and a piece of code is executed to complete the method invocation, a binding of a method invocation to a method definition.
    • Post-bind: Post-bind is the case of delayed binding. (The efficiency of the post binding is lower than the binding efficiency of the compile phase)

2. Implementation of polymorphism by inheritance

    • A reference variable can point to any object of any class that is inherited from the relationship;
    • The actual version of the method that will be called depends on the type of the object and not the type of the reference variable;

3. Using interfaces for polymorphism

    • An interface reference variable can point to any object of any class that implements the interface.
    • When you use an interface to reference a variable, you can only invoke methods defined in the interface, others are not callable, and if such a method call is known to make sense, you need to convert the object type
    • The interface name can also be used as the type of a method parameter, so that any class object that implements the same interface can be passed as a parameter to the method.

4. Sorting

    • There are two methods for sorting, selective sorting and insertion sorting
    • Selective sorting: Scans the entire sequence to find the minimum value and exchange it with the value of the first position in the sequence, so loop until the sequence is sorted.
    • Insert sort: From left to right the first sort starts with the second number, compared to the previous number, and the insertion is repeated in the appropriate position in the previous number.
    • Comparison: The efficiency of the two is the same, but the number of actual exchanges of the selection method is less than the insertion method, so the selection method will be better if you choose between the two.

5. Search

    • Linear search: Starting from an endpoint, scanning the entire search pool in a linear fashion, in order to search sequentially, in the traditional sense.
    • Binary search: A group of data that has been sorted by binary search, separated from the middle, looking for more close to the target interval, and finally reach the search target.
    • Comparison:
      (1) binary search is based on the premise that the data has been sorted, if not sorted, then consider the choice of linear search.
      (2) Under the premise of satisfying the binary search, if the amount of data is large, the two-point search may take less time, that is, more efficient.
      (3) The binary efficiency is higher when the data has been sorted (ascending or descending), and the linear efficiency is higher when the array form is present.
Problems in teaching materials learning and the solving process
    • Issue 1: The method version that is actually called depends on the type of the object and not the type of the reference variable. What's the meaning of this remark?
    • Question 1 Solution: Ask the seniors, and specifically do the following one of the experiments, can be more clearly explained this sentence.
      ···
      public class Polymorphism {
      public static void Main (string[] args) {
      Since it is polymorphic, the overloading and rewriting in Java is a manifestation of polymorphism, and the words you ask are certainly not overloaded and are explained by rewriting.
      This declares a gun, the variable is gun, but he points to a Ak47 object, that is, although the gun is a reference to the gun, but is actually a Ak47 object
      So Gun.shot actually calls Ak47.shot instead of the gun's own shot
      Gun gun = new Ak47 ();
      Gun.shot ();
      }
      }
      Class Gun {
      public void shot () {
      SYSTEM.OUT.PRINTLN ("Sudden!");
      }
      }
      Class Ak47 extends Gun {
      public void shot () {
      System.out.println ("Sudden, sudden, sudden!");
      }
      ···}
    • Issue 2: Polymorphism of interfaces that part of the understanding is not very good
    • Question 2 Solution: When looking for information, I found a question and answer, although there is no specific guide to the code in the problem, but according to their question and answer is really good to help me understand the interface to achieve polymorphism.



      Connection of the problem
Problems in code debugging and the resolution process
    • Question 1:xxxxxx
    • Issue 1 Solution: XXXXXX
    • Question 2:xxxxxx
    • Issue 2 Solution: XXXXXX
    • ...
Code Hosting

Script

Last week's summary of the wrong quiz
    1. Inheritance through an extended (derived) class supports which of the following concepts?
      A. Interfaces
      B. Modulary
      C. Information hiding
      D. Code reuse
      E. Correctness
      Resolution by extending a class and inheriting it, the new class does not have to re-implement any of these inherited methods or instance data, thereby saving the programmer's workload. Therefore, code reuse is the benefit of extending it for your needs and reusing other code.
  • 2. A variable declared to being of one class can later reference an extended class of the that class. This variable is known as
    A. Protected
    B. Derivable
    C. Cloneable
    D. Polymorphic
    E. None of the above, a variable declared to being of one class can never reference any other type of class, even an extended CL The
    Parsing: Polymorphism means that variables can take many forms. In the ordinary case, Java is strongly defined, that is, once a variable declared as a type is never changed to a different type. This is an exception, and a polymorphic variable can be any type of derived class (although not at the same time, a variable can be changed from one type to another).
    Reason: Failed to correctly understand test instructions, thought to be what type before the variable.
    1. Which of the following is an example of multiple inheritance?
      A. A computer can be a mainframe or a PC
      B. A PC can be a desktop or a laptop
      C. A laptop is both a PC and a portable device
      D. A portable device is a lightweight device
      E. Macintosh and IBM PC is both types of PCs
      Resolution: Multiple inheritance means that a given class inherits multiple parent classes. In those listed above, laptops inherit the features from PCs and portable devices. The answer in a, B and E is an example of a single inheritance in which a class has at least two children (in a, the computer has a children's mainframe and PC,B,PC has children's desktops and laptops, E,PC has children's Macintosh and IBM PCs). Answer d represents a property of a class.
    1. In order to determine the type of a polymorphic variable refers to, the decision is made
      A. By the programmer at the time of the program is written
      B. By the compiler at compile time
      C. By the operating system, the program was loaded into memory
      D. By the Java run-time environment at run time
      E. By the user at run time
      Analysis: This topic is asked at what stage to determine the type of polymorphic variables referenced, which is also part of the tenth chapter content. For this kind of request in most cases, this binding occurs during the compilation phase, but for polymorphic references, this binding is deferred until the program runs to execute, and the method to bind depends on the object referenced by the reference variable at that time, which is called a post-bind or dynamic binding.

      Pairing and mutual evaluation
Reviews Template:
    • Blogs that are worth learning or questions:
      • Xxx
      • Xxx
      • ...
    • Something worth learning or doing in your code:
      • Xxx
      • Xxx
      • ...
    • Based on the scoring criteria, I scored this blog: xx points. The score is as follows: XXX

    • Reference example

reviewed the classmates blog and code
    • This week's study of the knot
      • Pair of students study No. 1
      • Pair of photos
      • Pairs of learning content
        • Xxxx
        • Xxxx
        • ...
    • Last week's blog comments on the situation (as long as the link, specific reviews put the corresponding blog)

      • Study No. 1

# # Learning Progress bar

lines of code (new/cumulative) Blog Volume (Add/accumulate) Learning Time (new/cumulative) Important Growth
Goal 5000 rows 30 Articles 400 hours
First week 200/200 2/2 20/20
Second week 300/500 2/4 18/38
Third week 500/1000 3/7 22/60
Week Four 300/1300 2/9 30/90
Resources
    • Java Learning Notes (8th Edition)

    • Java Learning Note (8th Edition) Learning Guide
    • ...

20172325 2017-2018-2 Java programming Eighth week of study summary

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.