1. Create more than one class in single java program file.
  2. Execute the appropriate .class file, if more than one .class files are created after compilation.
  3. Access one class member into another class.
  4. Explain why more than one .class files are created after compilation of java program.

Create Two Classes in JAVA video tutorial (Hindi)

Vineet Agrawal

Published on January 12, 2017

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.
You can see use of two classes in this java program.


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();
	  }
   }
This content is part of the following course: 
Tags: 
Frequently Asked Questions
Required Components