Writing Classes Exercises

  < Previous  Next >
  1. How do we instantiate an object?
  2. What is special about the return type for a constructor? Why?
  3. Given the following class Vehicle, write Java code to instantiate two or more Vehicle objects:
    public class Vehicle{
    
        private String make;
        private String model;
    
        public Vehicle( String makeIn, String modelIn ){
            make = makeIn;
            model = modelIn;
        }
    }
    
  4. Discuss with someone else what new does
  5. What is appropriate to go into the public interface of a class? (see Java, Java, Java Section 1.3.2 (and 0.7.9))