Answer:
Class are the collection of variable and function.Class are the blueprint of an object.class are the logical entity.
Object are the physical entity .To access the properties of class we can create object of the particular class .We can create multiple object for a single class.
Step-by-step explanation:
In java we can create the class by using the class keyword
Following are the syntax of class
class classname
{
// function
public static void main(String args[]) // main method
{
// statement
}
}
In java the main method is inside the class .
In java object are created for a particular class by using "new " keyword.
Following are the syntax to create a object in java
classname objectname=new classname();
Let us consider a simple example of class and object in Java.
import java.io.*; // import package
class Text // creating class
{
public void fun() // memeber function fun()
{
System.out.println(" hello"); // print hello message
}
public static void main (String[] args)// main method
{
Text ob=new Text(); // creating object ob ..
ob.fun();//calling function fun by using object
}
}
output
hello