API (Application programming interface): API (Application programming interface) is a set of routines and classes provided by libraries to perform specific task. Java contains rich set of libraries that supports building of an application such us swing, awt, sql, etc.
Byte code: The Java source code is compiled into a intermediate form called byte code. The Java compiler reads Java language source (.java) files, translates the source into Java bytecodes, and places the bytecodes into class (.class) files. The compiler generates one class file for each class contained in java source file. Bytecode is a highly optimized set of instructions designed to be executed by the JRE system, which is called JVM (Java Virtual machine). JVM is software that interprets the byte code into underlying machine code and run the program.
The Java introduces the concept of WORA (write once run anywhere); it means java byte code can be run on any platform without compiling it again. When we write a program in C++ then C++ compiler translate the source code into machine code of underlying system. Later, if we want to run the C++ program on different operating system then we have to compile it again with compiler provided by underlying operating system.
Machine code: The machine code or native code is code that after you compile it, the compiled code runs on a specific hardware platform. When we write a program in C++ then C++ compiler translates the source code into machine code of underlying system.