What is .class File and Bytecode in Java?

This instructional exercise will assist you with learning about what is .class record and bytecode in java language.

You may get a kick out of the chance to peruse past instructional exercise about

How to Write, Compile and Run Your First Java Program?

What is .class File and Bytecode

  • At the point when Java source document is gathered by Java compiler, it is changed over into Java class record with .class augmentation.
  • The Java class document contains Java bytecode (exceptionally advanced arrangement of directions) which is executed by Java Virtual Machine (JVM).
  • .class document contains images and each bytecode guidance is put away into one byte precisely.
  • .class document of each class is independently put away. Its name is same as class name in the source record.
  • A Java program can have any number of classes. On the off chance that beneath program is accumulated, at that point, two .class documents will be made with name A.class and B.class.
class A
{


public static void main(String…s)


{


System.out.println(“A”);


}


}





class B
{


public static void main(String…s)


{


System.out.println(“B”);


}


}
  • A .class document can be executed on any working framework; we simply need JVM of that working framework. This makes Java machine free.

Difference Between .class File in Java and .exe File in C/C++

.class .exe
It contain bytecode directions for Java Virtual Machine (JVM).It contains machine code directions for Operating System.
Platform independent. Platform dependent.
It can be converted into source code. It can’t be converted into source code.
The .class document can’t be executed straightforwardly so infections can’t be connected to it and consequently secure.The .exe document can be executed straightforwardly so infections can be connected to
it and consequently unreliable.

Leave a Comment

error: Alert: Content is protected!!