Edit Game
Anatomy of Classes in Java
 Delete

Use commas to add multiple tags

 Private  Unlisted  Public



 Save

Delimiter between question and answer:

Tips:

  • No column headers.
  • Each line maps to a question.
  • If the delimiter is used in a question, the question should be surrounded by double quotes: "My, question","My, answer"
  • The first answer in the multiple choice question must be the correct answer.






 Save   21  Close
True or False: The default value for an instance variable of type integer is 1.
False
True or False: The default value for an instance variable of type String is void.
False
True or False: The argument types in the method call must be identical to the types of the corresponding parameters in the method’s declaration.
True
True or False: To call a method of an object, follow the object name with a comma, the method name and a set of parentheses containing the method’s arguments.
False
True or False: When a method that specifies a return type other than void is called and completes its task, the method must return a result to its calling method.
True
Which of the following represents the final output of the code segment above?
22
True or False: Classes often provide public methods to allow the class’s clients to set or get private instance variables; the names of these methods must begin with set or get.
False
Write the line of code that declares a sideLength instance variable for a Square class that stores an integer value.
private int sideLength;
A method in a class that modifies information about an object is called a/an ________________ method.
mutator
A method in a class that returns information about an object but does not change the object is called a/an _________________ method.
accessor
The getMonth() method in the code segment above can be considered an/a _______________ method. (accessor/mutator)
accessor
Assuming that object birthday is an instance of the Date class, what is the correct way to call the getMonth() method?
birthday.getMonth()
Given class Counter above, what output is generated by the code segment?
2 1
You should declare all instance variables as ____________________.
private
Data required for an object's use are stored in _________________.
instance variables
When an object is created from a class, the object is called a/an ________________ of the class.
instance
The ______________ keyword is used to construct an object from a class.
new
The process of hiding object data and providing methods for data access is called ______________________.
encapsulation
Given the above class definition, which of the following are considered part of the class’s public interface?
updatePrice and designCode
Consider the above code segment. Class Date contains ______ instance variables.
3
Given class Counter, how many instances of the Counter class are created in the code segment?
2