# 20182328 2019-2020-1 "data structures and object-oriented programming," the second and third week learning summary

Learning content summary

Java chapter mainly about the basic data types and converts it, how to use an expression, and reads the user input method of
third chapter In more detail, the concept and use of various types of object classes used to perform a variety of complex operations, as well as the concept of enumerated types

Textbook learning and problem-solving process

  • Question 1: I do not know how to extract a single letter of the string.
  • Problem 1 Solution: Use char.charAt () command.
  • Question 2: π how to express?
  • Problem 2 Solution: call the Math class to Math.PI
  • ...

Code debugging and problem solving in the process

  • Question 1: Output code problems.

  • Problems Solution 1: parenthesis not have "," + the string must be constant operand and connected.
  • Question 2: When you perform extracts part of a string command error.

  • Problem 2 Solution: Command String substring (int num1, int num2) error, should String.substring (int num1, int num2).
  • Question 3: Perform square calculation error.

  • Problems Solution 3: wrong command, should Math.pow (r, 2)
  • Question 4: Illegal expression display

  • Question 4 Solution: should be constant at the beginning of the calculation.

Code hosting

Last week exam wrong question summary

  • 1, the wrong question: the In the Java, "instantiation" means
    A .noticing something IS Used The First Time
    B A new new .creating The Object of class
    C .creating A new new AN to existing Alias Object
    D .launching A Method
    E The .none of above
    analysis: "instantiate" means to create a new instance of the object, which is the basic knowledge.

2, the wrong question: String of The class' the compareTo Method
A String in .compares TWO-Independent Manner A Case
B .yields to true or to false
C .yields 0 IF TWO The strings are Identical
D .returns. 1 IF The String First Comes The lexically before string sECOND
E .none of the above
analysis: If the two strings are the same, generates the compareTo 0, -1 if the first occurrence of a string lexicographically before the second string of +1 is generated, if the first lexicographically string after the second string appears.
3, the wrong question: These two ways of setting up a String yield identical results:

a) String string = new String(12345);

B) String String = new new String ( "12345");
A .true
B .false
analysis: not accepted overloaded version string constructor parameter values.

4, the wrong question: the Consider at The following of Statement:
System.out.println ( "Big Bad Wolf 1 \ T8 at The 3 Little Pigs \ n4 Dinner \ r2night");
This of Statement by Will the Output ________ Lines of text (Consider the following statement, which ___ statement output line of text)
A .1
B .2
C .3
D .4
E .5
analysis: insert a tab escape sequence, but leaving the cursor in the same row. Escape sequences will produce a new line to the next line output "4 dinner". Enter the escape sequence results (i.e., the cursor moves back to the left margin), but since it does not start a new line, "2night" Output on "4dinn", causes the second line looks like "2night".

5, the wrong question: If you want to output the text "hi there", including the quote marks, which of the following could do that ( if you want to output text "hi there", including the quotation marks, of which the following statement? do)?
A .System.out.println ( "Hi there");
B .System.out.println ( "" Hi there "");
C .System.out.println ( "" Hi there ");
D .System.out.println ( "" Hi there "");
E .none, IT IS A output not possible to quote Because IT IS Used to Mark The Mark The Beginning and Ending of BE to output String (no, not possible to output quotes, because it is used to mark the beginning and end of a string)
Analysis: "an escape sequence is used to place characters in the string, hence the use of the rest of it to output and quoted strings.

6, the wrong question: A Cast of IS required at The following Situations in Which?
A .using charAt to the Take A String AN Element of IT and Store in char A
B .storing AN A float int in
C .storing A float in A Double
D a AN in a float int .storing
E .all of the require casts The above
analysis: for a, charat returns a char, there is no problem. In b and c, where the expansion operation, the use of a narrow type, and stores the value in a wide type. Only in d, the type will be stored in the broader types appear narrower, it is necessary to cast.

7, the wrong question: If x is an int and y is a float, all of the following are legal except which assignment statement ( if x is an int, y is the number of a float, all of the following assignment statement? which is not legal)?
A .y = X;
B .x = Y;
C .y = (a float) X;
D .x = (int) Y;
E The above are .all of legal (valid above all)
Analysis: Since X is int, int unless it is a floating-point type, otherwise it can not be other than floating point. B thrown in there is no clear assignment statement. In A, it does not require a throw, because floating-point (y) int acceptable value (X), and in c and d, so that they explicitly thrown legitimate.

8, In order to create a constant , you would use which of the following Java reserved words? ( To create a constant, which of the following would you use Java reserved word?)
A .private
B .static
C .int
D. final
E .class
Analysis: this is a reserved word final represents the final value stored in this variable, so it can not be changed or constant. Constants can be of type int, constants can also be any other type. It is the last reserved word, so that the value can not be changed.

9, the wrong question: the Java Language IS A Strongly typed the What IS Meant by "Strongly typed."?
A .Every the MUST have have AN Associated variable of the type the before you use IT CAN
B .Variables CAN BE Used Their Declaring the without of the type
C variable has .Every Associated with IT SINGLE of the type A Throughout the ITS Existence in at The Program, and only Store at The CAN variable of the type that values of
D .Variables are allowed to Change Their Existence of the type in at The During Program at The value AS Long AS IT IS Rate this page Currently Stores of the type of IT at The Rate this page Currently declared to bE iS
E .Variables are allowed to Change Their existence in at the types During program at the Change But only IF iS a narrower of the type to
resolve: strongly typed property is a programming language through which types of variables exist in variable during does not change, and no value is stored in the variable is the type. Strong typing is important because it ensures the success of the program will not be compiled when you run the wrong type of abuse associated with the declaration of variables.

10, the wrong question:. The values of (double) 5/2 and (double) (5/2) are identical (. (Double) (double) value of 5/2 and (5/2) are the same)
A .true
B .false
Analysis: in the first expression, (double) applied to cast int 5, change it to a double value 5.0. Then calculated 5.0 / 2, 2.5 doubled value obtained. In the second expression, int division performed first to obtain a value of 2. 2 then change to double, double to give a value of 2.0.

11, the wrong question: Every Interator
A .has the hasNext A () Method
B A .has hasFirst () Method
C A .has hasNextInt () Method
D A .has isEmpty () Method
E The above .none of
analysis: for each iteration there is a method hasNext (), if there has not been an iterative process elements, the method is true. Each iteration also has a next () method, which is transmitted to the next element to be processed.

12, the wrong question: In order to compare int, float and double variables, you can use <,>, ==, =, <=,> =, but to compare char and String variables, you must use compareTo (),! the equals () and equalsIgnoreCase ().
A .true
B .false
Analysis: you can also directly compare the char variable, using <,>, =,! =, <=,> =, But must use compareTo (), equals () and equalsIgnoreCase () for any string comparison.

Pair peer review and

Grading

  • Based on score, I give this blog scoring: 14 points. Scores are as follows:
  1. Proper use Markdown syntax (1 point):
  2. Elements range (1 point) template
  3. Textbook learning and problem-solving process, plus 4 points
  4. The code debugging and problem solving process, plus 4 points
  5. Other points (plus 4 points)

    Comments template:

  • Worth learning problems or blog:
    • Informative and streamlined
    • Issues are fully resolved and
    • There are distribution map
  • Code is worth learning or problem:
    • Correct and concise
    • Methods varied it is worth learning
    • ...
  • Reference Example

Comments had students blog and code

Other (perception, thinking, etc., optional)

1, the contents of two weeks to learn more, a little catch up, but multi spare some free time was able to learn more, the fourth week, I try to spend more time to knock code.
2, read as many books, the contents of the textbook is very detailed, there will not look at the books, and then from the Internet.

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 30/90

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

  • Plan study time: 30 hours

  • The actual study time: 25 hours

Reference material

Guess you like

Origin www.cnblogs.com/monsterhunter/p/11569847.html