Exercises

  1. 7.4 (Keyword new) What’s the purpose of keyword new? Explain what happens when you use it.

  2. 7.5 (Default Constructors) What is a default constructor? How are an object’s instance variables initialized if a class has only a default constructor?

  3. 7.6 (Instance Variables) Explain the purpose of an instance variable.

  4. 7.7 (Using Classes without Importing Them) Most classes need to be imported before they can be used in an app. Why is every app allowed to use classes System and String without first importing them?

  5. 7.8 (Using a Class without Importing It) Explain how a program could use class Scanner without importing it.

  6. 7.9 (set and get Methods) Explain why a class might provide a set method and a get method for an instance variable.

  7. 7.10 ...

Get Java How To Program, Late Objects, 11th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.