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

UML class diagram

Implementation of Class Circle

Implementation

UML Notations for creating Object

UML notation 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

student clas
Implementation of Class Student

student class implementation

Implementation of Class Student

 

student objects

Person Class Example

Class Example

Class Example

 

No Responses

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.