O'Reilly logo

Java, A Beginner’s Guide, 5th Edition by Herbert Schildt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 4: Introducing Classes, Objects, and Methods

1. What is the difference between a class and an object?

A class is a logical abstraction that describes the form and behavior of an object. An object is a physical instance of the class.

2. How is a class defined?

A class is defined by using the keyword class. Inside the class statement, you specify the code and data that comprise the class.

3. What does each object have its own copy of?

Each object of a class has its own copy of the class’ instance variables.

4. Using two separate statements, show how to declare an object called counter of a class called MyCounter.

Image

5. Show how a method called ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required