To learn more about the .class file structure, have a look at chapter 5?(I think it's 5) of the JVM spec. Anyway, a .class file contains the bytecode for the compilation
unit. Therefore, if I have a .java file that contains a base and derived class, all the methods will be in that .class file. However, if I have the base and derived classes in different .java files, I will get 2 .class files. The .class file for the derived class will not contain the bytecode for the methods of the base class that it inherits.
The cost for invoking a method can differ if the method requires dynamic resolution. A static method is invoked with the invokestatic opcode where a method that requires dynamic resolution will use the more expensive invokevirtual opcode.
Peter Haggar
------------------
Senior Software Engineer, IBM
author of:
Practical Java