Exercises
7.4 (Keyword
new
) What’s the purpose of keywordnew
? Explain what happens when you use it.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?
7.6 (Instance Variables) Explain the purpose of an instance variable.
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
andString
without first importing them?7.8 (Using a Class without Importing It) Explain how a program could use class
Scanner
without importing it.7.9 (set and get Methods) Explain why a class might provide a set method and a get method for an instance variable.
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.