Game Preview

Accessor & Mutator Methods

  •  English    15     Public
    Identify and write codes for accessor and mutator methods in a class to allow client code to use and modify data.
  •   Study   Slideshow
  • Given class Counter above, how many instances of the Counter class are created in the code segment?
    2
  •  10
  • Given class Counter above, how many instance variables are created in the code segment?
    1
  •  10
  • Given class Counter above, how many instance methods are created in the code segment?
    1
  •  10
  • Given class Counter above, what is the type of count() method in the code segment? (accessor or mutator)
    mutator
  •  10
  • Name the instance methods that are available in class Counter.
    getValue() and count()
  •  10
  • Given class Counter above, what is the type of getValue() method in the code segment? (accessor or mutator)
    accessor
  •  10
  • How many instance variables are created in the code segment above?
    3
  •  10
  • Consider the above code segment. What is the return type of the getDay() method?
    int
  •  10
  • How many parameters does the getDay() method have?
    0
  •  10
  • The process of hiding object data and providing methods for data access is called ______________________.
    encapsulation
  •  10
  • True or False: The coinName variable can be accessed only by methods of the Coin class.
    True
  •  10
  • True or False: setVehicleAttributes is an accessor method.
    False
  •  10
  • How many accessor methods do you see in the code segment above?
    2
  •  10
  • What is the return type of getModelName() method?
    String
  •  10
  • You should declare all instance variables as ____________________.
    private
  •  10