20172306 "Java programming and data structure" eighth week learning summary

20172306 "Java Programming" Week 8 Learning Summary

Textbook learning content summary

 第十章最开始自己看的时候,没怎么看懂,等老师讲完之后,又看了一遍,就理解了很多。第十章主要学习了以下几点:

1. Memory for several conceptual contents: polymorphic references can point to different types of objects over time; a reference variable can be declared with a class name and an interface name, etc.
2. The reason for the inefficiency of dynamic binding is that it is done during program execution.
3. Polymorphism is achieved by inheritance and interface: I think according to my understanding, when other classes inherit the parent class or use the interface, when we call the method, it depends on the situation.
4. Selective and insertion sorting: I wrote a specific understanding of this in my last blog. ( http://www.cnblogs.com/lc1021/p/8969199.html )
5. Linear and binary search: Linear is to search one by one from left to right. Binary search is similar to the binary method in high school mathematics. The time is the same, they are all searched from the middle, and the scope is constantly narrowed.

Problems and Solving Processes in Teaching Materials Learning

  • Question 1: I think the content of binding in the book is not clear enough. I can only understand it simply by knowing that the efficiency of post-binding (dynamic binding) is lower than that of the compilation phase, and post-binding occurs in the compilation phase. .
  • Solution to problem 1: I mainly found some statements about binding in Java on the Internet. Binding is divided into static binding and dynamic binding. The popular understanding of static binding is that you already know which class the method is in the compilation process. The methods in java are only final, static, private and constructors are early binding; dynamic binding is also called post binding. , the compiler still does not know the type of the object at this time, but the method invocation mechanism can investigate by itself and find the correct method body. This is the blog I refer to ( https://blog.csdn.net/zhangjk1993/article/details/24066085 ). I think this blog's explanation of binding is more detailed and easy to understand.
  • Question 2: In binary search, segments will start from the middle, just like binary in mathematics, but if all permutations are even, so there is no number in the middle, what should I do in this case?
  • Solution to problem 2: This problem is that I didn't read the book carefully enough, and later found out what to do in this case in the book. The fractional part should be ignored and the first of the two midpoints should be taken as the new midpoint. Then keep searching.

Problems and solutions in code debugging

  • Question 1: When I was working on PP10.4, I initially thought that I only needed to change the code of movies, and other referenced classes did not need to be changed, so I started like this

  • Solution to Problem 1: This quickly became a problem, because it was found that our Contact is for the first and last name, which is obviously not recognized in the DVD. Therefore, we not only have to change movies, but also rewrite their corresponding classes. The corresponding classes are DVD, DVDCollection and Sorting. And something should be added to these classes accordingly to satisfy the concatenation between these classes.
  • Question 2: Still the code of PP10.4, I made the following additions in DVD, DVDCollection and Sorting. But there is such a problem

  • Problem 2 solution:

code hosting

Summary of last week's exam mistakes

  • 1.Which of the following is an example of multiple inheritance?
    AA computer can be a mainframe or a PC
    BA PC can be a desktop or a laptop (a personal computer can be a desktop computer or a laptop computer)
    CA laptop is both a PC and a portable device (a laptop is both a personal computer and a portable device.)
    DA portable device is a lightweight device )
    E Macintosh and IBM PC are both types of PCs Of those listed above, a laptop inherits some properties from personal computers and portable devices. The answers for A, B, and E are all examples of single inheritance, where a class has at least two children (in A, the computer has the children host and PC, in B, the PC has the children desktop and laptop, and in E, the PC There are child Macintosh and IBM PC). Answer D represents an attribute of a class. Here is mainly to distinguish the concept of multiple inheritance.
  • 2.If a programmer writes a class wanting it to be extended by another programmer, then this programmer must (if a programmer writes a class wanting it to be extended by another programmer, then this programmer must)
    A change private methods and instance data to be protected
    B change public methods and instance data to be protected
    C change all methods to be protected The method becomes protected)
    D change the class to be protected
    E none of the above, the programmer does not have to change anything The knowledge in the book is my general idea.
  • 3.Abstract methods are used when defining
    A interface classes (interface class)
    B derived classes (derived class)
    C classes that have no constructor (class without constructor)
    D arrays (array)
    E classes that have no methods (a class without methods) An interface for this topic is a class that defines some of its components, but leaves other components (methods) for you to implement. Therefore, these components (methods) are called abstract and defined as abstract in the interface class.
  • 4.Which of the following is true regarding Java classes? Which of the following is true regarding Java classes?
    A All classes must have 1 parent but may have any number of children (derived or extended) classes
    B All classes must have 1 child (derived or extended) class but may have any number of parent classes
    C All classes must have 1 parent class and may have a single child (derived or extended) class
    D All classes can have any number (0 or more) of parent classes and any number of children (derived or extended) classes (all classes can have any number (0 or more) of parent classes and any number of child (derived or extended) classes)
    E All classes can have either 0 or 1 parent class and any number of children (derived or extended) classes The question is basically understood, that is, there is ambiguity in the question of the Object class
  • 5. A variable declared to be of one class can later reference an extended class of that class. This variable is known as a variable declared as a class can later reference an extended class of that class. This variable is called
    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 The term indicates that variables can take many forms. In general, Java is strongly defined that a variable, once declared as a type, can never be changed to a different type. The only exception is that a polymorphic variable can be a derived class of any type (although not at the same time a variable can be converted from one type to another).
  • 6. 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 Java E by the user at run
    time A polymorphic variable can have many different types, but it doesn't know which type it takes until the program executes. When this variable is referenced, a decision must be made. This decision is made by the runtime environment based on the most recent assignment to the variable.
  • 7.Using the reserved word, super, one can
    A access a parent class'constructor(s)
    B access a parent class'methods and instance data to access the parent class' methods and instances Data
    C access a child class'constructor(s)
    D access a child class'methods and instance data
    E none of the above E super provides a mechanism to Access the methods and instance data of the parent class (whether they are hidden or not). Additionally, super can be used to access the superclass's constructor(s). So the correct answer is a combination of A and B which is not an option so the correct answer is E.

  • 8.Interface classes
    can not be extended but classes that implement interfaces can be extended. An interface, or implementing an interface, or neither. The only exception is if the class is explicitly modified with the word "final", in which case it cannot be extended.
  • 9.A derived class has access to all of the methods of the parent class, but only the protected or public instance data of the parent class. or public instance data.)
    A true
    B false This question chooses B Since methods can also be declared private, any private method cannot be accessed by derived classes. Therefore, the derived class can only access the protected public methods and instance data of the parent class.
  • 10.If class AParentClass has a protected instance data x, and AChildClass is a derived class of AParentClass, then AChildClass can access x but can not redefine x to be a different type. (If class AParentClass has a protected instance data x, and AChildClass is a class of derived classes, then AChildClass can access x, but cannot redefine x to another type.)
    A true
    B false B The derived class can redefine any instance data or method of the parent class. The version of the parent class is now hidden, but can be accessed by using super, just like in super x.

  • 11.Although classes can be inherited from one-another, even Abstract classes, interfaces cannot be inherited
    . Has all the inherited properties that normal classes do. So you can create an interface inheritance hierarchy just like you can create a class inheritance hierarchy. However, what you can't do is instantiate an interface that must be implemented.

    Pairing and mutual evaluation

Grading

Review Template:

  • Worth learning or questions from the blog:
    • xxx
    • xxx
    • ...
  • Worth learning or problems in the code:
    • xxx
    • xxx
    • ...
  • Based on the scoring criteria, I give this blog a score: XX points. The scores are as follows: xxx

Reviewed classmates blog and code

  • Pair study this week
    • Together we learned about sorting and searching in Chapter 10.
    • 20172325 Deng Yukun didn't understand the process of selection sort and insertion sort thoroughly enough, and then I told him some things, and he understood very quickly.
    • For the exercises that follow, we programmed together.

Others (perception, thinking, etc., optional)

 这周因为除了第十章还有一个结对的实验刚刚起步,还连着五一的激动假期,我觉得最开始知道这么多的东西的时候十分的烦躁,内心十分的抗拒不想做。但是知道也没什么用,一点点做,但是好在老师讲了第十章的相关内容,这样我理解的比较快一些。而且这一章主要是概念的理解,再就是排序和搜索,都是套路,所以还算是可以理解的。

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 193/200 1/1 20/20
the second week 247/440 1/1 22/42
The third week 445/895 2/2 20/62
the fourth week 885/1780 1/1 43/105
fifth week 775/2555 1/1 55 /160
Week 6 1171/3726 1/1 38/198
Week 7 596/4322 1/1 60/258
eighth week 569/4891 2/2 55 /313

References

Guess you like

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