What is the purpose of an object's instance variables? correct answers To store the data for a
single instance of a class.
Suppose you want to work with objects of the Student class. What do you need to know? correct
answers The public interface of the class.
T/F: System.out is an object correct answers True
T/F: String is an object correct answers False
T/F: Suppose that a new version of Java is released, and that the Java compiler changes the way
that string objects store characters. If the string methods are updated accordingly, then you won't
need to change your code. correct answers True
Given class Counter below, how many instances of the Counter class are created in the code
segment that follows?
public class Counter
{
private int value;
...
public void count()
{
value = value + 1;
}
...
}
Counter points = new Counter();
Counter passengers = new Counter();
, points.count();
passengers.count();
points.count(); correct answers 2
Mutator method correct answers a method that changes the state of an object
Accessor method correct answers a method that accesses an object but does not change it
Consider the following code snippet.
public class Day
{
private int dayOfMonth;
private int month;
private int year;
...
public int getMonth()
{
...
}
...
}
Assuming that object birthday is an instance of the Day class, what is a correct way to call the
getMonth() method? correct answers int theMonth = birthday.getMonth();
Where does an object store its data? correct answers Instance Variables
Consider the following code snippet.