Review Quiz

  1. What is the difference between the & and && operators?
  2. What is the difference between the pre and post forms of the increment and decrement operators? Write an example of each.
  3. Explain what the heap and the stack are in the Java Virtual Machine.
  4. Imagine a method with this signature:
    public class MyClass    
    {     
        public void myMethod(int x, SavingsAccount sa)
        {
            x = 14;
            sa.setBalance(1000);
        }         
    }
             
    Write a snippet of code that calls the method. Draw a picture of the stack and the heap. You can assume the SavingsAccount class has a zero-argument constructor.
  5. Discuss what the static modifier does on a method definition. How do you call a static method? Write an example.