When Java source file is compiled by Java compiler it is converted into Java class file with .class extension.
The Java class file contains Java bytecode (highly optimized set of instructions) which is executed by Java Virtual Machine(JVM).
.class file contains symbols and each bytecode instruction is stored into one byte exactly.
.class file of each class is separately stored. Its name is same as class name in source file. A Java program can have any number of classes.
Difference Between ByteCode and Machine Code
Byte code is similar to machine code (but not machine code) which can be understood by a run-time system.
It is sort of a programming language (as machine code also is) which is interpreted by a run-time system so that the code can be executed on a system.
The run-time system ultimately turn those Byte code into actual machine code while it executes them on the computer.
For example, Java(Programming language) compiles its program to Byte code. Then Java Runtime System (JRE) interprets those Byte code into machine code when it runs on Java Virtual Machine (JVM), the underlying system. JVM is the underlying system which interacts with the operating system on the computer whenever a piece of Java Byte code is being run. JVM manages resources (e.g - garbage collection) on behalf of the program being executed.
The advantage of Byte code is that it only depends on the run-time system and the virtual machine it is being run on. Therefore, it is platform-independent.