Sams Teach Yourself C in 21 Days

(singke) #1
Answers 877

F


Answers for Bonus Day 4

Quiz


  1. Type long.

  2. Yes, but they are called methods.

  3. Either whileordo...while.
    4 You use importto make other classes available in your Java program.

  4. There are three Java comment styles:

    • Anything between /and/is a comment.

    • Anything on a line after //is a comment.

    • Anything between /*and/is a comment.



  5. Java identifiers are case-sensitive, so countandCountrefers to two different
    things.

  6. Any type—there are no restrictions on data type in Java arrays.


Answers for Bonus Day 5

Quiz


  1. You have no choice in the matter. Constructor method always have the same name
    as the class they are in.

  2. Use extendsin the first line of a class definition to specify the parent class that the
    new class will inherit from.

  3. No. If the return type of a method is declared as void, the method does not return a
    value.

  4. Yes, as long as the different constructor methods all have a different number and/or
    type of arguments.

  5. When an instance of the class is created.

  6. No. If a class was created with the finalkeyword, it cannot be used as a parent
    class.

  7. The finalkeyword is used to prevent a class from being inherited from.

  8. No, an abstract class cannot be used to instantiate an object. You can, however,
    inherit from it.


49 448201x-APP F 8/13/02 11:22 AM Page 877

Free download pdf