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

Similar Program

# Program Language
1 Java
2 Java
3 Java
4 Java
5 Java
6 Java
7 Java
8 Java
9 Java
10 Java
11 Java
12 Java
13 Java
14 Java
15 Java
16 Java
17 Java
18 Java
19 Java
20 Java
# Program Language