A Java course file is a document containing Java bytecode and having .class extension that can be executed by JVM. A Java class document is created by a Java compiler indigenous .java files as a an outcome of successful compilation. As we know that a solitary Java programming language source file (or we can say .java file) might contain one class or more than one class. For this reason if a .java file has much more than one course then each course will compile right into a separate class files.

You are watching: The .class extension on a file means that the file

For Example: conserve this below code as Test.java on your system.
Attention reader! Don’t stop learning now. Acquire hold of all the necessary Java Foundation and Collections concepts with the Fundamentals that Java and also Java collection Course at a student-friendly price and become market ready. To finish your preparation from discovering a language come DS Algo and many more, you re welcome refer Complete Interview ready Course.
For Compiling:javac Test.javaAfter compilation there will certainly be 3 class papers in matching folder named as:


A single class file structure contains characteristics that explain a class file.Representation that Class record StructureClassFile magic_number; minor_version; major_version; constant_pool_count; constant_pool<>; access_flags; this_class; super_class; interfaces_count; interfaces<>; fields_count; fields<>; methods_count; methods<>; attributes_count; attributes<>;Elements of class paper are together follows:magic_number: The an initial 4 bytes the class record are termed together magic_number. This is a predefined worth which the JVM usage to determine whether the .class file is generated by valid compiler or not. The predefined value will it is in in hexadecimal form i.e. 0xCAFEBABE.Now let’s check out what happen when JVM will certainly not uncover valid magic number. Suppose we have a .java file named together Sample.java together follows and follow action by step process on her system.// course Declarationclass Sample public revolution void main(String<> args) System.out.println("Magic Number"); Step 1: Compile making use of javac Sample.javaStep 2: now open the Sample.class file. It will looks like following.Sample.class FileStep 3: currently erase at least solitary symbol indigenous this Sample.class file from beginning of paper and conserve it.Step 4: Now try to operation this using java Sample command and see the magic i.e. Friend will gain run time exception (See the highlighted message in below image):Runtime Exception due to Invalid magic numberNote: This deserve to vary depending on how much you remove the .class document data.

minor_version & major_version: these both with each other represents .class file version. JVM will usage these version to identify which variation of the compiler generates the present .class file. We denotes the version of class paper as M.m wherein M stands for major_version and also m means minor_versionNote: reduced version compiler produced .class paper can be enforcement by high variation JVM but greater version compiler created .class record cannot be enforcement by lower version JVM. If we will shot to execute we will gain run time exception.This demonstrate is for windows OS as follows:Step 1: open a command prompt home window and shot to inspect java compiler version and also JVM version using following regulates respectively (Highlighted text in picture are the commands)Output because that 1.8 variation will be:Java Compiler VersionJVM VersionStep 2: Now inspect with an additional version which may be higher or lower than already installed.thisDownload link.And download this come your computer or laptops and note the installation address.Step 3: open a 2nd command prompt home window and collection the course of bin folder of mounted jdk mounted during second step. And also check for Java compiler version ad JVM version.Checking version of JDK 1.6Step 4: currently on 1st command prompt translate in the any kind of valid .java file. For example: See above Sample.java file. Compile it as:Compiling v Compiler version 1.8Step 5: now on second command note window try to run the above compiled code class document and watch what happen. Over there is a run time exemption which I have highlighted in listed below image.Runtime Exception due to Invalid major and minor version of course fileNote: inside jdk 1.5 version method 49.0 and 1.6 method 50.0 and 1.7 way 51.0 etc. Class paper version whereby the digits before the decimal suggest represent the major_version and digits after decimal allude represents the minor_version.constant_pool_count: It to represent the variety of the constants existing in the consistent pool (When a Java document is compiled, all recommendations to variables and also methods are stored in the class’s continuous pool together a symbolic reference).constant_pool<>: It represents the information around constants present in consistent pool file.access_flags: It provide the information around the modifiers i m sorry are claimed to the class file.this_class: the represents fully qualified surname of the course file.super_class: it represents completely qualified surname of the instant super course of current class. Consider above Sample.java file. As soon as we will compile it, climate we can say this_class will certainly be Sample class and also super_class will be Object class.interface_count: It return the variety of interfaces applied by current course file.interface<>: It returns interfaces information imposed by current class file.fields_count: It to represent the number of fields (static variable) current in current course file.fields<>: it represent fields (static variable) information existing in current class file.method_count: the represents number of methods present in current class file.method<>: It returns information about all methods present in current class file.attributes_count: It returns the number of attributes (instance variables) current in current course file.

See more: Have Any Of Lisa Gardner Books Made Into Movies ? Lisa Gardner

attributes<>: It gives information around all attributes present in current course file.