(Spring 2019) Software configuration: Rain classroom papers (Chapter 7)

7-1 robustness and accuracy

1 minute multiple choice question 1

About robustness and correctness of the statement, the right is __

A even if the user input is not consistent with spec requires an error elegant, reasonable terminate or continue to run
B "for their code to be conservative on the user's behavior to be open", the former is aimed at robustness, which is aimed at correctness
C programmers should always consider client can always follow the spec, this is the robustness-oriented programming ideas
D program tend to direct the robustness of error (error), the correctness of the program tend to fault tolerance (fault-tolerance)

The correct answer: A

Fill in the blank 2 3 points

(1) you write program reads data from an external file to construct a magic square in Lab1. You find that reading the file, between the two figures is not always desired by spec \ t split, so you decide, as long as the encounter non \ digital t division will exit. This is for [fill in the blank 1] programming.

(2) you ask the user to enter a 16-digit credit card number, the results of that check the user input 17. You decision taken before the user input as 16-bit digital, enter the subsequent processing. This is for [fill in the blank 2] programming.

(3) you read in Lab3 external text files, the found file number less than 10,000, also used in scientific notation, does not meet the spec. For this purpose you decide to accept this input, the program automatically reverts to regular digital form. This is for [fill in the blank 3] programming.

You can fill: accuracy, robustness, unreasonable

The correct answer:
correctness; unreasonable; robustness

3 multiple choice questions 2 points

About robustness and correctness of the statement is not correct __

The Make your Robust External interface A, and the make your code correct Internal
B The former is to allow users easy to use, which is designed to allow developers to Develop the Easy
C over the pursuit of robustness let users do not want to use your development ADT
D too correctness will pursue developer to write code becomes too complicated

The correct answer: CD

Multiple choice question 4 2 points

The following applies to the use of more robustness for development scenarios include _

A fourth Chang E lunar spacecraft control software on the
star on the B LOS ANGELES dynamic tracking and search
App authorization management functions on the iPhone XS C
D Boeing 737 MAX MCAS anti-stall system on 8
E HIT CS32207 of Lab1-Lab6, there are several free to change the contents of the input file your TA

The correct answer: BE
answer Analysis:

D: According to the current news reports, many experts believe that: the current Boeing 737 MAX MCAS anti-stall system on the 8, read the wrong sensor data, in the absence of verification plus other mechanisms, to start the next head of the press action - the pursuit of correctness is not enough

5 multiple choice questions 2 points

About terminology to distinguish between error, fault, failure, what is said is not correct __

(Quibble means nothing, but still need to try to understand the "jargon" is valid)

A You will a.equals (b) wrote a == b, this is an error
thrown a bunch of red stack trace B program is running, this is a Fault
C You () by checking in checkRep assert xx RI this is to avoid introducing failure in ADT code
D debug locate you through the bug lies, which is to find the hidden Fault
E you fix a bug in the code, which is the elimination of error

The correct answer: BC

## multiple choice 6 2 points
configuration method for supporting comprises robustness ___

A used in the code the assertion
B last used checkRep in the method ()
C guarantee ADT does not appear REP explosure
D inspection pre-condition, if found to violate, to inform client, requires client data re-entry
E checking pre-condition, if it is found in violation, an exception is thrown, the program ends
F checks pre-condition, once the violation is thrown exception

The correct answer: D
// I think it is: ABDF

Fill in the blank question 7 1 minute

The highest-level interface in Java to handle errors and exceptions are [fill in the blank 1]
Wrong solution: Exception
just fill in the name of the interface, without having to bring the package name.

The correct answer: Throwable

Fill in the blank 8 2 points

ADT for sorting includes a Java interface or abstract class is [fill in the blank 1] or [fill in the blank 2]
the Comparable; Comparator
just fill interface / abstract class name without belt package name.

The correct answer:
Comparator; the Comparable

7-2 error and exception handling

2 minute multiple choice question 1

The following categories of error attributable ___?

A Java Virtual Machine can not allocate enough memory for the object, resulting in memory overflow
B because of a disk failure results in files unreadable
C because of the use of the index over the array length to read the data in the array, resulting in can not be read
can not find the time to run D the required class file

The correct answer: ABD

2 multiple choice questions 2 points

About Java exception handling statement is not correct __

A RuntimeException improper handling by the programmer in the code, the code is a potential bugs
B a RuntimeException addition, other sub-types of exception the Exception class are beyond the control of the programmer, the event can only wait for the program exit
exception C RuntimeException and its subclasses defined exception called an unchecked
D in addition to other exception RuntimeException and its subclasses can be attributed to the checked exception

The correct answer: B

3 multiple choice questions 2 points

The abnormality determination by name, belonging __ checked exception type

A NullPointerException
B NumberFormatException
C FileNotFoundException
D NegativeArraySizeException
E ClassCastException

The correct answer: C

Multiple choice question 4 2 points

About checked and unchecked exceptions, is not correct is __

A former requires try / catch, which is not required / necessary / should the try / the catch
B can customize the former new exception type, which is not
C former event, can not be remedied; the latter event, the programmer can to take measures to remedy the
D client developers prefer to use the latter; and if developers tend to use the former, make the code more concise and easier to read
E former regular code will be passed on together with the customers, the latter should not appear in the delivery code

The correct answer: BCDE
Answer Analysis:
A: Unchecked abnormalities can also use throws statement or try / catch capture, but most of the time is not needed, nor should it do so

B: Both can define new types, different from the parent class inherits

D: client wishes to use checked exceptions, because they can prompt a clearer error messages and remedy, avoid direct exit the program; if developers tend to use checked exceptions, it makes the code becomes more complex (try a variety of / catch). In comparison, using unchecked exceptions makes the code concise and easy to read (only in the field of abnormal throw new XxxException (...) you can)

E: unchecked Although it is impossible to recover, but if there are remaining issues in the code, inevitably throw unchecked exceptions, there are no deliveries are not delivered to a user says

5 1 minute multiple choice questions

The following statement is correct __

If A is not throws any checked exception, then the method subtype override a method declaration of the parent type, in the interior of the override any method throws exception or trap must be captured and processed in the method
B RuntimeException will not after then throws keyword appears in the method definition, it can certainly throw keyword does not appear in the method of
C if a method contains throw new xxException (...) such a code, the method of the kind of spec will include xxException throws
D a line of code calls a method methodA w, when using a throw throws checked exception spec methodA in, then the line must be included in w try-catch block

The correct answer: A

Answer Analysis:

Option A: If you do not understand why it is correct, consider LSP

Option B: RuntimeException is unchecked exceptions, but this relationship with throws and throw the word does not matter, they can appear to come, represents an exception is thrown.

Option C: unless xxException be checked exception, otherwise the method does not need to appear in the spec

Option D: Not necessarily, this line of code where the method can continue to capture the exception to throw it calls the client side, that is where the spec w method also has the same exception throws

This question is more obscure, carefully experience. (Although most of the rules are described here to help you do the static type checking, but you still have to understand the principle)

6 1 minute multiple choice questions

The following scenarios best suited checked exception is ___

A certain method, the client determines parameters passed in compliance with pre-condition the method
B of a method, prior to the return statement, determines which class where RI meets
C in the process of reading the file, the disk was found find the file on
bounds array access time D, for example, a [-1] = 0

The correct answer: C
Answer Analysis:

RI, pre-condition, post-condition, the best approach is assertion, the purpose is to fail fast, because this is a programming error (either the wrong client, or is the wrong developer)

Array bounds, is the same reason
pot is ABC program ape. client is a client, not a user
only option C, the pot is not a programmer, it would honestly try / catch it.

7 multiple choice questions 2 points

About Java try / catch / finally syntax, the following statement is not correct __

A try {...} If, after the second line code throws an exception, then the second row to try to "}" of the code will not be executed between
B try {...} If the code throws an exception, but not catch behind any captured {...}, the {...} in the finally statement is never
C finally {...} statements no longer throw and catch exceptions, and in which again should throw / try / catch statement
D If the syntax try (...) {...}, it is no longer a need to finally {...}

The correct answer: BC

8 1 minute multiple choice questions

JVM stack at a certain time as shown at right, and C is a method of performing checked exception thrown XX. The following statement is incorrect __
Here Insert Picture Description
A if C is not trapped untreated XX, XX is transmitted to the B
B C if not trapped untreated XX, the method declaration of B with the words of throws XX, XX is transmitted to the A
C if a, method of declaration of B are not words throws XX, the XX is captured to be treated in B
D If the exception XX is transmitted to the main and the main did not handle it, the program will be terminated, Console printing bleeding red stack trace

The correct answer: C

9 multiple choice questions 2 points

{the try
...
} the catch (XXException E) {
e.printStackTrace ();
Print (e.getMessage ());
}
for the code review of the code above, statement is correct __

A normal code, using try / catch catch and handle checked exceptions
B printStackTrace and print message has a duplicate, to OK a
C small significance, in addition to print output stack trace and error, not to do anything abnormal recovery processing
D if XX can not restore this anomaly, the best in print the next line plus throw YYException (...), YY is unchecked exceptions

The correct answer: CD

10 multiple choice questions 1 point

The following on "position" exception handling statement, the right is __

If a line A throw checked exception, the exception is preferably captured in the process of this code is located in, and recovery processing
B, if a line of code to throw checked exception, this method is not preferable in handling it, but it throws this method is called the client to be addressed
C if a line of code to throw checked exceptions, if you want to take other action to recover client exception is not processed in the method code resides in
D if a line of code throws an unchecked exception, but you do not want to exit the program, it is advisable to call this method throws to the client to be addressed

The correct answer: C
Answer Analysis:

The key to see what information is needed to restore checked exception, what information needs to be presented to the user. If the information can not be obtained in this method, the method in this or can get the information of an abnormality to the user worthless, an exception will be passed up.

Unchecked exceptions, it is best not propagate throws up. It represents a problem in your application code, site solution (and quickly modify the code to eliminate it). - Think about your physical education system in the ArrayIndexOutOfBoundsException, actually appeared in the UI

7-3 assertion of defensive programming (pending)

2 minute multiple choice question 1

_ The following is an effective means of defensive programming

A use of the type Checking Java's static
B as much as possible so that the ADT is immutable, rep for the final and private
checks the validity of the method parameter in the first line of C, in compliance with the spec-for condition Condition pre
D method called before the return of checkRep ()
E use unchecked exception found potential problems in the code
F to write spec, and then design the test case, and finally write the code, each code update all regression test

The correct answer: ABCDEF

2 multiple choice questions 2 points

The following statement regarding the assertion, is not correct _

A assert mainly used in the development stage, to help developers find potential errors in the code
B is added to a location assert statements in the code, for determining the conditions to be satisfied by running this program. If it is false, the error means that the code
behind the C assert can be followed by a parameter (determination condition), you can also have a second parameter (the Message)
D if the code assert statement too much, it will seriously affect the performance of code to run, so be careful use E assert statement once false, absolutely not restore the program, can only exit

The correct answer: D

3 multiple choice questions 2 points

The following __ occasion suitable for use assertion?

CheckPep A ()
B pre-condition checks whether the violation of the
C post-condition checks whether the violation of
D should not be executed in the program sequence where
whether the external file to check the presence of E
F check user input data through the keyboard is legitimate
if the communication network checks G

The correct answer: ABCD

1 minute multiple choice question 4

About similarities and differences and Exception Assertion of right is ___

A assertion in response to robustness, exception handling in response correctness
B if developers can expect some special cases may occur, with its assertion to be addressed
C if developers want some special circumstances must not take place, with its abnormal treatment to be addressed
D development stage with the assertion eliminate as far as possible bug in the release version with exception handling mechanism to deal with missing error

The correct answer: D

5 multiple choice questions 2 points

From defensive programming point of view, if the client calling a method when the input parameters do not meet the pre-condition, the following practices are inappropriate __

A spec by definition, developers can take any action to deal with illegal input parameter
B of illegal input parameters do intelligent processing, to make it into a legitimate input parameters, and then continues to calculate the
C assert statement will not be used directly out of the legal input parameters stand in, to the client presents an error message indicates
D throws an exception, show why the client parameter is not legal, what is the legal argument

The correct answer: AB

Fill in the blank 6 2 points

ADT for iterating functions and includes a client object to provide an iterator class is abstract Java interfaces or [fill in the blank 1] and [fill in the blank 2].

Simply fill interface or abstract class name without package with a name.

The correct answer:
Iterator; Iterable

Fill in the blank question 7 2 points

Implement the observer pattern for supporting Java interface or abstract class is [fill in the blank 1] and [fill in the blank 2]

Simply fill interface or abstract class name without package with a name.

The correct answer:
the Observer; Observable

7-4 Debugging

1 minute multiple choice question 1

_ Bug term is used first?

A Ada Lovelace
B Barbara Liskov
C Grace Hopper
D Margaret Hamilton

The correct answer: C

Multiple choice question 2 1 point

About assertion, exception handling, debugging, testing the relationship between these four technologies, including the inappropriate statement __

A use of assertions defensive programming, find the code of potential errors; the problem can not be prevented, resolved at runtime exception handling
B defensive programming can not avoid all the bug, to be discovered by testing other bug
C by assertion, checked exception and testing the need to find the bug and debug error by eliminating the positioning of
D these four methods are not a panacea, the code may still be hiding in the delivery of a large number of bug

The correct answer: C
Answer Analysis:
the Checked Exception is expected to take place and to be able to process, not a bug. Unchecked exception is used to help identify undesirable situation, that code is bug.

3 multiple choice questions 2 points

Why debug taking up almost 50% of the development time, the following are possible causes __?

A line of code where the error symptoms with "reason" caused by the offending line of code may be far apart, not even in the same source file
some reason by the timing bug B / timing as a result, the time is different, the symptoms appear on the bug may be different from
C multithreaded program execution because the thread interlaced (interleaving) randomness, resulting in a different order each execution, bug symptoms may disappeared the
D because the dynamics of the outside, makes it difficult to reproduce exactly the same as when performed multiple times the execution environment or user input

The correct answer: ABCD

1 minute multiple choice question 4

Lines may appear in the code added after log or print statements, the output value of certain variables, whether a bug is determined based on these values. The debug strategy is called __

A Instrumentation
B Divide and Conquer
C Program Slicing
D Delta Debugging

The correct answer: A

5 1 minute multiple choice questions

Two test cases, the test results are "pass" and "do not pass."
Then, use the code coverage tool EclEmma observe two lines of code coverage test cases to find out the differences between the two, bug is likely to hide differences in lines of code.
The debug strategy is called __

A Instrumentation
B Divide and Conquer
C Program Slicing
D Delta Debugging

The correct answer: D

6 1 minute multiple choice questions

If it is found in a variable of a function of a desired output is inconsistent, then the function code value of the variable part of the code could result in a change of careful analysis in order to find hidden bug. The debug strategy is called ___

A Instrumentation
B Divide and Conquer
C Program Slicing
D Delta Debugging

The correct answer: C

1 minute multiple choice question 7

After finding the root cause of a variety of bug debug strategy, bug fix. The following statement is most inappropriate __

A before modifying the code before the code you want to commit to the repository
B Each time a bug is best only for code modifications
C for a bug after modify the code before to re-run all the test cases found the bug, which has been confirmed whether the bug is fully repaired
D for a bug in the code modification, if not completely fix the bug, it is best not to modify the code commit to the warehouse

The correct answer: C

8 multiple choice questions 2 points

The following __ developers can find the root cause of bug to provide effective help

A git diff v1 v2
B Memory heap dump
C Print stack trace
D System.out.println()
E java.util.logging
F Set breakpoints and use step-by-step debugger
G End users’bug report

The correct answer: ABCDEFG

Published 113 original articles · won praise 1067 · Views 170,000 +

Guess you like

Origin blog.csdn.net/JAck_chen0309/article/details/105022489