JAVA AND INTERNET TECHNOLOGY
UNIT-1 JAVA BASICS
Teaching Scheme - JAVA AND INTERNET TECHNOLOGY
Teaching Cr Examination Scheme
Scheme(hr/week)
L T P External Internal Total
TH(E) PRA(V) T CE P
3 0 4 5 60 30 20 20 20 150
L- Lectures; T- Tutorial/Teacher Guided Student Activity; P- Practical; Cr- Credit; E - End
Semester Theo. Exam; V - End Semester Viva Exam; M –Mid Semester Exam; P.A.- Progressive
Assessment
2
Application - JAVA AND INTERNET TECHNOLOGY
1. Android Apps
2. Server Apps at Financial Services Industry
3. Java Web applications
4. Big Data technologies
Why Java is
Important
• Two reasons :
– Trouble with C/C++ language is that
they are not portable and are not
platform independent languages.
– Emergence of World Wide Web, which
demanded portable programs
• Portability and security necessitated
the invention of Java
Histor
•yJames Gosling - Sun
Microsystems
• Co founder – Vinod Khosla
• Oak - Java, May 20, 1995, Sun
World
• JDK Evolutions
– JDK 1.0 (January 23, 1996)
– JDK 1.1 (February 19,
1997)
– J2SE 1.2 (December 8,
1998)
– J2SE 1.3 (May 8, 2000)
– J2SE 1.4 (February 6,
Cont.
•
.
Java
Editions.
J2SE(Java 2 Standard - to
client-side
Edition) standalone applications or
develop
applets.
J2ME(Java 2 Micro Edition ) - to develop
applications for mobile devices such as
cell phones.
J2EE(Java 2 Enterprise Edition ) - to
develop server-side applications such
as Java servlets and Java ServerPages.
What is
java?
• A general-purpose object-oriented
language.
• Write Once Run Anywhere (WORA).
• Designed for easy Web/Internet
applications.
• Widespread acceptance.
How is Java different from
C…
• C Language:
– Major difference is that C is a structure oriented
language and Java is an object oriented language
and has mechanism to define classes and objects.
– Java does not support an explicit pointer type
– Java does not havepreprocessor, so we can't
use #define,
#include and #ifdef statements.
– Java does not include structures, unions and enum
data types.
– Java does not include keywords like goto, sizeof and
typedef.
– Java adds labeled break and continue statements.
– Java adds manyfeatures required for object
oriented programming.
How is Java different from
C++…
• C++ language
Features removed in java:
Java doesn’t support pointers to avoid
unauthorized access of memory locations.
Java does not include structures, unions and
enum data types.
Java does not support operator over loading.
Preprocessor plays less important
role in C++ and so eliminated
entirely in java.
Java does not perform automatic
type conversions that
result in loss of precision.
Cont…
Java does not support global variables.
Every method and variable is declared
within a class and forms part of that class.
Java does not allow default arguments.
Java does not support inheritance of
multiple super classes by a sub class (i.e.,
multiple inheritance). This is accomplished
by using ‘interface’ concept.
In java objects are passed by reference only.
In C++ objects may be passed by value or
reference.
Cont …
New features added in Java:
Multithreading, that allows two or more
pieces of the same program to execute
concurrently.
C++ has a set of library functions that use a
common header file. But java replaces it
with its own set of API classes.
It adds packages and interfaces.
Java supports automatic garbage collection.
break and continue statements have been
enhanced in java to accept labels as
targets.
The use of unicode characters ensures
Cont …
Features that differ:
Though C++ and java supports Boolean data
type, C++ takes any nonzero value as true and
zero as false. True and false in java are
predefined literals that are values for a boolean
expression.
Java has replaced the destructor function with a
finalize() function.
C++ supports exception handling that is similar
to java's. However, in C++ there is no
requirement that a thrown exception be caught.
Characteristics of
•Java
Java is simple • Java is architecture-
• Java is object- neutral
oriented • Java is portable
• Java is distributed • Java’s performance
• Java is • Java is multithreaded
interpreted • Java is secure
• Java is robust
Java
Environment
• Java includes many development tools,
classes and methods
– Development tools are part of Java Development
Kit (JDK) and
– The classes and methods are part of Java Standard
• JDKLibrary (JSL),of tools
also like
known as Application
java compiler,
Programming
interpreter Interface (API).
and many.
constitutes java
• API includes hundreds of classes and
methods grouped into several packages
according to their functionality.
Java is architecture-
neutral
JAVA Program
Execution
WORA(Write Once Run Anywhere)
JVM
JVM (Java Virtual Machine) is an
abstract machine.
It is called virtual machine because it
doesn't physically exist.
It is a specification that provides
runtime environment in which java
bytecode can be executed.
17
The JVM performs following main
tasks:
Loads code
Verifies code
Executes code
Provides runtime environment
18
JRE
JRE is an acronym for Java Runtime
Environment.
The Java Runtime Environment is a
set of software tools which are used for
developing java applications.
It is used to provide runtime
environment.
19
20
JDK
JDK is an acronym for Java
Development Kit.
The Java Development Kit (JDK) is a
software development environment
which is used to develop java
applications and applets.
It physically exists. It contains JRE +
development tools.
21
Continue..
JDK is an implementation of any one
of the below given Java Platforms
released by Oracle corporation:
Standard Edition Java Platform
Enterprise Edition Java Platform
Micro Edition Java Platform
22
23
Java Variables
A variable is a container which holds
the value while the java program is
executed.
Variable is a name of memory
location. There are three types of
variables in java: local, instance and
static.
There are two types of data types in
24
java: primitive and non-primitive.
Local Variable
A variable declared inside the body of
the method is called local variable.
You can use this variable only within
that method and the other methods in
the class aren't even aware that the
variable exists.
25
Instance Variable
A variable declared inside the class
but outside the body of the method, is
called instance variable.
It is called instance variable because
its value is instance specific and is not
shared among instances.
26
Static variable
A variable which is declared as static
is called static variable.
It cannot be local.
You can create a single copy of static
variable and share among all the
instances of the class.
27
Example
class A{
int data=50;//
instance variable
static int m=100;//
static variable
void method(){
int n=90;//local variable
}
}//end of class
28
Data Types in
Java
Primitive data types: The primitive
data types include Integer, Character,
Boolean, and Floating Point.
Non-primitive data types: The non-
primitive data types include Classes,
Interfaces, and Arrays.
29
Java Primitive Data Types
There are 8 types of primitive data
types:
boolean data type
byte data type
char data type
short data type
int data type
long data type
float data type
double data type
30
31
Data Type Default Value Default size
boolean false 1 bit
char '\u0000' 2 byte
byte 0 1 byte
short 0 2 byte
int 0 4 byte
long 0L 8 byte
float 0.0f 4 byte
double 0.0d 8 byte
32