What is a class in Object Oriented Programming ?

Classes are fundamental or basic unit in Object Oriented Programming. A class is kind of blueprint or template for objects. Class defines variables, methods. A class tells what type of objects we are creating.

For example take Department class tells us we can create department type objects. We can create any number of department objects. All programming constructs in java reside in class. When JVM starts running it first looks for the class when we compile. Every Java application must have at-least one class and one main method. Class starts with class keyword. A class definition must be saved in class file that has same as class name. File name must end with .java extension.

If we see the above class when we compile JVM loads the FirstClass and generates a .class file (FirstClass.class). When we run the program we are running the class and then executes the main method.