Monday, 3 October 2016

Q . Write features of JAVA programming language in details. What do you understand by bytecode? Also write working of JVM.

Java is a general-purpose, high-level programming language. The features of Java:
• Java program is both compiled and interpreted.
• Write once, run anywhere
Java is a software-only platform running on top of other, hardware-based platforms.
• Java Virtual Machine (Java VM)
• The Java Application Programming Interface
Features of Java
(1) Simple: It fixes some clumsy features of C++. There is no use of pointers. Java has Automatic garbage
collection. It has rich pre-defined class library
(2) Object oriented: Focus on the data (objects) and methods manipulating the data. All functions are associated with objects. Almost all datatypes are objects (files, strings, etc.). it has potentially better code organization and reuse.
(3) Interpreted: Java compiler generate byte-codes, not native machine code. This compiled byte-codes are platform-independent. Java bytecodes are translated on the fly to machine readable instructions in runtime (Java Virtual Machine).
(4) Portable: Same application runs on all platforms. The sizes of the primitive data types are always the same. The libraries define portable interfaces
(5) Reliable: There is extensive compile-time and runtime error checking. No pointers but real arrays. Memory corruptions or unauthorized memory accesses are impossible. Automatic garbage collection tracks objects usage over time.
(6) Secure: Its usage in networked environments requires more security. Memory allocation model is a major defense. Here access restrictions are forced (private, public).
(7) Multi-threaded: Multiple concurrent threads of executions can run simultaneously. It utilizes a
sophisticated set of synchronization primitives (based on monitors and condition variables paradigm) to achieve this
(8) Dynamic: Java is designed to adapt to evolving environment. Libraries can freely add new methods and instance variables without any effect on their clients. Interfaces promote flexibility and reusability in code by specifying a set of methods an object can perform, but leaves open how these methods should be implemented. It can check the class type in runtime.
Java compilation produces “bytecode” which is an Intermediate code readable by the VM and transferable across the Internet as applets. VM interprets BC into instructions. ByteCode produced on any platform may be executed on any other platform which supports a VM.
Acts as an interpreter for the bytecode, which takes the bytecodes as input and executes as if it was a physical process executing machine code. JVM is a component of the Java system that interprets and executes the instructions in our class files. Each instance of the JVM has one method area, one heap, and one or more stacks - one for each thread.
• When JVM loads a class file, it puts its information in the method area
• As the program runs, all objects instantiated are stored in the heap
• The stack area is used to store activation records as a program runs

No comments:

Post a Comment