4.Classes and Objects in Java

Two fundamental concepts in object-oriented programming are that of classes and objects.A class can be regarded as an object template: it describes how an object looks and operates.
We may have a bank account class that holds details such as account number, account name, and balance. These are defined by member variables that are said to define the state of the class.

Examples of operations associated with the bank account class are making a deposit or a withdrawal. Operations, or methods in object-oriented terminology, are said to define the behavior of a class. An object is an instance of a class. Corresponding to our bank account class, each individual bank account would be an object: fredsAccount, say, would be an object holding bank account details for the individual Fred. The following sections illustrate all the preceding concepts with Java code.

No comments:

Post a Comment