declaring an object in java from a different class code example Example 1: java create new object Car mycar = new Car(); Example 2: create instance object java myCar = new Car();