Java Programming Fundamentals: Features, JVM and Principles Explained

Verified

Added on  2019/09/20

|6
|1044
|398
Homework Assignment
AI Summary
This assignment delves into the fundamentals of Java programming, exploring its key features such as being object-oriented, platform-independent, robust, interpreted, and multi-threaded. It discusses the principles of Java, including encapsulation, inheritance, and polymorphism, providing detailed explanations and examples. Furthermore, the assignment examines the Java Virtual Machine (JVM), outlining its role in loading, verifying, and executing bytecode, emphasizing its contribution to Java's platform independence. The content also includes a critical evaluation of the environmental flexibility of programming in Java, highlighting its adaptability across different hardware and software platforms and the JVM's role in enabling this flexibility. The document references several sources to support the concepts discussed.
Document Page
Q 1)
Java has many features including Object Oriented, Platform Independent, Robust,
Interpreted, and Multi-threaded. Discuss the principles, characteristics and features of
Programming in Java?
Ans:
Characteristics and Features of Java
1. Simple: According to Sun, Java language is simple because its syntax based on C++. If a
programmer is familiar with C++, then it is easy to learn quicker Java language. Some
concepts removed from this language that makes developer confused, for example,
explicit pointers, operator overloading, etc. It also eliminates the greatest headache for
the developer, and that is removing the unreferenced objects. Java provides Automatic
Garbage Collection.
2. Object- oriented: Java is an object-oriented programming language. By using this
language, we can easily organize our software as a combination of different types of
objects. Each object has own data and behavior. This methodology simplifies software
development and maintenance by providing some set of rules or principles.
3. Platform Independent: As we know platform belongs to hardware or software
environment in which a program runs. Java provides the software-based platform that
runs on the top of other hardware-based platforms. Java has two important components:
a) Runtime Environment
b) API (Application Programming Interface)
tabler-icon-diamond-filled.svg

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
Note: Java code can run on any platform for example: Windows, Linux, Sun Solaris,
Mac/OS, etc.
4. Secured: Java is secured language because there are no explicit pointer and Java
programs run inside virtual machine sandbox. Here is the diagram describes the apparent
difference
Document Page
Classloader: It separates the package for the classes of the local file system from those
files that imported from network sources.
Bytecode Verifier: It checks the fragments of code for illegal code that can violate
access right to objects.
Security Manager: It determines what type of resources a class can access such as
reading and writing to the local disk.
5. Robust: Java uses proper memory management. Java eliminates pointer concept that was
a cause of weak security. Java provides automatic garbage collection. There are exception
handling and type checking mechanism in Java. All these make Java robust.
6. Portable: We can run the Java bytecode on any platform.
7. Multi-threaded: A thread is a part of a program which cannot break further. Java based
on multithreading concept. Threads shares common memory. They do not need separate
memory to run. They run concurrently. It reduces the execution time, and it increases the
performance.
Principles of Java Language
There are three essential principles.
1. Encapsulation: Encapsulation wraps the attributes and the behavior. Encapsulation
provides security by covering things in the single unit. Encapsulation prevents
unauthorized access to a class from outsiders. For example: a class combines attributes
and methods in a single unit.
2. Inheritance: The main advantage of Inheritance of code re-usability. A class inherits or
uses the features of already exists class; this is called inheritance (reusing the code).
There are two types of classes. One is the parent or super (this already exists, or we can
Document Page
say this is an old class) and the second one is child class or subclass (this is newly
created, class). Subclass uses some or all features of a super class. It reduces the time,
increases the performance and increases the code readability. A subclass can have own
features.
3. Polymorphism: The general meaning of this term is many forms. In Java, there is an
object which can perform different tasks in a different environment. The role of the
object depends on what is the environment. For example: There is a child in school he is
a student; if he is in his house then he is a child of his parent. There are two types of
method overloading and method overriding. Polymorphism implemented at run-time.
Q 2) explain the role of Java Virtual Machine (JVM) and critically evaluate
environmental Flexibility of programming in Java?
Ans: JVM stands for (Java Virtual Machine) is an abstract machine. It is a
specification that provides a runtime environment. Java bytecode executed in this
environment. JVM available for many hardware and software platforms.
Role of JVM: JVM performs following operations
1. Loads code
2. Verifies code
3. Executes code
4. Provides runtime environment
Internal Architecture of JVM
tabler-icon-diamond-filled.svg

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
Platform independent means that the code remains the same no matter what is the
platform involved. Java has JVM. JVM once installed on any platform for example
Windows or OS. It can run the Java code without any changes. The JVM acts like a
virtual platform on which the code executed. JVM is platform dependent, but Java is
platform independent. JVM is available for each platform. JVM is open source no need to
purchase we have to download it from the internet and just install it. JVM should be
compatible with the installation machine OS and Windows. Once you compiled your
Java code; a bytecode generated. This byte code is platform independent. After
installation of appropriate JVM, you can run this bytecode without any difficulty.
Document Page
References
Characteristics of Java. (2016). Papa.det.uvigo.es. Retrieved 5 November 2016, from
http://papa.det.uvigo.es/~theiere/cursos/Curso_Java/characteristics.html
Cassels, J., Cassels, J., & profile, V. (2016). The three main Principles of Object
Oriented Programming - How to Program with Java. Ejavatutorial.blogspot.in.
Retrieved 5 November 2016, from http://ejavatutorial.blogspot.in/2012/07/3-main-
principles-of-object-oriented.html
Java characteristics & features - Java Tutorials - c4learn.com. (2016). Learn
Programming Language Step By Step. Retrieved 5 November 2016, from
http://www.c4learn.com/java/java-characteristics-features/
Why is Java called a platform independent language?. (2016). Functionspace.com.
Retrieved 5 November 2016, from http://functionspace.com/topic/1689/Why-is-java--
called-a-platform-independent-language-
chevron_up_icon
1 out of 6
circle_padding
hide_on_mobile
zoom_out_icon
logo.png

Your All-in-One AI-Powered Toolkit for Academic Success.

Available 24*7 on WhatsApp / Email

[object Object]