The massive growth of the internet and world wide web leads
us to a completely new way of looking development and distribution of software.
Apart from being java is system independent language, java having many other
features also. Let us have a look at some of its features.
·
Simple
·
Object oriented
·
Robust
·
Secure
·
Distributed
·
Architectural neutral
·
Portable
·
Interpreted
·
High performance
·
Multithreaded
·
Scalability
·
Dynamic
Simple: Java was
designed to be easy for the professional programmer to learn and use
effectively. Assuming that you have some programming experience, you will not
find Java hard to master. If you already understand the basic concepts of
object-oriented programming, learning Java will be even easier. Best of all, if
you are an experienced C++ programmer, moving to Java will require very little
effort. Because Java inherits the C/C++ syntax and many of the object-oriented
features of C++, most programmers have little trouble learning Java. Also, some
of the more confusing concepts from C and C++ are omitted in java . for example
the concept of pointers, which is
very difficult for both learners and programmers, that has been eliminated in
java. Beyond its similarities with C/C++, people who know c and c++ can learn
java easily.
Q: why pointers are
eliminated in java?
A: 1. Pointers is
eliminated in java because pointers concept are complicated for the programmer.
pointers are not secure.
2. sometimes pointers may crash
programs easily, for example when we add two pointers, the program crash immediately. And when we
forgot to free the memory allotted to a variable and reallot it to some other variable, then
also program will crash.
3. using pointers harmful programs like virus and other hacking
programs can be developed. So
pointers breaks security
Object oriented: Java was not designed to be source-code
compatible with any other language. This allowed the Java team the freedom to
design with a blank slate. One outcome of this was a clean, usable, pragmatic approach to objects. That means java program use objects and classes. What is
an object? An object is anything that really exists in the real world and can
be distinguished from others. Everything that we see physically will come into
this definition. For example book, tree, human being…and so on.
Every object has properties and exhibits certain behavior.
For example let us assume a cat . It got
properties like name, color, height, age .. etc. these properties are
represented by variables. Now the object
cat will have some actions like walking, eating, jumping etc. these actions are represented by various
methods(functions) in our programming. So we can say the objects contain
variables and methods.
A group of objects exhibiting same behavior (properties and
actions) will comes under the same group called class. A class represents a group
of several objects. For example take flower: jasmine,rose, lilly. All these are exhibit
same behavior and hence they belongs to same group. So flower is the class name
and having three objects. And we can say a class is a model or blueprint for
creating the objects.
Q: what is the difference between a method and function?
A: a method is a
function that is written in a class. We don’t have functions in java, instead
we have methods. This means whenever a function is written in java, it should
be written inside the class only. But if we take c++, we can write the
functions inside as well as outside the class. So in c++, they are called
member functions.
Since java is purely object oriented programming language ,
so that if we write java program we need atleast one class or one object. C++ is not pure object
oriented language so it is possible to write programs in c++ without writing
class or object.
Robust: robust
means strong, java programs are strong and they don’t crash easily. the ability
to create robust programs was given a high priority in the design of Java. To
gain reliability, Java restricts you in a few key areas, to force you to find
your mistakes early in program development. At the same time, Java frees you
from having to worry about many of the most common causes of programming
errors. Because Java is a strictly typed language, it checks your code at
compile time. However, it also checks your code at run time. To better
understand how Java is robust, consider two of the main reasons for program
failure: memory management mistakes and mishandled exceptional conditions (that
is, run-time errors). Memory management can be a difficult, tedious task in
traditional programming environments. For example, in C/C++, the programmer
must manually allocate and free all dynamic memory. This sometimes leads to
problems, because programmers will either forget to free memory that has been
previously allocated or, worse, try to free some memory that another part of their
code is still using. Java virtually eliminates these problems by managing
memory allocation and deallocation . (In fact, deallocation is completely
automatic, because Java provides garbage collection for unused objects.)
Exceptional conditions in traditional environments often arise in situations
such as division by zero or “file not found,” and they must be managed with
clumsy and hard-to-read constructs. Java helps in this area by providing
object-oriented exception handling.
Q: what is garbage collector and which part of jvm will
allocate the memory for a program?
A: garbage collector is a form of memory management that
checks the memory from time to time and marks the variables or objects not used
by the program automatically. Class loader subsystem of jvm will allocate the
necessary memory needed by the program.
Q: which algorithm is used by garbage collector to remove
the unused variables or objects from memory?
A: mark and sweep
algorithm
Q: how can we call the garbage collector?
A: garbage collector is automatically invoked when the
program is being run. It can be also called by calling gc() method of Runtime
class or System class.
Secure: security
problems like tampering, eavesdropping , virus threats can be eliminated by
using java on internet.
-No explicit pointer
-Programs run inside virtual machine sandbox.
-Classloader: adds security by separating the package for
the classes of the local file system from those that are imported from network
sources.
-Bytecode Verifier: checks the code fragments for illegal
code that can violate accesss right to objects.
-Security Manager: determines what resources a class can
access such as reading and writing to the local disk.
Distributed: Java
is designed for the distributed environment of the Internet, because it handles
TCP/IP protocols. In fact, accessing a resource using a URL is not much
different from accessing a file. The original version of Java (Oak) included
features for intra- address-space messaging. This allowed objects on two
different computers to execute procedures remotely. Java revived these
interfaces in a package called Remote Method Invocation (RMI). This feature
brings an unparalleled level of abstraction to client/ server programming.
Architectural
neutral: java uses byte code which is not system dependent. It can run on
any machine with any processor and any operating system.
Portable: if a
program gives same result on every machine, then that program is called portable.
Java programs are portable programs.
Interpreted: when compile the java programs , they
generates byte code. This byte code is
downloaded and interpreted by the interpreter in JVM. Interpreting means
converting byte code into machine code. If we take any other languages only an
interpreter or compiler is used to execute the programs. But in java, we use
both compiler and interpreter for the execution.
High
performance: the problem with interpreter inside the jvm is that it is
slow. Because of this, java programs used to run slow. To overcome this
problem, along with the interpreter, java people have
introduced JIT(just in time) compiler, which enhances the speed of
execution. So in jvm ,interpreter and
JIT compiler work together to run the program.
Multithreaded: a
thread represents an individual process to execute a group of statements. Java
was designed to meet the real-world requirement of creating interactive,
networked programs. To accomplish this, Java supports multithreaded
programming, which allows you to write programs that do many things
simultaneously.
Scalability: java
platform can be implemented on a wide range of computers with varying levels of
resources , form embedded device to mainframe computers. This is possible
because java is compact and platform independent.
Dynamic: before
development of java, only static text used to be displayed in the browser. Java
programs carry with them substantial amounts of run-time type information that
is used to verify and resolve accesses to objects at run time. This makes it
possible to dynamically link code in a safe
manner. This is crucial to the robustness of the applet environment, in
which small fragments of byte code may be dynamically updated on a running
system.
No comments:
Post a Comment