"Object-oriented programming and data structures," the fourth week of learning summary

20,182,304 2019-2020-1 "Object-oriented programming and data structures," the fourth week of learning summary

Learning content summary

  • 1. In this chapter we learn how to use and write our own classes: class has the same name as the class constructor, you can also set, get, toSring and methods you define. Instantiate an object, the object may be used by all the class methods. Instance data is automatically generated new variable memory space after each instance of creating a
  • FIG 2.uml class: Each class may contain three parts: a class name, attributes, operations (methods). UML class diagrams own syntax, type name of the variable after the variable name, a colon between them as a separator, the method of the + and - indicate visibility. Arrow points, and indicated that a known class using another class in some way (call).
  • 3. The packaging concept
  • 4. visibility modifiers: public direct access from outside the class (usually set to the constant public, because it can not be arbitrarily changed, security can be guaranteed)
    Private mandatory package, can not be called protected and inheritance related class outside, both can be called by subclasses, but also to ensure that the package
  • The class relationships: dependency (has a), inheritance, polymerization, this refers to
  • 6. interface concept

    Textbook learning and problem-solving process

  • Question 1: How to understand the static method
  • Problem 1 Solution: Static method static modification, without instantiating the class can call. It does not refer to an instance variable in the instance of the class, so generally refer to a static variable
  • Question 2: this reference has what role
  • Problems Solution 2: this allows an object reference point to themselves, this refers to the method used to distinguish between parameter configuration corresponding instance variable of the same name. When the data transfer parameters required class, you can take the same name, as long as the left side plus this. Cited
  • Question 3: What is the packaging concept, why should promote package
  • Question 3 Solution: The object should be packaged, the package is packed with data and related behaviors in order to achieve information hiding, either class achieve hidden details, and also avoid direct manipulation of the class attribute. Package actually controls the degree of modification of a user and access data class, the method can only provide those services through the object interacts with other parts of the program, the interface means is an accurate description of the package. Declare variables within a class, the class should be accessible only from the inside and modify, outside the class should not and can not modify the value of a variable.

Code debugging and problem solving in the process

  • Question 1: error in the get method led to mass participation program error
  • Problem 1 Solution: By helping students, learned the get method can not pass parameters, can only return data. Parameter passing should be done in other processes such as set
  • Question 2: When you knock on the Coin class book, a line of code count1 = (coin1.isHeads()) ? count1+1 : 0;I will count1+1knock became count++, originally thought very different, running Shique cause an infinite loop

  • Problem 2 Solution: count++the count=count+1equivalent, count itself is the changed. Because the left-hand side there is a medium type count =, thus resulting in an infinite loop. The count + 1 does not change the value of the count, it can be used normally in the assignment statement
  • Question 3: After git configured not upload
  • Question 3 Solution: did not see the push and then submit, the default is to commit, need to manually set about

Code hosting

Last week exam wrong question summary

  • What is the function of the dot operator?
    • A .It serves to separate the integer portion from the fractional portion of a floating point number
    • B .It allows one to access the data within an object when given a reference to the object
    • C .It allows one to invoke a method within an object when given a reference to the object
    • D .It is used to terminate commands (much as a period terminates a sentence in English)
    • E .Both B and C are correct
    • The dot operator is appended directly after the object reference, followed by the data or method to which access is desired. In the case of data, the access may be for reading or writing. In the case of a method, the access is to allow one to invoke the method. The dot within a floating point number is a decimal point not a dot operator.
    • Appreciated: the dot operator can be directly added to an object reference, then add the name of the method to be invoked, the data objects may be accessed at a given reference object. .
  • The String class' compareTo method
    • A .compares two string in a case-independent manner
    • B .yields true or false
    • C .yields 0 if the two strings are identical
    • D .returns 1 if the first string comes lexically before the second string
    • E .none of the above
    • Understood: identical as equal, it does not understand the English meaning causes an error. compareTo and usage is similar in C
  • The names of the wrapper classes are just the names of the primitive data types, but with an initial capital letter.
    • A .true
    • B .false
    • This is true for most of the wrapper classes, but it is false for int (Integer) and char (Character).
    • Understanding: read books, can be found int wrapper classes for Integer, char wrapper classes are Character, other types of packaging titlecase
  • The advantage(s) of the Random class' pseudo-random number generators, compared to the Math.random method, is that
    • A .you may create several random number generators
    • B .the generators in Random are more efficient than the one in Math.random
    • C .you can generate random ints, floats, and ints within a range
    • D .you can initialize and reinitialize Random generators
    • E .all but answer B
    • The efficiency of all the random number generators are the same. The advantages of Random generators over Math.random include all the other properties.
    • Understanding: efficiency is the same
  • These two ways of setting up a String yield identical results:
  • a) String string = new String("123.45"); b) String string = "" + 123.45;
    • A .true
    • B .false
    • I understood that: "" is a string, the connection string + automatically, so the following figures are in the form of a string is assigned to the string, equivalently,
  • 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.
    • Understand: D must be wrong, if the class is set to final, it can not be rewritten, will always be a subclass of abstract class can not be instantiated
  • Having multiple class methods of the same name where each method has a different number of or type of parameters is known as
    • A .encapsulation
    • B .information hiding
    • C .tokenizing
    • D .importing
    • E .method overloading
    • When methods share the same name, they are said to be overloaded. The number and type of parameters passed in the message provides the information by which the proper method is called.
    • I understand: error reason is because of lack of knowledge to understand the type of book
  • Visibility modifiers include
    • 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.
  • The following method header definition will result in a syntax error: public void aMethod( );
    • A .true
    • B .false
    • The reason for the syntax error is because it ends with a ";" symbol. It instead needs to be followed by { } with 0 or more instructions inside of the brackets. An abstract method will end with a ";" but this header does not define an abstract method.
    • Understanding: First of all, can not have a colon after the method. Second, it should have a back brace
  • Every class definition must include a constructor.
    • A .true
    • B .false
    • Java allows classes to be defined without constructors, however, there is a default constructor that is used in such a case.
    • Appreciated: may not be defined, it will generate a default constructor

Pair peer review and

Grading

  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, a problem 1 point

  4. Code debugging and problem solving in the process, a problem 1 point

  5. Week over 300 branches valid code (plus 2 points)
    • Submitted one week fewer than 20 times without points
  6. Other plus points:
    • Hair blog before Friday 1 point
    • Feelings, experience does not leave large empty 1 point
    • Typesetting fine plus one point
    • Progress bar records the learning time and improve the situation of 1 point
    • There are hands-on writing new code, add 1 point
    • After class choice has verified 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
  7. Points:
    • Plagiarism buckle to 0
    • Cheat codes to buckle 0
    • Late assignments to buckle 0

Comments template:

  • Worth learning problems or blog:
    • xxx
    • xxx
    • ...
  • Code is worth learning or problem:
    • xxx
    • xxx
    • ...
  • Based on score, I give this blog Rate: XX points. Score as follows: xxx

  • Reference Example

Comments had students blog and code

  • Pair this week learning
    • 20182302
      • Pair learning content
      • The concept of learning to interface with specific operations
      • Packaging appreciated defined class
      • A debugging test programs compile error
  • Last week blog peer assessment case

Other (perception, thinking, etc., optional)

  • After the test, I found myself only textbooks have probably understood that many details still unknown knowledge, there is much room for improvement
  • Starting from the fifth chapter, Java learning curve is relatively large, it takes more time and effort to learn

Learning progress bar

The number of lines of code (add / accumulate) Blog amount (add / accumulate) Learning time (add / accumulate) Important growth
aims 5000 rows 30 400 hours
the first week 200/200 2/2 20/20
the second week 300/500 2/4 18/38
The third week 500/1000 3/7 22/60
the fourth week 300/1300 2/9 35/100

Try recording "planned learning time" and "actual learning time" to the end see if you can improve their ability to plan. This study is very important work, is also useful.
Consuming an estimated equation: Y = X + X / N , Y = XX / N, training more often, X, Y will close.

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

  • Plan study time: 40 hours

  • The actual study time: 35 hours

  • To improve the situation: I will try to improve some of the learning efficiency

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

Reference material

Guess you like

Origin www.cnblogs.com/acgacg/p/11614371.html