20182323 "programming and design structure," the sixth week of learning summary

table of Contents

Student ID 20182323 2019-2020-1 "Object-oriented programming and data structures," the first six weeks learning summary

Learning content summary

Chapter 9

  • Key concepts
  1. Polymorphic reference object at different times can point to different types of

  2. Polymorphic references at runtime method call with its definition bound

  3. Reference variable can point to declare it inherited any class of any object

  4. Type of the object, rather than a reference type, the decision to call a method which version of

  5. A method is a set of abstract interfaces, it can not be instantiated

  6. Inheritance can be applied to the interface, the interface can be derived from another interface

  7. Interface reference can point to any object that implements this interface of any class

  8. The method parameters may be polymorphic, so that the flexibility is provided a method for controlling its parameters

  9. Establish the relationship between the listener and the listener components is accomplished by the polymorphic

  • Key summary
  1. When a given class implement each abstract method defined in the interface that implements the interface class is said to

  2. If the interface is not a method implemented in a class, the compiler error

  3. Interface only guarantee class implements certain methods, but it does not limit the type of behavior can have other

  4. A plurality of classes can implement the same interface, and each of which provides a method defined in the class

  5. Interface may also comprise constants that are defined by the final modifier

  6. Sub-interface inherits all abstract methods and constants parent interface. Any class that implements a sub-interface must implement all methods

  7. All members of interfaces are public

chapter Ten

  • Key concepts
  1. Errors and exceptions on behalf of unusual objects or incorrect processing

  2. Message output when an exception is thrown provides a method call stack trace

  3. Each type of a particular catch clause try block processing exceptions thrown

  4. Whether normal exit the try block, or by throwing an exception and exit, carry out your finally clause

  5. If you do not capture and processing it at an exception occurs, the exception will be propagated to the calling method

  6. If an exception will be generated, the programmer must carefully consider how and where to handle exceptions

  7. From the Exception class or one of its successors class derive a new class, you can define a new exception

  8. Block header comprising the throws clause must not capture and processing methods will be seized abnormality

  9. Stream is a sequence of a sequence of bytes, it can be used as an input source or output destination

  10. Public class System three reference variable represents the standard I / O stream

  11. Java class library includes a number of classes, with different properties can be used to define the I / O stream

Textbook learning and problem-solving process

  • Question 1: How to understand the book
对象的类型,而不是引用的类型,决定调用的是方法的那个版本
  • Problem 1 Solution: When a parent class object reference variable that references subclass object, who decided to call a member method conditions are: the type of the referenced object rather than a reference type variable. But this method must be invoked been defined in the parent class, which is a subclass covering over methods.

  • Question 2: Regarding the question of succession interface
    (Description: The book introduces the concept of inheritance to apply to class, but also applies to the interface, the interface inherits whether and class inheritance generally do not support multiple inheritance.)

  • Problem 2 Solution: query data that, java interface multiple inheritance.

Interface Extends Interface0, Interface1, interface3
不允许类多重继承的主要原因是,如果A同时继承B和C,而B和C同时有一个D方法,A如何决定该继承那一个呢?

但接口不存在这样的问题,接口全都是抽象方法继承谁都无所谓,所以接口可以继承多个接口。
  • Question 3: deepening on the throw and throws

  • Question 3 Solution: When checking summarized as follows:

    01.throw a statement throws an exception, and get this reference exception, and the exception is thrown to the outside environment, it is processed by the external environment.

    02.throws is throw an unusual statement. (When used in the method statement, indicating that the method might want to throw an exception)

    03.throws can be used alone, but can not throw, and throw or try-catch-finally statement supporting the use of, or supporting the use of throws. However throws may be used alone, and then captured by the process of the exception processing.

    04.throw statement is used in vivo, it represents an exception is thrown, the statements in vivo treatment with throws statement after the method declaration that then throw an exception, is handled by the previous method call this method in the statement, you must make a deal (capture or continue statement)

    05.throws primarily declare this method throws this type of exception, the rest of the call when it knows to catch this exception must be made so that the reminder process. Otherwise the compiler will not pass. throw exception is thrown outwardly specific operation, it is to throw an exception instance.

    06.throws indicate a possibility of abnormal, these exceptions do not necessarily occur in the absence of abnormality can also throws in; throw an exception is thrown, throw it must perform some kind of an exception thrown object.

Code debugging and problem solving in the process

  • Question 1: static keyword
  • Description: When the code following experiments
public class Mydoc {
    Document d;
    public static void main(String[] args) {
        d = new Document(new IntFactory());
        d.DisplayData();
        d = new Document(new FloatFactory());
        d.DisplayData();
    }
}

Program prompts:Non-static filed 'd' cannot be referenced from a static context

  • Resolution process: because the static method does not operate on specific objects, so they can not only refer to an instance variable only exists in the instance of the class. All static methods, including the main method, can only access static variables or local variables.
    and sostatic Document d

Code hosting

Last week exam wrong question summary

  • Question 1: Polymorphism is achieved by (what polymorphism is achieved by it?)

    A. Overloading (overload)

    B. Overriding (rewritable)

    C. Embedding (embedding)

    D. Abstraction (abstract)

    E. Encapsulation (package)

    1. Answer: This question answer is B. At that time chose D. Analysis of each option:. A heavy load but provides alternatives for the method with different parameter lists. B. rewrite provides polymorphism, because the appropriate approach is based on the object currently referenced invoked. C. embedded class is included in the class. D. abstraction and polymorphism nothing to do. E. package using visibility modifier (public, private, protected) implementation. So I chose to rewrite.

  • Question 2: Which statement is completely true (Which statement is entirely correct?)?

    A. Java upcasts automatically, but you must explicitly downcast (java upward type conversion is automatic, but down type conversion must be clearly stated)

    B. Java downcasts automatically, but you must explicitly upcast (java downward type conversion is automatic, but up type conversion must explicitly)

    C. Java expects the user to explicitly upcast and downcast (requires java explicitly stated when the user upward or downward transition)

    D. Java will both upcast and downcast automatically (when the user java upward or downward transition is automatic)

    E. The rules for upcasting and downcasting depend upon whether classes are declared public, protected, or private (transition rules up and down in transition depends on whether the class is declared as public, protected, private)

    2. Answer: This question answer choices A, I chose E. Java in the upward transition is automatic, it is the product of Java support single inheritance structure. Downwardly conversion must be done explicitly by the programmer. Java automatically converted only in one direction. Downcast and upcast rules do not depend on the use of any means, including visibility modifier.

  • Question 3:? Can a program exhibit polymorphism if it only implements early binding ( if a program only implements early binding, so it can display multiple state it?
    )
    A Yes, Because One form of polymorphism IS Overloading (yes, because. a form of polymorphism is overloaded)

    B. No, because without late binding polymorphism can not be supported (not because there are no late-binding polymorphism can not be supported)

    C. Yes, because so long as the programs uses inheritance and / or interfaces it supports polymorphism (that, as long as the program uses inheritance and / or interfaces that it supports polymorphism)

    D. Yes, because early binding has nothing to do with polymorphism (yes, because early binding and polymorphism has nothing to do)

    E. None of the above (none of the above)

    3. Answer: The answer option A, I chose B. Although inheritance and interfaces to support multi-state, but only do so only when there is late binding. However, overloading is polymorphic form an alternative embodiment, a plurality of the body, as long as the program using the overload, polymorphism in use.

  • Question 4: The fact that the System.out.println () method is able to handle such a wide variety of objects, and print them correctly, is an example of the polymorphic nature of the println () method (System.out.. println () method can handle such a wide range of objects, and to print them correctly, it is a characteristic example of reflected polymorphic.)

    A.ture

    B.false

    4. Answer: The answer is A. Since println () is essentially a highly polymorphic, it is possible to accurately print a variety of predefined (library), and built-in (raw) data.

Pair peer review and

Comments template:

  • Worth learning problems or blog:
    • With the increase of the difficulty of learning content, a deeper analysis of the problem
    • Continued access to information, efforts to resolve problems
  • Code is worth learning or problem:
    • Logic of the code needs to be improved
    • Code appropriate to add comments will be better
  • Based on score, I give this blog scoring: 12 points. Scores are as follows:
  1. Proper use Markdown syntax (1 point):
    • Do not use Markdown no extra points
    • A syntax error is not a plus (link does not work, does not form, the list is incorrect ...)
    • Typesetting confusion is not a plus
  2. Elements range (1 point) template
    • Missing "textbook learning and problem solving process" without points
    • Lack of "problem solving and debugging code in the process" without points
    • Managed code can not be opened without points
    • Missing "twinning and peer assessment" can not be opened without points
    • Missing "last week summed up the wrong title examination" can not be a plus
    • The lack of "progress bar" can not be a plus
    • Lack of "reference" can not be a plus
  3. Textbook learning and problem-solving process (2 points)

  4. The code debugging and problem solving process (2 points)

  5. Week over 300 branches valid code (plus 0)

  6. Other plus points:
    • Hair blog before Friday 1 point
    • Feelings, experience does not leave large empty 1 point
    • Progress bar records the learning time and improve the situation of 1 point
    • There are hands-on writing new code, add 1 point
    • Learning the wrong questions in depth, add 1 point
    • Comments seriously, I can point out problems and blog code plus 1 point
    • Pair learning authentic plus 1 point

Comments had students blog and code

  • Pair this week learning
  • Suddenly the book has more than half, knowledge is still scattered, you need a wrap.
  • It is necessary to draw extra-curricular knowledge, nothing can be more to see someone else's blog, exchange of experience

Learning progress bar

The number of lines of code (add / accumulate) Blog amount (add / accumulate) Learning time (add / accumulate) Important growth
aims 10,000 lines 30 400 hours
the first week 77/77 2/2 15/15
The third week 424/501 3/5 30/30
the fourth week 393/894 2/7 30/30
fifth week 320/1214 1/8 30/30
Sixth Week 904/2118 2/10 30/30
  • Plan study time: 25 hours

  • The actual study time: 20 hours

  • Improvements:

Reference material

Guess you like

Origin www.cnblogs.com/caoqian1314/p/11681695.html