Learn By Watch Exit Reader Mode

How to declare a class in JAVA

JAVA is a truly object oriented programming language. You can’t even write main function without class. Hence, it is necessary to learn to declare a class in JAVA. In this video Mr. Vineet Agrawal will show you how to declare a class in JAVA.

After watching this video you will be able to-

Syntax of class in JAVA

class class_name{
}

Basic structure of class

Class contains properties (member variables) and behavior (member function).
The java code given below shows a class with member variables and member functions.

class Employee{
int empID; //member variable
void setInfo(){  //member function with blank body.
}
}