Вы находитесь на странице: 1из 12

1

JAVA Notes
Que) What are the applications of java.

Ans.

There are mainly 4 type of applications that can be created using java programming:

1) Standalone Application
It is also known as desktop application or window-based application. An application that we need to install
on every machine such as media player, antivirus etc. AWT and Swing are used in java for creating
standalone applications.
2) Web Application
An application that runs on the server side and creates dynamic page, is called web application. Currently,
servlet, jsp, struts, jsf etc. technologies are used for creating web applications in java.
3) Enterprise Application
An application that is distributed in nature, such as banking applications etc. It has the advantage of high
level security, load balancing and clustering. In java, EJB is used for creating enterprise applications.
4) Mobile Application
An application that is created for mobile devices. Currently Android and Java ME are used for creating
mobile applications.

Que) What are differences between java and c++?.

2
Que) What are the important features of java ?
1) Simple
According to Sun, Java language is simple because:
syntax is based on C++ (so easier for programmers to learn it after C++). removed
many confusing and/or rarely-used features e.g., explicit pointers, operator overloading
etc. No need to remove unreferenced objects because there is Automatic Garbage
Collection in java.
2) Object-oriented
Object-oriented means we organize our software as a combination of different types
of objects that incorporates both data and behaviour. Object-oriented programming(OOPs) is
a methodology that simplify software development and maintenance by providing some
rules. Basic concepts of OOPs are: Object , Class ,Inheritance ,Polymorphism, Abstraction,
Encapsulation
3) Robust
Robust simply means strong. Java uses strong memory management. There are lack of
pointers that avoids security problem. There is automatic garbage collection in java. There is
exception handling and type checking mechanism in java. All these points makes java
robust.
4) Platform Independent
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 software-based
platform. The Java platform differs from most other platforms in the sense that it's 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 run on multiple platforms e.g.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).

5) Secured
Java is secured because:
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
access right to objects.

Security Manager- determines what resources a class can access such as


reading and writing to the local disk.

6) Portable
We may carry the java bytecode to any platform.

7) High-performance
Java is faster than traditional interpretation since byte code is "close" to native code still
somewhat slower than a compiled language (e.g., C++)

Que) What is JVM ? Write the architecture of JVM (also known as architecture of java) .
JVM (Java Virtual Machine) is an abstract machine. It is a specification that provides runtime
environment in which java bytecode can be executed. JVMs are available for many hardware
and software platforms (i.e.JVM is plateform dependent). JVM, JRE and JDK are platform
dependent because configuration of each OS differs. But, Java is platform independent.
JVM is basically
1. A specification where working of Java Virtual Machine is specified. But
implementation provider is independent to choose the algorithm. Its implementation
has been provided by Sun and other companies.
2. An implementation Its implementation is known as JRE (Java Runtime
Environment).
3. Runtime Instance Whenever you write java command on the command prompt to
run the java class, and instance of JVM is created.
The JVM performs following main tasks:
Loads code

Verifies code

Executes code

Provides runtime environment

4
Architecture of JAVA (JVM)

5
1) Classloader:
Classloader is a subsystem of JVM that is used to load class files.
2) Class(Method) Area:
Class(Method) Area stores per-class structures such as the runtime constant pool, field and
method data, the code for methods.
3) Heap:
It is the runtime data area in which objects are allocated.
4) Stack:
Java Stack stores frames.It holds local variables and partial results, and plays a part in
method invocation and return. Each thread has a private JVM stack, created at the same
time as thread. A new frame is created each time a method is invoked. A frame is
destroyed when its method invocation completes.

5) Program Counter Register:


PC (program counter) register. It contains the address of the Java virtual machine
instruction currently being executed.
6) Native Method Stack:
It contains all the native methods used in the application.
7) Execution Engine:
It contains:
1) A virtual processor
2) Interpreter:Read bytecode stream then execute the instructions.
3) Just-In-Time(JIT) compiler:It is used to improve the performance.JIT compiles
parts of the byte code that have similar functionality at the same time, and hence
reduces the amount of time needed for compilation.Here the term

compiler? refers to a

translator from the instruction set of a Java virtual machine (JVM) to the instruction set
of a specific CPU.

Que) What are the various concepts of OOPS ?


Ans : Object-Oriented Programming is a methodology or paradigm to design a
program using classes and objects. It simplifies the software development and
maintenance by providing some concepts:

6
Object
A run time entity that has state and behavior is known as an object. For example: chair,
pen, table, keyboard, bike etc. It can be physical and logical.
Class
A class is a logical entity which defines a blueprint for an object.
Inheritance
When one object acquires all the properties and behaviours of parent object i.e.
known as inheritance. It provides code reusability. It is used to achieve runtime
polymorphism.
Polymorphism
It means one interface multiple methods.When one task is performed by different
ways i.e. known as polymorphism.
In java, we use method overloading and method overriding to achieve polymorphism.

Abstraction
Hiding internal details and showing functionality is known as abstraction. For
example: phone call, we don't know the internal processing.
In java, we use abstract class and interface to achieve abstraction.
Encapsulation
Binding (or wrapping) code and data together into a single unit is known as
encapsulation. For example: capsule, it is wrapped with different medicines.
A java class is the example of encapsulation. Java bean is the fully encapsulated class
because all the data members are private here.

Que) What is method overloading ?


Ans : If a class have multiple methods by same name but different parameters, it is
known as Method Overloading. If we have to perform only one operation, having same
name of the methods increases the readability of the program.
There are two ways to overload the method in java
1. By changing number of arguments
2. By changing the data type

In java, Methood Overloading is not possible by changing the return type of the method

Que) What are constructors in java ?


Constructor in java is a special type of method that is used to initialize the object. Java
constructor is invoked at the time of object creation. It constructs the values i.e.
provides data for the object that is why it is known as constructor. There are basically
two rules defined for the constructor.
1. Constructor name must be same as its class name
2. Constructor must have no explicit return type
There are two types of constructors:

8
1. Default constructor (no-arg constructor)
2. Parameterized constructor

10

Que) What is constructor overloading in java ?


Constructor overloading is a technique in Java in which a class can have any number of
constructors that differ in parameter lists.The compiler differentiates these constructors
by taking into account the number of parameters in the list and their type.

11

Que) What are advantages of oops ?


Ans : Advantages of OOP
Object-Oriented Programming has the following advantages over conventional approaches:

OOP provides a clear modular structure for programs which makes it good for defining
abstract datatypes where implementation details are hidden and the unit has a clearly defined
interface.

OOP makes it easy to maintain and modify existing code as new objects can be created with
small differences to existing ones.

OOP provides a good framework for code libraries where supplied software components can
be easily adapted and modified by the programmer. This is particularly useful for developing
graphical user interfaces.

Que) What is JRE and JDK ?

12

Que) What is JAVA API ?


Ans : Java API is an acronym for Application Programming Interaface.It is :
1) a large collection of ready-made software components that provide many useful
capabilities, e.g. graphical user interface
2) grouped into libraries (packages) of related classes and interfaces.
3) together with JVM insulates Java programs from the hardware and operating
system variations.
Que) How is Java Important to the Internet ?
Ans: Prior to java, cyberspace was effectively closed to half the entities that now live there, as you will
see, java addresses those concerns and, by doing so, has opened the door to an exciting new form of
program: the applet.
1) Applet : An applet is an application designed to be transmitted over the Internet and executed by a
java-compatible Web browser. An applet is actually a tiny java program, dynamically downloaded
across the network, just like an image, sound file, or video clip. The important difference is that an
applet is an intelligent program, not just and animation or media file. In other words, and applet is a
program that can react to user input and dynamically change not just run the same animation or
sound over and over.

2) Seccurity : Provides a firewall between a networked application and your computer.


3)Portability : Many types of computers and operating systems are in use throughout the world and many are connected to the Internet. For programs to be dynamically downloaded to all the various
types of platforms connected to the Internet, some means of generating portable executable code is
needed. As you will soon see, the same mechanism that helps ensure security also helps create
portability. Indeed, javas solution to these two problems is both elegant and efficient.

Вам также может понравиться