Define Classes and Objects in Java
This tutorial will help you to define your own classes, including a set of data fields, methods, constructors, using classes by creating objects and invoke methods.
Class
A class describes the structure and behavior of similar objects. It is also described as a blue print, pattern, generalized , template and description of an realword object.
once a class is defined then a specific instance of class can defined by creating the object of the class. Where as object has a unique identity, state and behaviours.
State of an object is represented by data fields also know as the properties with their current values.
Behavior of an object is defined by a set of methods, invoking a method means an object have to perform a specific task.
UML Class Diagram of Class Circle
Implementation of Class Circle
UML Notations for creating Object
Creating Objects with java
Circle circle1 = new Circle(10);
Circle circle2 = new Circle(25);
Circle circle3 = new Circle(125);
Another Example :
UML Class Diagram for Student
Implementation of Class Student
Implementation of Class Student
Person Class Example
No Responses