JAVA is truly object oriented programming language this mean you need to write Main function inside a class. Best practice in this case is to create a class only for main function and access all other class members from this class. This creates the need of creating more than one classes. In this video you will learn how to create two classes and how to run the program.

Syntax :-


class employee
  {
	  int empID=5;
	  void showEmpID()
	  {
		  System.out.println(empID);
	  }	  
   }
   class company
   {
	   public static void main(String args[])
	  {
		  employee e; // object declaration
		  e=new employee();
		  e.showEmpID();
	  }
   }
 

Ratings

  • Rate this
  • Summary
Current Average Ratings
Cognitive
Avg: 0/5
Affective
Avg: 0/5
Create Two Classes in JAVA
Total Avg Rating: 0.00 out of 5 with based on 0 rating(s)
Cognitive
Affective
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