Exercises

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

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

B.7 (Instance Variables) Explain the purpose of an instance variable.

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

B.9 (Using a Class Without Importing It) Explain how a program could use class Scanner without importing it.

B.10 (set and get Methods) Explain why a class might provide a set method and a get method for an instance ...

Get Android™ How to Program, Second 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.