What is the difference between an executable file and a .class file?

1 answer

Answer

1248879

2026-03-08 02:25

+ Follow

Both are binary files but the differences between those are:-

1) we can execute an executable file while we cannot execute an object file.

2) An object file is a file where compiler has not yet linked to the libraries, so you get an object file just before linking to the libraries, so still some of the symbols or function definitions are not yet resolved which are actually present in the libraries, and that's why we cannot execute it.

Once an object file is linked with the library by the compiler, then all the symbols are resolved and we get an executable file which can be executed on the appropriate platform.

So basically the difference is that we get an object file when we don't link with library while executable file is with the linking phase.

In gcc we can direct compiler not to link with library and so it will prepare the object file :-

gcc -c test.c

It will automatically create test.o object file

when you try to execute it like:-

./test.o

cannot execute binary file

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.