Preview

03 - Documentation with Comments

 1. The Java language supports three types of ___________.
1	
/* text */

The compiler ignores everything from /* to */.

2	
//text

The compiler ignores everything from // to the end of the line.

3	
/** documentation */

This is a documentation comment and in general its called doc comment. The JDK javadoc tool uses doc comments when preparing automatically generated documentation.

  documents

  text strings

  comments

  implementation

 2. Read the following statement and fill in the blanks. What is it describing?
__________is a tool which comes with JDK 
and it is used for generating Java code
documentation in HTML format from Java
source code, which requires documentation
in a predefined format

 3. There is a description part in the following program. We note that the description contains ____________.
/**
* 

Hello, World!

* The HelloWorld program implements an application that * simply displays "Hello World!" to the standard output. *

* Giving proper comments in your program makes it more * user friendly and it is assumed as a high quality code. * * * @author Ruth Marvin * @version 1.0 * @since 2021-03-31 */ public class HelloWorld { public static void main(String[] args) { // Prints Hello, World! on standard output. System.out.println("Hello World!"); } }

  line spaces

  syntax errors

  Html tags

  single stars that will generate errors

 4. The javadoc tool recognises various tags. The @author tag:

  creates an author using line numbers to generate a random integer

  checks to see if there is an author behind any given class

  adds the author of a class using the syntax @author name-text

  prompts the user to ask for an author

 5. Identify the tag that relates to the description below.
Represents the relative path to the generated document's root directory from any generated page.

  Tag:@return

  Tag: {@docRoot}

  Tag:{@inheritDoc}

  Tag:@param

 6. Identify the tag that relates to the description below.
Inherits a comment from the nearest inheritable class or implementable interface.

  Tag: {@docRoot}

  Tag:@param

  Tag:@return

  Tag:{@inheritDoc}

 7. Identify the tag that relates to the description below.
Adds a parameter with the specified parameter-name followed by the specified description to the "Parameters" section.

  Tag:@return

  Tag:{@inheritDoc}

  Tag:@param

  Tag: {@docRoot}

 8. Identify the tag that relates to the description below.
Adds a "Returns" section with the description text.

  Tag:@return

  Tag: {@docRoot}

  Tag:{@inheritDoc}

  Tag:@param

 9. When {@value} is used in the doc comment of a static field, it displays ____________________.

  the value of the comment, that is, the description itself

  the value of that constant.

  the value of the field, if it is an integer

  the value contained in the constructor

 10. Java language specification defines a special type of comment known as a doc comment that serves to document the API of your code.

  FALSE

  TRUE

 11. Documentation comments for classes, interfaces, methods, constructors, and fields appear in Java source code immediately after the definitions of the features they document.

  FALSE

  TRUE

 12. You can also provide high-level documentation for a group of packages by defining an _________ file in the source tree for those packages.

  cast.html

  manage.html

  file.html

  overview.html

 13. Using comments is good practice, as you (and others) will be able to look back at your code and ______________.

  speed it up as documentation creates efficiency

  compile it with greater efficiency

  understand it better

  delete it

 14. The beauty of javadocs is that it can take all the comments on all Java elements and convert them into standardized, nicely formatted, easy-to-read _____________.
For example: In Eclipse, simply typing "/**" before a method or class will automatically generate in all necessary @param and @return attributes.

  objects

  web pages

  constructor classes

  strings

 15. Is the following statement true of implementation and documentation comments?
Implementation and Documentation comments
=========================================
Implementation comments describe the semantics
of a class, field, or method. Good implementation
comments should allow you to use the class and 
its methods without having to read any source code. 

In contrast, documentation comments are used to 
clarify how a particular piece of code operates.

  TRUE

  FALSE