Objects are instances of class. We can say that object is variable of class type. Memory for instance declaration rather at the time of class declaration rather than time of object creation. Thus we can say that objects have physical existence and classes are only concepts.
Syntax:
[Access Modifier] className{
// body
}
Creating Object
Syntax:
[className] [objectName] = new [className]();
Program
class Demo{ void display(){ System.out.println("Class Example"); } public static void main(String args[]){ Demo obj = new Demo(); obj.display(); } }
Post a Comment