O'Reilly logo

Programming with Java by Sunil Patekar, Mahesh Bhave

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 8

INTRODUCING CLASSES

So far, we have studied many basic features of Java. We know that Java is a highly object-oriented language. The study of this aspect of the language starts with the concept of class. Let us study classes step by step in this chapter.

8.1 Class Fundamentals

8.1.1 The general form of a class

Class can be considered as nothing but a user-defined type. It is a template for the object to be created. It holds some data. This data can be of different simple types we have studied earlier.

Let us take an example of time. It consists of hours, minutes, and seconds. To store these quantities, we need three different fields (variables). But together they constitute a single object.

A class in general has two types of members. ...

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