Professional Documents
Culture Documents
7, Daan Bari
Jawahar Nagar
Aura Of Excellence In Computer Education Kota (Rajasthan)
Mobile No. : 09928088743
C, C++, DSA, VB, VB.Net, C#, ASP.Net, Java(Core & Adv), PHP+MySql, UNIX, LINUX, Oracle, PL/SQL, BCA, MCA, BTECH
Local Applet
A LOCAL applet is the one which is stored on our computer system.when browser try to access
the applet, it is not necessary for our computer to be connected to The Internet.
Remote applets
Remote applets are developed by unknown persons and stored in remote computers. To run a
remote applet internet connection is needed. At the run time the system searches the applet
code in the internet and it is downloaded. To download a remote applet, we must give the
address of the applet in HTML page.
Compiler converts java code into byte code. Java application launcher opens a JRE, loads the
class, and invokes its main method.
You need JDK, if at all you want to write your own programs, and to compile the m. For running
java programs, JRE is sufficient.
JRE is targeted for execution of Java files i.e. JRE = JVM + Java Packages Classes(like util,
math, lang, awt,swing etc)+runtime libraries.
JDK is mainly targeted for java development. I.e. You can create a Java file (with the help of
Java packages), compile a Java file and run a java file
If u just want to run applets (ex: Online Yahoo games or puzzles), JRE needs to be installed on
the machine.
The JVM is called "virtual" because it provides a machine interface that does not depend on the
underlying operating system and machine hardware architecture. This independence from
hardware and operating system is a cornerstone of the write-once run-anywhere value of Java
programs.
There are different JVM implementations are there. These may differ in things like performance,
reliability, speed, etc. These implementations will differ in those areas where Java specification
doesn’t mention how to implement the features, like how the garbage collection process works
is JVM dependent, Java spec doesn’t define any specific way to do this.
BufferedReader(Reader inputReader)
Here, inputReader is the stream that is linked to the instance of BufferedReader that is being
created. Reader is an abstract class. One of its concrete subclasses is InputStreamReader,
which converts bytes to characters. To obtain an InputStreamReader object that is linked to
System.in, use the following constructor:
InputStreamReader(InputStream inputStream)
Because System.in refers to an object of type InputStream, it can be used for inputStream.
Putting it all together, the following line of code creates a BufferedReader that is connected to
the keyboard:
After this statement executes, br is a character-based stream that is linked to the console
through System.in.
Reading Characters
To read a character from a BufferedReader, use read( ). The version of read( ) that we will
be using is int read( ) throws IOException Each time that read( ) is called, it reads a character
from the input stream and returns it as an integer value. It returns –1 when the end of the
stream is encountered. As you can see, it can throw an IOException.
The following program demonstrates read( ) by reading characters from the console until the
user types a “q”:
// Use a BufferedReader to read characters from the console.
import java.io.*;
class BRRead
{
public static void main(String args[]) throws IOException
{
Topic : Java Page 2
Notes By NAGESH KUMAR Contact No: 09928088743
Nimbus Infocom
7, Daan Bari
Jawahar Nagar
Aura Of Excellence In Computer Education Kota (Rajasthan)
Mobile No. : 09928088743
C, C++, DSA, VB, VB.Net, C#, ASP.Net, Java(Core & Adv), PHP+MySql, UNIX, LINUX, Oracle, PL/SQL, BCA, MCA, BTECH
char c;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter characters, 'q' to quit.");
// read characters
do
{
c = (char) br.read();
System.out.println(c);
} while(c != 'q');
}
}
Here is a sample run:
Enter characters, 'q' to quit.
123abcq
1
2
3
a
b
c
q
This output may look a little different from what you expected, because System.in is line
buffered, by default. This means that no input is actually passed to the program until you press
ENTER. As you can guess, this does not make read( ) particularly valuable for interactive,
console input.
Reading Strings
To read a string from the keyboard, use the version of readLine( ) that is a member of the
BufferedReader class. Its general form is shown here:
• C++ was designed mainly for systems programming, extending the C programming language. To this
procedural programming language designed for efficient execution, C++ has added support for
statically-typed object-oriented programming, exception handling, scoped resource management, and
generic programming, in particular. It also added a standard library which includes generic containers
and algorithms.
• Java was created initially to support network computing. It relies on a virtual machine to be secure
and highly portable. It is bundled with an extensive library designed to provide a complete abstraction
of the underlying platform. Java is a statically-typed object-oriented language that uses a syntax
similar to C++, but is not compatible with it. It was designed from scratch, with the goal of being easy
to use and accessible to a wider audience.
The different goals in the development of C++ and Java resulted in different principles and design trade-offs
between the languages. The differences are as follows:
C++ Java
No backward compatibility with any previous
Compatible with C source code, except for a few
language. The syntax is however strongly influenced
corner cases.
by C/C++.
Write once run anywhere / everywhere (WORA /
Write once compile anywhere (WOCA)
WORE)
Allows procedural programming, object-oriented
Encourages an object oriented programming paradigm.
programming, and generic programming.
Call through the Java Native Interface and recently
Allows direct calls to native system libraries.
Java Native Access
Exposes low-level system facilities. Runs in a protected virtual machine.
Is reflective, allowing metaprogramming and dynamic
Only provides object types and type names.
code generation at runtime.
Has multiple binary compatibility standards Has a binary compatibility standard, allowing runtime
(commonly Microsoft and Itanium/GNU) check of correctness of libraries.
Optional automated bounds checking. (e.g. the at() Normally performs bounds checking. HotSpot can
method in vector and string containers) remove bounds checking.
Supports native unsigned arithmetic. No native support for unsigned arithmetic.
Standardized minimum limits for all numerical types,
but the actual sizes are implementation-defined. Standardized limits and sizes of all primitive types on
Standardized types are available as typedefs all platforms.
(uint8_t, ..., uintptr_t).
Primitive and reference data types always passed by
Pointers, References, and pass by value are supported
value.
Explicit memory management, though third party Automatic garbage collection (can be triggered
frameworks exist to provide garbage collection. manually). Doesn't have the concept of Destructor and
Supports destructors. usage of finalize() is not recommended.
Supports only class and allocates them on the heap.
Supports class, struct, and union and can allocate them
Java SE 6 optimizes with escape analysis to allocate
on heap or stack
some objects on the stack.
Rigid type safety except for widening conversions.
Allows explicitly overriding types.
Autoboxing/Unboxing added in Java 1.5.
The C++ Standard Library has a much more limited The standard library has grown with each release. By
Topic : Java Page 4
Notes By NAGESH KUMAR Contact No: 09928088743
Nimbus Infocom
7, Daan Bari
Jawahar Nagar
Aura Of Excellence In Computer Education Kota (Rajasthan)
Mobile No. : 09928088743
C, C++, DSA, VB, VB.Net, C#, ASP.Net, Java(Core & Adv), PHP+MySql, UNIX, LINUX, Oracle, PL/SQL, BCA, MCA, BTECH
C++ is a powerful language designed for system programming. The Java language was designed to be simple
and easy to learn with a powerful cross-platform library. The Java standard library is considerably large for a
standard library. However, Java does not always provide full access to the features and performance of the
platform on which the software runs. The C++ standard libraries are simple and robust providing containers
and associative arrays.
Cross Platform Compatibility: The java source files (java files with .java extension) after
compilation generates the bytecode (the files with .class extension) which is further converted
into the machine code by the interpreter. The byte code once generated can execute on any
machine having a JVM. Every operating system has it's unique Java Virtual Machine (JVM) and
the Java Runtime Environment (JRE).
Support to Internet Protocols: Java has a rich variety of classes that abstracts the Internet
protocols like HTTP , FTP, IP, TCP-IP, SMTP, DNS etc .
Support to HTML: Most of the programming languages that are used for web application uses
the html pages as a view to interact with the user. Java programming language provide it's
support to html. For example. Recently the extension package jipxhtml is developed in java to
parse and create the html 4.0 documents.
Support to Java Reflection APIs: To map the functionalities, Java Reflection APIs provides
the mechanism to retrieve the values from respective fields and accordingly creates the java
objects. These objects enables to invoke methods to achieve the desired functionality.
Support to XML parsing: Java has JAXP-APIs to read the xml data and create the xml
document using different xml parsers like DOM and SAX. These APIs provides mechanism to
share data among different applications over the internet.
Support to Web Services : Java has a rich variety of APIs to use xml technology in diverse
applications that supports N-Tiered Enterprise applications over the internet. Features like JAXB
, JAXM, JAX-RPC , JAXR etc enables to implement web services in java applications. It makes
java a most suited internet language.
Support to java enabled Mobile devices: Java programming language is made in such a way
so that it is compatible with mobile devices also. Java language also works with any java
enabled mobile devices that support MIDP 1.0/2.0 including the symbian OS mobile devices.
Support to Personal Digital Assistants: Java language is compatible with Personal Java 1.1
such as chaiVM, Jeode, CrEME, and JV-Lite2 or with all the later version and it also support
PDAs like HP/Compaq, iPAQ, Fujitsu-Siemens Pocket Loox and SimPad, HHP, NEC, Samsung,
Sharp Electronics, Toshiba, psion m5, and any other device with Windows CE/Pocket PC
2002/2003/2005).