Java Unit I-1 PDF
Java Unit I-1 PDF
Advantages:
Inheritance provides the idea of reusability.
Time consuming.
Dynamic Binding
Binding refers to the linking of a procedures call to the code to be executed in
response to the call.
Dynamic binding means that the code associated with a given procedure call is not
known until the time of the call at run time.
Message communication
An object-oriented program consists of a set of objects that communicates with each
other.
1. Creating classes that define object and behaviors.
2. Creating objects from class definitions.
3. Establishing communication among objects.
Objects communicates with one another by sending and receiving information much the
same way as people pass messages to one another.
1
Eg: Employee. Salary (name);
***************************************************************************
2. Explain java features?
Compiled and Interpreted
Usually a computer language is either compiled or interpreted.
Java combines both these approaches.
First, Java compiler translates source code into bytecode instructions.
Bytecodes are not machine instructions and therefore, in the second stage, Java
interpreter generates machine code that can be directly executed by the
machine that is running the Java program.
Platform-Independent and Portable
The most significant contribution of Java over other languages is its portability.
Java programs can be easily move from one computer to another.
Changes and upgrades in operating systems and system resources will not force
any changes in Java programs.
Object-Oriented
Java is a true object-oriented language.
Almost everything in Java is an object.
All program code and data reside within objects and classes.
Robust and Secure
Java is a robust language.
It provides many safeguards to ensure reliable code.
It has strict compile time and run time checking for data types.
Exception Handling- to handle series errors and eliminates any risk of
crashing the system.
Distributed
It has the ability to share both data and programs.
Java applications can open and enables multiple programmers at multiple
remote locations to collaborate and work together on a single project.
Simple, Small and Familiar
Java is a small and simple language.
Many features of C and C++ that are either redundant or sources of
unreliable code are not part of Java.
Multithreaded and Interactive
Multithreaded means handling multiple tasks simultaneously.
2
Java supports multithreaded programs.
This means that we need not wait for the application to finish one task
before beginning another.
High Performance
Java performance is impressive for an interpreted language, mainly due to
the use of intermediate bytecode.
Java speed is comparable to the native C/C++.
Dynamic and Extensible
Java is a dynamic language.
Java is capable of dynamically linking in new class libraries, methods and
objects.
Java programs support functions written in other languages such as C and
C++. These functions are known as native methods
*******************************************************************
C JAVA
Size of type definition (statement C keyword) Not supported
Struct, union(datatype) Not supported
Auto, extern, register, signed unsigned Not supported
(type modifier key word)
Pointers Not supported
Not supported New operator like instance of and
>>>
Not supported Labeled, break, continue
C++ JAVA
Operator overloading Not supported
Template class Not supported
Multiple inheritance Interface
Pointer Not supported
Destructor Destructor replaced as a Finalize() function
3
4.Explain Java And Internet?
Java is strongly with the Internet because of the fact that the application
program written in Java was HotJava, a web browser to run Java applets on
Internet.
Internet users can use Java to create applet programs and run them locally
using a “Java-enabled browser” such as HotJava .
They can also use a Java-enabled browser to download an applet located on a
computer anywhere in the internet and run it on his local computer.
In fact java applets have made the Internet a true extension of the storage
system of the local computer.
Internet users can also set up their Websites containing Java applets that
could be used by other remote users of Internet.
Java a unique programming language for the Internet. In fact, due to this, Java
is popularly known as Internet language
***********************************************************************
5. Explain Java And World Wide Web?
World Wide Web (WWW) is an open-ended information retrieval system
designed to be used in the Internet’s distributed environment.
This system contains what are known as Web pages that provide both
information and controls.
Before Java, the World Wide Web was limited to the display of still images
and texts.
However, the incorporation of Java into Web pages has made it capable of
supporting animation, graphics, games and wide range of special effects.
With support of Java, the web has become more interactive and dynamic.
Java communicates with a Web page through a special tag called <APPLET>.
The following are the communication steps.
The user sends a request for an HTML document to the remote computer’s
Web server is a program that accepts a request, processes the request, and
sends the required document.
The HTML document is returned to the user’s browser. The document
contains the APPLET tag, which identifies the applet.
The corresponding applet bytecode is transferred to the user’s computer. This
bytecode had been previously created by the Java source code file for that
applet.
4
The Java-enabled browser on the user’s computer interprets the bytecodes and
provides output.
*****************************************************
6 Explain web browsers?
Web browsers are used to navigate through the information found on the net.
They allow us to retrieve the information spread across the Internet and
display it using the hypertext markup language (HTML).
Among other Web browsers, includes
HotJava
Netscape Navigator
Internet Explorer
HotJava
HotJava is written entirely in Java and demonstrates the capabilities of Java
programming language.
When the Java language was first developed and ported to the Internet, no
browsers were available that could run Java applets.
HotJava is currently available for the SPARC/Solaris platform as well as
Windows 95, Windows NT and Windows XP.
Netscape Navigator
Netscape Navigator was from Netscape Communications Corporation, is a
general purpose browser that can run Java applets.
It has many useful features such as visual display about downloading process
and indication of number of bytes downloaded.
It also supports JavaScript, a scripting language used in HTML documents.
Internet Explorer
Internet Explorer is another popular browser developed by Microsoft for
Windows 95, NT and XP workstations.
Both the Navigator and Explorer use tool bars, icons, menus and dialog
boxes for easy navigation.
Explorer uses a just-in-time (JIT) compiler which increases the speed of
execution.
************************************************************************
5
7.Explain java program structure?
****************************************************
6
8.Expalin Java Tokens?
Smallest individual units in a program are known as tokens.
Java contains 5 types of tokens:
1. Reserved Keywords 2.Identifiers 3.Literals 4.Operators 5.Seperators
Tokens Description
Key Words Java language has reserved 50 words as keywords
Java keywords have specific meaning in java.
We cannot use them as names for variables, classes, methods and so and
so.
Ex : for, import, private, void.
Identifiers They are used for naming classes, methods, variables, objects, labels,
packages and interfaces in a program.
Rules
They can have alphabet, digit and the underscore and dollar sign
characters.
EX: average, sum
They must not begin with a digit. Ex: 1empname
Upper case and lower case letter are distinct. EX: Student, HelloJava
They can be of any length.
**********************************************************************
7
9. Explain java virtual machine?
* The java compiler produces an intermedia code known as bytecode for a machine
that does not exist. This Machine is called the Java Virtual Machine.
* It exists only onside the computer memory.
* It is simulated computer within the computer and does all major functions of a real
computer.
* Java program into byte code which is also referred as Virtual Machine code.
* The Virtual machine code is not machine specific. The machine specific code
(known as machine code) is generated by the Java Interpreter by acting as an intermediary
b/w the virtual machine and the real machine.