20172333 2017-2018-2 "Java Programming" 4th Week study Summary

Source: Internet
Author: User
Tags gcd greatest common divisor

20172333 2017-2018-2 "Java Program Design" 4th Week study summary textbook learning content

1. Definition and concept of class structure

2. Using instance data to establish the concept of object state

3. Describe the effect of the visibility modifier on methods and data

4. The use of learning method parameters and return values

5. Structure and use of construction methods

6. Learn the main steps of object-oriented software design

7. Technology of classes and objects required by the program

8. Three kinds of relationships between classes

Effect of 9.Static on the effect of the method

10. Static variables, static methods, non-static methods, differences between non-static variables

11.this Application Statement

12. Interface

13. Enumeration type

Problems in code debugging and the resolution process
    • [x] Question 1: A Java program that has just started to use die methods, has not declared the class in advance, causing the error.

    • Resolution process: After repeated correction is invalid, the reference book after the attempt to compile the later Die.java program after running, again run Rollingdice.java, the final success.

    • [x] Issue 2: In the PP4.9 program compile, the topic requires the use of the previous die class file and redefine the new class, an error occurred.

    • Resolution process: I tried to find the relevant information in the book to see if I could solve the problem, but did not find a clear method, I began to look for errors from the beginning, I suddenly think of the use of Die, Need to Die.class file in this directory, and then recompile the die.class, the result of the problem is still not resolved, and later think of the Roolingdice.java in the reference Die.java to instantiate, in Pairofdice.java in the instantiation of two variables. The mistake will be solved.

Problems in teaching materials learning and the solving process
    • [x] Question 1: How do I pass an object as a parameter?
    • Resolution process: This problem I see in the Sr7.21, my understanding is to assign the object's instance data to a parameter, with this parameter to pass. In fact, the answer is to copy the reference copy of the object to the method so that the method's arguments and parameters are each other's aliases.
Code Hosting

(run result of statistics.sh script)

Last week's summary of the wrong quiz

1.The relationship between a class and an object are best described as

A. Classes is instances of objects

B. Objects is instances of classes

C. Objects and classes are the same thing

D. Classes is programs while objects is
Variables

E. Objects is the instance data of classes

Summary: The class contains instance data and methods, and the object is the instantiated data.

    1. In order to preserve encapsulation of an object, we would does 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

Summary: encapsulation means that the class contains the data and methods needed to manipulate the data. To properly save the encapsulation, the instance data should not be accessed directly from outside the class, so the instance data is private and the method is defined to access and manipulate the instance data. In addition, methods for accessing and manipulating instance data are exposed so that other classes can use the object.

3.If a method does not having a return statement, then

A. It'll produce a syntax error when compiled

E I It must be a void method

C. It can called from outside the class that defined the method

D. It must is defined to is a public method

E. It must is an int, double, float or String method

Summary: Only the void method does not return, and the rest has a corresponding return value.

4.Consider a sequence of method invocations as Follows:main calls M1, M1 calls M2, M2 calls M3 and then M2 calls M4, M3 C Alls M5. If M4 have just terminated, what method would resume execution?

A. M1

E I M2

C. M3

D. M5

E. Main

Summary: Once the method terminates, the value in the method is restored.

5.Consider a rational class designed to represent Rational numbers as a pair of int ' s, along with methods reduce (to Reduc E The rational to simplest form), gcd (to find the greatest common divisor of both int ' s), as well as methods for addition, subtraction, multiplication, and division. Why should the reduce and GCD methods is declared to be private.

A. Because They'll never be used

B. Because they is called from
Methods inside of Rational

C. Because They is called from the constructor of Rational

D. Because They don't use any of Rational's instance data

E. Because It is a typo and they should being declared as public

Summary: Private definitions can only be used within this class.

    1. In Black-box testing, the tester should already know something what's about the program was implemented so that he/she can mor E carefully identify what portion (s) of the software is leading to errors.

A. True

B. False

Summary: The black box experiment, the programmer just know the input and output, do not know its specific method, a little know the method becomes transparent box experiment.

7.Interface classes cannot be extended but classes, implement interfaces can be extended.

A. True

B. False

Summary: In addition to final not extensible, the rest can be expanded.

8.Formal parameters is those that appear in the method call and actual parameters is those that appear in the method hea Der.

A. True

B. False

Summary: The formal parameter is inside the method head, the argument is the parameter inside the method.

9.Assume The class Bird has a static methodfly (). If B is a Bird, then to invoke fly, you could do Bird.fly ();.

A. True

B. False

Summary: Static methods are all shared.

10.The goal of testing is to
A. Ensure the software has no errors

B. Find syntax errors

C. Find logical AND Run-time errors

D. Evaluate how well the software meets the original requirements

E. Give out-of-work programmers something to do

Summary: Test the Java program to ensure that the program logic error does not occur.

Learning progress Bar
lines of code (new/cumulative) Blog Volume (Add/accumulate) Learning Time (new/cumulative) Important Growth
Goal 5000 rows 30 Articles 400 hours
First week 125/125 2/2 20/20
Second week 269/394 2/4 Unknown/38
Third week 477/920 1/5 x/x
Week Four 1179/2338 1/6 --




20172333 2017-2018-2 "Java Programming" 4th Week study Summary

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.