Exercises
3.5 (Keyword new) What’s the purpose of keyword new? Explain what happens when you use it.
3.6 (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 (Instance Variables) Explain the purpose of an instance variable.
3.8 (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?
3.9 (Using a Class without Importing It) Explain how a program could use class Scanner without importing it.
3.10 (set and get Methods) Explain why a class might provide a set method and a get method for an instance variable.
3.11 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access