Java Object and Class



Class

Class is a collection of similar type of objects which have
some common properties. 

Also class contains

Variables / data members
Inner/sub classes
Constructor
Methods
Static variable / methods

If abstract class in the sense it can contain abstract method();


  
Object

Object is any real world entity which have physical
existence either living or non-living.
Object is a blueprint of an class.






Example:

Class Demo
{

int a= 10;       // variable a & b is now object inside the Demo class
int b= 10;
String name = "world";

Void methodName()       //its an object inside the Demo class
{
System.out.println("Hi...");
}
}

public class MainClass
{
public static void main(String args[])
{
Demo objref = new Demo();
objref.mehodName();
}
}




Search This Blog

Video of the Day