20,182,324 2019-2020-1 "data structures and object-oriented programming," the first four weeks learning summary

20,182,324 2019-2020-1 "data structures and object-oriented programming," the first four weeks learning summary

Learning content summary

1, using the cycle
2, UML modeling
3, method overloading
4, like encapsulation, inheritance and polymerization
5, simple iterator (the Iterator) and methods of using
6, an interface (Interface) the preparation and use of

Textbook learning and problem-solving process

  • Question 1: The character can not be nextChar()entered
  • Problems Solution 1: Scanner is not a class nextChar()method, may be used charAt(int)to return the specified character position.

  • Question 2: display git push to push the code "unable to access 'xxxx': Could not resolve host: gitee.com"
  • Problem 2 Solution: The investigation is open due to the virtual machine network.

Code debugging and problem solving in the process

  • Q: Output Format. "# ###" is omitted automatically when the last decimal place is 0
  • Problem Solution: "#" is not formatted output is zero footprint, you can use the "# .000."

Other problems have been recorded to the blog experiment REPORT

Code hosting

(Run results screenshot statistics.sh script)

Last week exam wrong question summary

  • The behavior of an object is defined by the object's
    A. instance data
    B. constructor
    C. visibility modifiers
    D. methods
    E. all of the above
    解析:The methods dictate how the object reacts when it is passed messages. Each message is implemented as a method, and the method is the code that executes when the message is passed. The constructor is one of these methods but all of the methods combine dictate the behavior. The visibility modifiers do impact the object's performance indirectly.

  • In order to preserve encapsulation of an object, we would do all of the following except for which one?
    A. Make the instance data private
    B. Define the methods in the class to access and manipulate the instance data
    C. Make the methods of the class public
    D. Make the class final
    E. All of the above preserve encapsulation
    解析:Encapsulation means that the class contains both the data and the methods needed to manipulate the data. In order to preserve encapsulation properly, the instance data should not be directly accessible from outside of the classes, so the instance data are made private and methods are defined to access and manipulate the instance data. Further, the methods to access and manipulate the instance data are made public so that other classes can use the object. The reserved word "final" is used to control inheritance and has nothing to do with encapsulation.

  • A class' constructor usually defines
    A. how an object is initialized
    B. how an object is interfaced
    C. the number of instance data in the class
    D. the number of methods in the class
    E. if the instance data are accessible outside of the object directly
    解析:The constructor should be used to "construct" the object, that is, to set up the initial values of the instance data. This is not essential, but is typically done. The interface of an object is dictated by the visibility modifiers used on the instance data and methods.

  • Instance data for a Java class
    A. are limited to primitive types (e.g., int, float, char)
    B. are limited to Strings
    C. are limited to objects(e.g., Strings, classes defined by other programmers)
    D. may be primitive types or objects, but objects must be defined to be private
    E. may be primitive types or objects
    解析:The instance data are the entities that make up the class and may be any type available whether primitive or object, and may be public or private. By using objects as instance data, it permits the class to be built upon other classes. This relationship where a class has instance data that are other classes is known as a has-a relationship.

  • Consider a Rational class designed to represent rational numbers as a pair of int's, along with methods reduce (to reduce the rational to simplest form), gcd (to find the greatest common divisor of two int's), as well as methods for addition, subtraction, multiplication, and division. Why should the reduce and gcd methods be declared to be private.
    A. Because they will never be used
    B. Because they will only be called from methods inside of Rational
    C. Because they will only be called from the constructor of Rational
    D. Because they do not use any of Rational's instance data
    E. Because it is a typo and they should be declared as public
    解析:All items of a class that are declared to be private are only accessible to entities within that class, whether they are instance data or methods. In this case, since these two methods are only called from other methods (including the constructor) of Rational, they are declared private to promote information hiding to a greater degree. Note that answer C is not a correct answer because the reduce method calls the gcd method, so one of the methods is called from a method other than the constructor.

  • Visibility modifiers include
    A. public, private
    B. public, private, protected
    C. public, private, protected, final
    D. public, protected, final, static
    E. public, private, protected, static
    解析:Public, private, protected control the visibility of variables and methods. Final controls whether a variable, method, or class can be further changed or overridden not visibility. Static controls whether a variable or method is associated with instances of a class or the class itself.

  • What happens if you declare a class constructor to have a void return type?
    A. You'll likely receive a syntax error
    B. The program will compile with a warning, but you'll get a runtime error
    C. There's nothing wrong with declaring a constructor to be void
    D. The class' default constructor will be used instead of the one you're declaring
    E. None of the above
    解析:It is a syntax violation to declare a constructor with any type even void so you'll receive a syntax error.

Pair peer review and

Comment:

  • Worth learning problems or blog:
    • Illustrated, there are references
    • markdown format using more skilled
  • Code is worth learning or problem:
    • Code format specification, the rational use of the blank, easy to read
  • Based on score, I give this blog scoring: 14 points. Scores are as follows:
    • 1, the proper use Markdown syntax (1 point)
    • 2, elements of the template is complete (1 point)
    • 3, textbook learning and problem-solving process (2 points)
    • 4, code debugging and resolving problems in the process (1 point)
    • 5, valid code week over 300 branches (plus 2 points)
    • 6. Other points:
      • 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
      • Code Commit Message Specification 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
  • Reference Example

Comments had students blog and code

  • Pair this week learning
    • 20182329

    • Pair learning content
      • Unit testing code tests
      • TDD code testing
      • Learning to use writing class with public, void, etc. write, call the class method computes
      • Relationship between classes and class inheritance, polymerization, association
      • Using a learning method calls and method of packaging

Other (perception, thinking, etc., optional)

After two weeks of study and practice, I gradually realized that the underlying C language to lay the semester, in fact, the C language and Java language, although there are different but there are similarities, the essence of which is the need for more detailed study in order to gradually appreciate.

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 109/109 2/2 28/28 Learn the basic syntax of Java, familiar with Linux Bash command
the second week 550/659 1/3 23/51 Learning to master the JDB debugger command
The third week 1028/1687 2/5 30/81 Compilation and learning classes
the fourth week 542/2229 2/7 22/103 Learning overloading, class inheritance, polymerization

Reference: Why is estimated that software engineering software so hard , software engineering estimation method

  • Plan study time: 20 hours

  • The actual study time: 22 hours

  • Improvements:

(Available see more modern software engineering courseware software engineers the ability to self-evaluation form )

Reference material

Guess you like

Origin www.cnblogs.com/lolipop2019/p/11613815.html