Class and Object Review Questions for Test 3
- 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 _______________________.
- Explain the difference between how variables hold values of primitive
types and how they hold objects.
- Consider the assignment statement x = y. Carefully explain what this
does. Is is the same for objects and primitive values? Why is the effect
- What does it mean for two or more references to be aliases?
- When objects are passed as parameters, are the formal and actual
- Explain the difference between static and instance variables.
- Explain the difference between static and instance methods.
- Can a static method use an instance variable? Explain.
- Can an instance method use a static variable? Explain.
- What does == do?
- What is overloading? When a method is overloaded, how does the compiler
know which one to use?
- Suppose method foo has return type void.
- Can foo be used as a statement?
- Can foo be used as an expression?
- Will foo have a return statement?
- Suppose method bar has return type double.
- Can bar be used as a statement?
- Can bar be used as an expression?
- Will bar have a return statement?
- When should a method be public? Private?
- When should an instance variable be public? Private?
- What is the difference between a local variable and an instance variable?
- What is the difference between type int and type Integer?