1.13 Object Creation and Storage (Instantiation)

2 阅读1分钟

1. Exam Points

  • Create an object by using the new keyword and calling a constructor.
  • Identify which constructor is called (depends on the arguments passed).
  • Arguments passed should match the parameters (type and number).
  • declare constructors, call constructors, create objects.
  • static variables can be used to count objects created.

2. Knowledge Points

(1) Create Objects(Instantiation)

  • An object is typically created using the keyword new followed by a call to one of the class’s constructors.
  • Example:
    image.png image.png

3. Exercises