What is Java: Java is a class-based, object-oriented programming language that is designed to be secure and portable. It is used for developing mobile, web and desktop applications. The core principle is "Write Once Run Anywhere" (WORA), which means it can run on any device or operating system that has Java Virtual Machine (JVM).
Why to use Java? Java works on different platforms(Windows, Linux) and it is one of the most popular programming languages in the world. It is easy to learn and easy to use. It is an object oriented language which gives a clear structure to programs and allows code to be reused, lowering development costs. It is secure, fast and powerful.
Programs written in C++ are often platform-dependent, meaning code compiled on Linux may not run directly on Windows without modifications, and vice versa.
Platform dependent language: It is a programming language whose compiled code is specific to a particular operating system.
Ex: C,C++.
Platform is combined of software and hardware.
Ex: Linux + AMD7, Linux + intel7
Platform independent language: It is a programming language whose code runs on multiple operating system and hardware without any changes. This is also referred as cross-platform language.
Ex: Java, Python
For transferring data from C++ to system which can read only binary numbers, a compiler in the middle acts as the translator.
Translator can be divided into two types:
- Compiler - It is a language processor that reads the whole program and translates it into a program in machine language.
- Interpreter - An interpreter translates one line of code at a time into machine code and runs it immediately before moving to the next line.
In Java, bytecode is used as an intermediate step between source code and machine code. It is a low-level, platform-independent code generated by the Java compiler when compiling Java source code, which can then be executed on any system with a JVM.
Top comments (0)