Two requirements to create first java program:
1.Java Development Kit(JDK)
Steps to compile and run first program:
2.Create a class A
3.Write the main method as public static void main
4.Save your file with .java extension
5.Compile code as javac filename.java
6.To execute the code type java classname
Sensitivity of Java: Java is a case sensitive programming langugage(what)
Components of Java Platform: Execution engine, Compiler, set of libraries(what)
Type of Language: Java is a platform independent language.(what)Java does not depend upon the underlying network, operating system, hardware of the system.(why)
Computer : Computer is an electronic device that is used to store information, display results and for processing and computing results.Computer has peripheral devices like mouse, monitor, keyboard etc.(what)
Assembly Language: Assembly language is the very basic/elementary form of programming language.Code is converted from machine language to machine language(language of zeroes and ones).(what)
Compiler : Compiler converts programming language code to assembly language code.(what)
Platform: The combination of operating system and processor is called platform.(what) Wintel is a common platform with windows as the operating system and intel processor(e.g)
Java is a language and platform: In java the program code is first converted into byte code or class file which is interpreted by the Java Virtual Machine(JVM).(what)
Byte Code: Byte code is the compilation result of the java compiler after it compiles a .java file.The byte code is stored in the form of .class file.(what)
Java Virtual Machine: Java virtual machine converts bytecode to the machine code based on the platform so we don’t have to adapt a new compiler everytime we change platform. JVM is responsible for allocating memory.(what)
JVM Architecture : It consists of Java Compiler, method area and execution engine.(what)
Steps involved in Java Compilation:
Editor: In the editor you write your code.
Compile: Compiler compiles that code.
Linker: A linker links all the reference files in the program.
Loader: To load the file from your secondary storagedevice to your RAM.
Execute: Actual execution of code happens with the help of OS and the processor.
Categories of Programming Language :
1.High Level Language(C++, Java)
2.Middle Level Language( C )
3.Low Level Language(Assembly Language)
4.Lowest Level Language(Machine Language)
Difference between compiler and interpreter:
Compiler a high level language to a low level language.
An interpreter converts a language of one level of hierarchy to another language of same hierarchy.
Java is compiled as well as interpreted language:
In java we convert java file to byte code(compilation) and byte code to assembly code/machine code(interpretation).(why)
Two reasons Java is slow:
1.Dynamic linking : All the files present in java are linked at run time every time the program is run.
2.Run time interpreter :Conversion from code to byte code is done at run time and this process is little bit slow.
Java In Time Compiler(JIT) : Java in time compiler is slow so to speed up the process we have java in time compiler.(what)