"Data Structures and object-oriented programming," the second and third week learning summary

Student Number 2019-2020-2314 "Object-oriented programming and data structures," the second and third week learning summary

Learning content summary

Chapter II data and expression:

1, the basic concept is introduced and string String class.

2, presentations and the difference between print and println methods, after println output will change to the next line and print will not.

3, connecting the two strings using +.

4, the use of the escape character, \ n-indicating force output of the next line, \ T represents a tab

5, the definition of variables, if the increase in the final qualifier before the statement, it indicates that the value of the constant does not change.

6, assignment of use, a type of value can not be assigned to another type with variable mismatch.

7, a specific constant value is stored during its existence.

8, the basic data types, integer and floating point, character type, boolean type (for true and false judgments, can only choose from two variable values ​​inside twenty-one), the expression, the use of arithmetic operators, operator priority, and so on.

Chapter 3 Using classes and objects
The object is created, new operator returns a reference to the newly created objects, multiple references to variables can point to the same object.

2, String class String and more useful method of usage.

3, the import statement and using the package (for all classes java.lang package will be automatically incorporated into each of the program)

4, and using the Random class Math class

Textbook learning and problem-solving process

  • Question 1:
    output problems, can not be printed

  • Problem 1 Solution: I found I used println (+ (xx) +) format

  • Question 2: println ( "How much \ n"); discover how much money will be output \ n

  • Problem 2 Solution: Look after the escape character chapters found, \ n only be used in the middle

Code debugging and problem solving in the process

  • Question 1: After starting the second week jdb debugger calculator to do the experiment, list shows the current operation to display the first few rows could not find the source file.
  • Problem 1 Solution: First, I ask the students fail, then I asked the seniors and assistants, have failed, and finally with the help of cold-students of a blog, follow the steps in the blog solves this long-standing problem, blog at the following address : JAVA to solve the problem stepping keyboard is occupied jdb
  • Question 2:

Code debugging can not pass

  • Problem 2 Solution: After the inquiry assistant that class which can not be re-defined class, and defines the string when the public can not be added in front of it is superfluous and calls the class method call must have the same name and class.

Code hosting

Last week exam wrong question summary

  • Wrong question 1:
    the If you want to the Output at The text "hi there", Including at The quote Marks, of Which at The following could do that (if you want to output text "hi there", including the quotation marks, which of the following statements do? to?)

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 not possible to output a quote mark because it is used to mark the beginning and ending of the String to be output (no, not possible to output quotes because it is used to mark the beginning and end of the string)

The correct answer: D Your answer: B

  • Cause of error:
    not a good look at the content of textbooks escapes, escapes clear that the content you want to add "" must be added a /.

  • The wrong question 2:
    Word IS A println (the n-) (println is a word)

A .method (Method)

B .reserved word (reserved word)

C .variable (variable)

D .class (class)

E .String (String)

The correct answer: A Your answer: C

  • Cause: The study did not have knowledge of the class, stumbled a mess Mongolia, now distinguish the difference between the classes and methods.

  • Wrong question 3:
    the What z value by Will have have the Execute IF WE following the Assignment of Statement at The float z = 5/10; (if we execute the following assignment statement, is what will get the z value??

A .z will equal 0.0 (z will be equal to 0.0)

B .z will equal 0.5 (z will be equal to 0.5)

C .z will equal 5.0 (z will be equal to 5.0)

D .z will equal 0.05 (z will be equal to 0.05)

E .none of the above, a run-time error arises because z is a float and 5/10 is an int (None of the above, since z is a float type, 5/10 is of type int error occurs when it runs)

The correct answer: A Your answer: B

  • wrong reason:

Did not properly understand the int type integer division may bring consequences, because 0.5 is less than 1, two int type directly to become zero.

  • 4 wrong question:

A cast is required in which of the following situations? (Which of the following need to cast?)

A .using charAt to take an element of a String and store it in a char (charAt used to obtain the string elements and stored as a char type)

B .storing an int in a float (int type to a number storage type float)

C .storing a float in a double (a float type number stored as double type)

D .storing a float in an int (a float type number storage type int)

E .all of the above require casts (All of the above are required cast)

The correct answer: D Your Answer: A

  • wrong reason:

Not a good look at the content of textbooks type conversion, clearly written textbooks on different types of values ​​you want to convert, you need to go through mandatory conversion.

  • Wrong question 5:

Assume that x, y, and z are all integers (int) equal to 50, 20, and 6 respectively. What is the result of x / y / z? (Assuming x, y and z are integer (int) , respectively, then the result is equal to 50, 20 and 6 x / y / z what?)

  • wrong reason:

Blindly think that this operation format is unreasonable, mistook this form will directly result in an error.

  • 6 wrong question:

What is output with the statement System.out.println (x + y);? If x and y are int values ​​where x = 10 and y = 5 (if x and y is a number of type int, x = 10, y = 5, the statement System.out.println (x + y); What is the output)?

A .15

B .105

C .10 5

D .x+y

E .An error since neither x nor y is a String (an error due to the x and y strings are not caused)

The correct answer: A Your answer: B

  • wrong reason:

Previously did not know the textbook + can clearly written two strings.

  • 6 wrong question

In Java a variable may contain

A .a value or a reference

B .a package

C .a method

D .a class

E .any of the above

The correct answer: A Your answer: E

  • wrong reason:

java class has methods and variables, no package

  • 7 wrong question:

What happens if you attempt to use a variable before it has been initialized?

A .A syntax error may be generated by the compiler

B .A runtime error may occur during execution

C .A "garbage" or "uninitialized" value will be used in the computation

D .A value of zero is used if a variable has not been initialized

E .Answers A and B are correct

The correct answer: E Your answer: A

  • wrong reason:

I did not think too much, do not think the general election simultaneously selected two answers, and then on the Mongolia A.

  • 8 wrong question:

What will be displayed by this command: System.out.println(Math.pow(3, 3-1));

A .9

B .8

C .6

D .4

E .27

The correct answer: A Your answer: C

  • wrong reason:

No serious view before the exam books, textbooks clearly written Math.pow (3, 2) is the square of three, because I have not seen, mistakenly thought it was 3 * 2, this sudden joke.

Pair peer review and

  • Pair this week learning

20182330

  • Peer assessment

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

Other (perception, thinking, etc., optional)

After this week, I'm learning more profound understanding of java, but java class for understanding

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 second and third week 387/400 2/2 20/20

Reference material

Guess you like

Origin www.cnblogs.com/juminghan/p/11569737.html