CPSC 120
Class and Object Review Questions for Test 3

  1. We said that an object has two important properties: state and behavior. An object's state is defined by its _______________________. An object's behavior is defined by its _______________________.

  2. Explain the difference between how variables hold values of primitive types and how they hold objects.

  3. Consider the assignment statement x = y. Carefully explain what this does. Is is the same for objects and primitive values? Why is the effect different?

  4. What does it mean for two or more references to be aliases?

  5. When objects are passed as parameters, are the formal and actual parameters aliases?

  6. Explain the difference between static and instance variables.

  7. Explain the difference between static and instance methods.

  8. Can a static method use an instance variable? Explain.

  9. Can an instance method use a static variable? Explain.

  10. What does == do?

  11. What is overloading? When a method is overloaded, how does the compiler know which one to use?

  12. Suppose method foo has return type void.

  13. Suppose method bar has return type double.

  14. When should a method be public? Private?

  15. When should an instance variable be public? Private?

  16. What is the difference between a local variable and an instance variable?

  17. What is the difference between type int and type Integer?