Professional Documents
Culture Documents
Chapter 9
Objects and Classes
Banking system:
• Build an application (program) that will keep
track of all banking information such as user
account information, transaction details,
balance, customer listing, etc.
Enter
Enter Account Enter Account
Enter Account No. Account No.
No. No.
1. Deposit
2. Withdraw
Account
Info
Circle(double newRadius) {
radius = newRadius;
}
new ClassName();
Example:
new Circle();
new Circle(5.0);
ClassName objectRefVar;
Example:
Circle myCircle;
yourCircle.radius = 100;
yourCircle.radius = 100;
Create a circle
yourCircle.radius = 100;
yourCircle no value
Declare yourCircle
yourCircle.radius = 100;
yourCircle no value
Create a new
Circle object
yourCircle.radius = 100;
yourCircle.radius = 100;
Change radius in
yourCircle
to invoke a method in the Math class. Can you invoke getArea() using
Circle.getArea()? The answer is no. All the methods used before this
chapter are static methods, which are defined using the static keyword.
However, getArea() is non-static. It must be invoked from an object
using
To protect data.