L0: Introduction to java programming

Q1. What is programming ?

The process of developing and creating a program to carry out a given task is known as programming. A program is a set of instructions written in a specific language. Hence, driving directions, cooking recipes written in English or any other language are also programs. Computer programming is the process of developing and creating a computer program to perform a specific task through a computer. Thus, computer program contains the instructions that tells a computer or computerized device-what to do.

Q2. What is a compiler ?

Computer understands the programs that are written in machine language. However, machine language is very cumbersome to work with and also, machine dependent, that is, every different type of computer has its own unique instruction set and thus, a program written for one type of computer cannot be run on another type of computer without significant alternations. Hence, in general computer programs are written in some high-level language, whose instruction set is more compatible with human languages. A program written in high-level language must be translated into machine language for its execution. Compiler acts as a translator and translates the programs written in high-level programming language to equivalent machine language.

Q3. What is an interpreter and how is it different from a compiler ?

A translator that translates the programs written in high-level programming language to machine language line by line or one statement at a time is known as interpreter. Thus, both compiler and interpreter do the job of translation.
Compilers translate the whole program before the execution begins. On the other hand, an interpreter translates only one statement at a time. Thus, interpreter translates the high-level language during execution of the program.

Q4. How java is platform independent ?

Programs written in Java are compiled into machine language for a computer that doesn't really exist. This so-called "virtual" computer is known as the Java Virtual Machine (JVM). The machine language for the JVM is called Java bytecode. This bytecode is not specific to any particular platform; it is a set of instructions that can be executed by the JVM. As long as you have a JVM for a particular platform, you can run any Java program on that platform. Java achieves platform independence by generating the bytecode which is platform independent and executing that bytecode on platform-specific JVMs. In this way, Java applications can be developed on one platform and run on various other platforms with the help of JVMs.