How to declare a class in JAVA

0
85

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-

  • – Declare a class in JAVA
  • – Choose correct name for the class in JAVA
  • – Explain the structure of a class
  • – Define class properties
  • – Define class methods

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.
}
}
Was this post helpful?
Let us know, if you liked the post. Only in this way, we can improve us.
Yes0
No0
Previous articleException handling using Try Catch in JAVA
Next articleHow to set background color of an Applet in JAVA
An educational consultant Vineet Agrawal is a director and founder of Solution Center, Agra. He has been providing training for last 17 years. He has trained 1000s of students of the software industry. He has been actively involved in final year projects of B.Tech. (CS /IT). The programs included in this video series are based on his experience of teaching that will help you in cracking a java interview.

Leave a Reply