0% found this document useful (0 votes)
7 views

Web Technology

Uploaded by

Ravi Yadav
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Web Technology

Uploaded by

Ravi Yadav
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

QUESTION: What are the features of the java?

ANSWER: The features of the java are :-


1. SIMPLE
Java is very easy to learn, and its syntax is simple, clean and easy to understand. According to Sun
Microsystem,

Java language is a simple programming language because:

•Java syntax is based on C++ (so easier for programmers to learn it after C++).

•Java has removed many complicated and rarely-used features, for example, explicit pointers,
operator

overloading, etc.

•There is no need to remove unreferenced objects because there is an Automatic Garbage Collection
in Java.

2. OBIJECT-ORIENTED
Java is an object-oriented programming language. Everything in Java is an object. Object-oriented

means we organize our software as a combination of different types of objects that incorporate both

data and behavior.

Object-oriented programming (OOPs) is a methodology that simplifies software development and

maintenance by providing some rules.

Basic concepts of OOPs are:

1.Object

2.Class

3.Inheritance

4.Polymorphism

5.Abstraction

6.Encapsulation

3.PLATFORM INDEPNDENT
Java is platform independent because it is different from other languages

like C, C++, etc. which are compiled into platform specific machines while Java

is a write once, run anywhere language. A platform is the hardware or

software environment in which a program runs.


There are two types of platforms software-based and hardware-based. Java

provides a software-based platform.

The Java platform differs from most other platforms in the sense that it is a

software-based platform that runs on top of other hardware-based platforms.

It has two components:

1. Runtime Environment

2. API(Application Programming Interface)

Java code can be executed on multiple platforms, for example, Windows, Linux, Sun Solaris, Mac/OS,
etc. Java code is compiled by the compiler and converted into bytecode. This bytecode is a platform-
independent code because it can be run on multiple platforms, i.e., Write Once and Run Anywhere
(WORA).

4.SECURED
Java is best known for its security. With Java, we can develop virus-free systems. Java is

secured because:

•No explicit pointer

•Java Programs run inside a virtual machine sandbox

• Classloader: Classloader in Java is a part of the Java Runtime Environment (JRE) which is used

to load Java classes into the Java Virtual Machine dynamically. It adds security by separating

the package for the classes of the local file system from those that are imported from

network sources.

• Bytecode Verifier: It checks the code fragments for illegal code that can violate access rights

to objects.

• Security Manager: It determines what resources a class can access such as reading and

writing to the local disk.

Java language provides these securities by default. Some security can also be provided by an

application developer explicitly through SSL, JAAS, Cryptography, etc.

5. ROBUST
The English mining of Robust is strong. Java is robust because:

• It uses strong memory management.

• There is a lack of pointers that avoids security problems.


• Java provides automatic garbage collection which runs on the Java Virtual Machine to get rid of
objects which are not being used by a Java application anymore.

• There are exception handling and the type checking mechanism in Java. All these points make Java
robust.

• ARCHITECTURAL-NEUTRAL
• PORTABLE
• HIGH PERFORMANCE
• DISTRIBUTED
• MULTI-THREAD
• DYNAMIC

QUESTION: Discuss the life cycle of threads.


ANSWER: In Java, a thread always exists in any one of the following states. These states
are:
1. New

2. Active

3. Blocked / Waiting

4. Timed Waiting

5. Terminated

1.New: Whenever a new thread is created, it is always in the new state. For a thread in the new
state,

the code has not been run yet and thus has not begun its execution.

2.Active: When a thread invokes the start() method, it moves from the new state to the active
state. The active state contains two states within it: one is runnable, and the other is running.

Runnable: A thread, that is ready to run is then moved to the runnable state. In the runnable state,
the thread may be running or may be ready to run at any given instant of time. It is the duty of the

thread scheduler to provide the thread time to run, i.e., moving the thread the running state.

Running: When the thread gets the CPU, it moves from the runnable to the running state. Generally,
the most common change in the state of a thread is from runnable to running and again back to
runnable

3.Blocked: The thread will be in blocked state when it is trying to acquire a lock but currently the
lock is acquired by the other thread. The thread will move from the blocked state to runnable state
when it acquires the lock.
4.Waiting state: The thread will be in waiting state when it calls wait() method or join() method.
It will move to the runnable state when other thread will notify or that thread will be terminated.

5.Timed Waiting: A thread lies in a timed waiting state when it calls a method with a time-out
parameter. A thread lies in this state until the timeout is completed or until a notification is received.

For example, when a thread calls sleep or a conditional wait, it is moved to a timed waiting state.

6.Terminated State: A thread terminates because of either of the following reasons:


•Because it exits normally. This happens when the code of the thread has been entirely executed

by the program.

•Because there occurred some unusual erroneous event, like a segmentation fault or an

unhandled exception.

You might also like