Skip to main content
Logo image

Java, Java, Java: Object-Oriented Problem Solving, 2022E

Section 2.8 Chapter Summary

Subsection 2.8.1 Technical Terms

access modifier method call and return
class-level variable null pointer
default value null pointer exception
delimiter pointer
empty string reference
flow of control reference variable
interface static modifier
local variable user interface

Subsection 2.8.2 Important Points

  • Dot notation is used to refer to an object’s public elements.
  • Designing a class is a matter of deciding what role it will play and what information and actions it will have.
  • Writing a Java program is a matter of defining one or more classes. A class definition serves as a template for creating instance of the class.
  • Classes typically contain two kinds of elements, variables and methods. An object’s state is defined by its instance variables.
  • Class elements that are declared public can be accessed by other objects. Elements that are declared private are hidden from other objects.
  • A class’s instance variables are usually declared private so they cannot be accessed directly by other objects.
  • An object’s public instance methods can be called by other objects. Thus, they make up the object’s interface with other objects.
  • Object instantiation is the process of creating an object, using the new operator in conjunction with a constructor method.
  • A class definition consists of a header and a body. The header gives the class a name, specifies its accessibility (public), and its place in the Java class hierarchy (extends Object). The class body contains declarations of the class’s variables and definitions of its methods.
  • By default, a newly defined class is consider a subclass of Object.
  • Class elements that are declared static, such as the main() method, are associated with the class(not with its instances).
  • A Java application program must contain a main() method, which is where it begins execution.
  • Methods that are used solely for the internal operations of the class should be declared private.
  • An instance variable declaration reserves memory for the instance variable within the object, associates a name and a type with the location, and specifies its accessibility.
  • A method definition consists of two parts: a header, which names the method and provides other general information about it, and a body, which contains its executable statements.
  • Declaring a variable creates a name for an object but does not create the object itself. An object is created by using the new operator and a constructor method.

Solutions 2.8.3 Solutions to Self-Study Exercises

2.4 Class Definition
2.4.5 Define, Create, Use

Self-Study Exercises
2.4.5.2. Riddle Instance Variables.

2.5 CASE STUDY: Simulating a Two-Person Game
2.5.3 Testing the OneRowNim Class

Self-Study Exercises
2.5.3.1. Add Hint to Riddle Class.

2.7 From the Java Library: java.util.Scanner
2.7.3 Exceptions

Self-Study Exercise
2.7.3.1. TestScanner for Decimals.
You have attempted of activities on this page.