Java Object And Class Example


Object

Anything that has a state and behavior is known as an object. For example, a pencil, chair, mouse, keyboard, mobile, etc.

An object is created from the class.

Class

A class is a collection of objects.

Program
public class ObjectExample { public void m1(){ System.out.println("Hello Fresherbell"); } public static void main(String[] args) { ObjectExample message = new ObjectExample(); message.m1(); } }
Input
Output