Quiz 6

This quiz consists of True/False questions. The question is displayed, and then its answer is below.

The size of an array cannot be changed after it is declared

Answer True. Array lengths are fixed. Other data structures allow for more general sizing.



It is not possible to make a copy of an array, only a reference

Answer False. By default, arrays are copied by reference, not by value, but it is entirely possible to make a true copy with the "new" keyword.



“Immutable” means an object’s instance variables cannot be changed after the object is initialized

Answer True. Immutable objects can be overwritten but not changed directly.



An object is any class that has methods

Answer False. An object is an instance of a class. An object is to a class as your car is to the concept of a car.



The constructor for a class can be a public or a private method depending on how you want to implement the class

Answer Bad question. Basically, yes, a constructor can be public or private, but if you want to instantiate any objects off the class, the constructor must be public. So this really depends on what you mean.



An object’s private instance variables can be accessed by other members of the same class

Answer True. You can directly access instance variables of the same class.



An object’s private instance variables can be accessed by other classes

Answer False. You must write a method to return these values.