Lab 3 – Programming Style and Documentation

Post Test

 

Lab Section:

 

Name:

 

 

 

Knowledge/Memory

 

1.      Javadoc comments begin with the special marker /**. True or false?

 

a. True

b. False

 

Answer: a

 

2.      Comments can be used to:

 

I.                    Explain code whose purpose may not be obvious.

II.                 Compensate for poorly written code.

III.               Summarize a block of code.

IV.              Identify temporary code.

 

  1. I, II & III
  2. II & IV
  3. I, III & IV
  4. I, II, III & IV

 

Answer: c

 

3.      Wrong documentation is better than no documentation at all. True or false?

 

  1. True
  2. False

 

Answer: b

 

4.      You can put a comment inside another comment. True or false?

 

a.       True

b.      False

 

Answer: b

 

5.      Where is the best place to write a summary description for a method?

a.       As the first sentence of a Javadoc comment for the method.

b.      As the last sentence of a Javadoc comment for the method.

c.       In the middle of a Javadoc comment for the method.

d.      Anywhere in the program.

e.       It is not necessary to write a summary description for a method.

 

Answer: a.

 

Comprehension:

 

6.  Which of the following variable names is the best example of a self-documenting variable name?

 

  1. acct
  2. a
  3. accountNumber
  4. acctNo

 

Answer: c

Application

 

7. Which of the following is not a good coding practice?

 

a.       Choose meaningful names for classes and methods.

  1. Document everything, even if what the code does is obvious.
  2. Use white space.
  3. Avoid duplicate code in different places.

 

Answer: b

 

8.  For what audience should Javadoc comments be written?

  1. Developers who use or call the code in their own programs.
  2. Someone who is trying to execute the code.
  3. A person who is considering the purchase of a program that was built using the code.
  4. Developers who maintain the code.

   Answer: a

 

Analysis

 

 

 

9. What is output by the Javadoc program?

 

I.                    HTML files containing the program’s documentation.

II.                 An index.

III.               A hierarchy tree.

IV.              Java source code.

 

 

Answer: d

 

Synthesis / Evaluation

 

10. Javadoc comments are useful because:

 

I.                    They allow us to automatically document our code.

II.                 They eliminate the need for other types of comments.

III.               They allow us to easily generate documentation based on information included in the Java source code.

IV.              They generate Java code that can be used by other programmers.

 

 

 

     Answer: c