20172332 2017-2018-2 "Program Design and Data Structure" Week 8 Learning Summary

20172332 2017-2018-2 "Program Design and Data Structure" Week 8 Learning Summary

Textbook learning content summary

Chapter 10 Polymorphism

  • 1. Post binding.
    • The efficiency is lower than the binding efficiency at compile stage.
  • 2. Use inheritance to achieve polymorphism.
  • 3. Use interfaces to achieve polymorphism.
  • 4. Sort.
    • Sort by selection. (scan from left to right to the smallest number)
    • Insertion sort. (select the numbers in turn and compare them with the previously arranged numbers and insert them)
    • All things considered, the selection method is better than the insertion method.
  • 5. Search.
    • Linear search.
    • Binary search. (must be in order)
    • The efficiency of binary search is higher than that of linear search, but the implementation of linear search is simpler than binary search.
  • 6. Polymorphic design (multiple different objects perform the same basic behavior, and the behavior is implemented differently depending on the specific type of the object.)

Problems and Solving Processes in Teaching Materials Learning

  • Question 1: How to get the middle value if the number of elements in the array is even in binary search?
  • Solution to problem 1: Select the middle two values, add them and divide by 2, and then round up to the middle value for comparison.
  • Question 2: How to understand this instantiation statement, such as Speaker current = new Philosopher() ;?
  • Solution to problem 2: This is related to polymorphism, which can be understood as defining a class Philosopher that implements the Speaker interface, and then assigning the Philosopher object (that is, current) to the Speaker interface reference variable.

Problems and solutions in code debugging

  • Question 1: The reason for the red line

  • Solution to problem 1: The interface can only be implemented in the class, not in the main function.

code hosting

Summary of last week's exam mistakes

1.Abstract methods are used when defining

  • A . interface classes
  • B . derived classes
  • C . classes that have no constructor
  • D . arrays
  • E . classes that have no methods
  • Answer: A; I chose: E
  • Analysis: The interface is full of abstract methods.
  • Words: 1. derived : inheritance.

2.A variable declared to be of one class can later reference an extended class of that class. This variable is known as

  • A . protected
  • B . derivable
  • C . cloneable
  • D . polymorphic
  • E . none of the above, a variable declared to be of one class can never reference any other type of class, even an extended class
  • Answer: D; I chose: A
  • Analysis: This question is related to polymorphism. I didn't learn it at the time. Now that I have finished polymorphism, it is easy to understand. (The simple understanding is that a variable of type A can use the method of type B.)
  • Words: 1. polymorphic : Polymorphism.

3.In order to determine the type that a polymorphic variable refers to, the decision is made

  • A . by the programmer at the time the program is written
  • B . by the compiler at compile time
  • C . by the operating system when the program is loaded into memory
  • D . by the Java run-time environment at run time
  • E . by the user at run time
  • Answer: D; I chose: A
  • Analysis: A polymorphic variable can take many different types, but it is not known what type it takes before executing the program. When referencing a variable, a decision must be made. This decision is made by the runtime environment based on the latest assignment of the variable.
  • Words: 1. compiler : Compiler.

Reviewed classmates blog and code

Others (perception, thinking, etc., optional)

  • Sorting and searching in this week's content are mentioned in the video when learning arrays, so it's not difficult to understand. As for the knowledge about polymorphism, it may be used, but it is not very understandable.

learning progress bar

Lines of code (added/accumulated) Blog volume (new/cumulative) Study time (added/accumulated) important growth
Target 5000 lines 30 articles 400 hours
the first week 182/182 1/1 10/10
the second week 458/640 1/2 15/25
The third week 469/1109 2/4 18/43 Learn to use and debug IDEA, and learn to debug jdb.
the fourth week 1536/2645 1/5 24/67
fifth week 980/3625 1/6 25/92
Week 6 870/4495 1/7 16/108
Week 7 455/4950 2/9 22/130
eighth week 1322/6272 2/11 28/158
  • Planned study time: 20 hours

  • Actual study time: 28 hours

  • Improvement situation: There are four arithmetic projects starting this week, so I spend more time in java learning, so I have one more blog.

References

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325163923&siteId=291194637