Documentation with Comments - AP Computer Science A

  1. What is the recommended use of comments in simple code?
    Minimal use to avoid clutter. Simple code is often self-explanatory.
  2. Identify the symbols used to start a Javadoc comment.
    /**. Three characters start documentation comments.
  3. Find and correct the comment error: // Missing end.
    No correction needed; single-line comment. Single-line comments don't need closing delimiter.
  4. Which character sequence is used to start a Javadoc comment?
    /**. Three characters including asterisk start Javadoc.
  5. Which Javadoc annotation is used to describe exceptions thrown by a method?
    @throws or @exception. Documents possible exceptions the method throws.
  6. Which type of comment is suitable for method-level explanations?
    Javadoc comments. Javadoc provides formal method documentation.
  7. Which comment type is typically used to explain complex logic?
    Multi-line comments. Block comments handle detailed explanations.
  8. What is the role of the @deprecated annotation in Javadoc?
    Indicates a deprecated method or class. Warns that feature should not be used.
  9. What is the result of incorrect Javadoc syntax?
    Errors in generated documentation. Invalid Javadoc produces malformed documentation.
  10. Identify the effect of outdated comments in code.
    Can mislead developers. Outdated comments provide incorrect information.
  11. Which comment type is ignored by the Java compiler?
    All comment types. Compiler ignores all comment content.
  12. What is the consequence of omitting comments in complex code?
    Difficulty in understanding and maintaining. Complex code needs explanation for clarity.
  13. Identify the structure of a single-line comment.
    Begins with // and extends to the line end. Single-line comments end at line break.
  14. Identify the Javadoc annotation used to link to related topics.
    @see. Creates cross-references in documentation.
  15. Which comment type is preferred for inline explanations?
    Single-line comments. Single-line comments work well inline.
  16. What is the purpose of the @since tag in Javadoc?
    Indicates the version since a feature was added. Documents when feature was first introduced.
  17. What Javadoc annotation is used to describe the return value of a method?
    @return. Documents what the method returns.
  18. What symbols are used to start and end a multi-line comment in Java?
    /* to start and */ to end. Multi-line comments span across multiple lines.
  19. Identify the comment type used to temporarily disable code.
    Single-line or multi-line comments. Both types can comment out code sections.
  20. What annotation is used in Javadoc to describe a method parameter?
    @param. Documents method parameters with descriptions.
  21. Find and correct: "// This is a multi-line comment."
    Use /* ... */ instead. Multi-line syntax handles line breaks properly.
  22. What is the impact of excessive comments in code?
    Can clutter code and reduce readability. Too many comments distract from code logic.
  23. Which type of comment is used for detailed documentation in Java?
    Multi-line comment (/* ... */). Block comments handle longer descriptions effectively.
  24. Which Javadoc tag is used to document the author of a class?
    @author. Documents who created the class.
  25. Find and correct the comment error: /* Incorrect comment.
    Close with /: / Incorrect comment */. Multi-line comments need closing delimiter.
  26. What is the primary purpose of comments in Java code?
    To enhance code readability and explain logic. Comments make code easier to understand for developers.
  27. Identify the recommended practice for writing comments.
    Clear, concise, and relevant. Good comments are helpful without being verbose.
  28. Which comment type is visible in generated Javadoc HTML files?
    Javadoc comments. Only Javadoc appears in generated documentation.
  29. Which type of comment is typically used for brief explanations in Java?
    Single-line comment (//). Double slash is quick for short explanations.
  30. What does the @version tag in Javadoc represent?
    Version information of a class or method. Tracks version number of the code.
  31. Identify the main difference between // and /* comments.
    // is single-line, /* is multi-line. Single-line extends to end, multi-line spans blocks.
  32. Which comment type should be used for writing method descriptions?
    Javadoc comments. Javadoc provides formal method documentation.
  33. What is the effect of not using comments in code?
    Reduced code readability and maintainability. Code becomes harder to understand and modify.
  34. Which comment type is used to block out code sections?
    Multi-line comments. Multi-line comments disable code sections.
  35. Identify the symbol used for single-line comments in Java.
    //. Double forward slash creates single-line comments.
  36. What is the primary use of Javadoc comments?
    To generate documentation for Java classes. Javadoc creates HTML documentation automatically.
  37. Identify the comment type that supports tags like @param and @return.
    Javadoc comments. Javadoc supports special documentation tags.
  38. Identify the use of @author in Javadoc.
    Indicates the author of a class or method. Documents who wrote the code.

Study these flashcards