1.1 JAVA
1.1 JAVA
Dr E.Suganya
Recap
Prerequisite Knowledge:
• Structured Programming
• Object Oriented Programming
• Internet and WWW
Evocation
The Genesis of JAVA
Recall the origin of C and C++ that led to JAVA
History: JAVA
• The man only knows that pressing the accelerators will increase
the speed of car or applying brakes will stop the car but he does
not know about how on pressing the accelerator the speed is
actually increasing, he does not know about the inner
mechanism of the car or the implementation of accelerator,
brakes etc in the car. This is what abstraction is.
In java, abstraction is achieved by interfaces and abstract classes.
We can achieve 100% abstraction using interfaces
ENCAPSULATION
• It is defined as the wrapping up of data under a single
unit. It is the mechanism that binds together code and
the data it manipulates. Another way to think about
encapsulation is, it is a protective shield that prevents
the data from being accessed by the code outside this
shield.
• Technically in encapsulation, the variables or data of a
class is hidden from any other class and can be
accessed only through any member function of own
class in which they are declared.
• As in encapsulation, the data in a class is hidden from
other classes, so it is also known as data-hiding.
Inheritence
• Inheritance is an important pillar of OOP(Object Oriented
Programming). It is the mechanism in java by which one class is
allow to inherit the features(fields and methods) of another
class.
• Super Class: The class whose features are inherited is known as
superclass(or a base class or a parent class).
• Sub Class: The class that inherits the other class is known as
subclass(or a derived class, extended class, or child class). The
subclass can add its own fields and methods in addition to the
superclass fields and methods.
• Reusability: Inheritance supports the concept of “reusability”,
i.e. when we want to create a new class and there is already a
class that includes some of the code that we want, we can
derive our new class from the existing class. By doing this, we
are reusing the fields and methods of the existing class.
Polymorpism
• Polymorphism
• Polymorphism (from Greek, meaning “many forms”) is
a feature that allows one interface to be used for a
general class of actions.
• It refers to the ability of OOPs programming languages
to differentiate between entities with the same name
efficiently. This is done by Java with the help of the
signature and declaration of these entities.
• Note: Polymorphism in Java are mainly of 2 types:
• Overloading
• Overriding
Interpret how JAVA and Internet works together
How JAVA Changed the Internet
JAVA Applets
• An applet is a special kind of Java program that is designed
to be transmitted over the Internet and automatically
executed by a Java-compatible web browser
• Applets are intended to be small programs.
• They are typically used to display data provided by the
server, handle user input, or provide simple functions, such
as a loan calculator, that execute locally, rather than on the
server.
• Objects : Active and Passive
Interpret how JAVA and Internet works together
How JAVA Changed the Internet
Security and Portability:
• As Applets are downloaded automatically from internet
there are chances for breach of the system security
• JAVA enable applets to be downloaded and executed on
the client computer safely and it prevents an applet from
launching such an attack.
• Java achieved this protection by confining an applet to the
Java execution environment and not allowing it access to
other parts of the computer.
• Applets runs on all types of browsers and operating systems
that are connected to the internet
Interpret how JAVA and Internet works together
• Java is a Complied and Interpreted Language
• The output of java compiler is the byte code which is a
highly optimized set of instructions designed to be executed
by the Java run-time system, which is called the Java Virtual
Machine (JVM).
Interpret how JAVA and Internet works together
How JAVA Changed the Internet
Servlets:
• A servlet is a small program that executes on the server.
• Servlets are the Java programs that run on the Java-enabled
web server or application server. They are used to handle the
request obtained from the webserver, process the request,
produce the response, then send a response back to the
webserver.
• Just as applets dynamically extend the functionality of a web
browser, servlets dynamically extend the functionality of a web
server.
• Ex: Online Store Price Look up from the database at the server
side
Formative Assessment
1. ___________ is a small program that can be downloaded
and executed from a web browser
a) Applet
b) Servlet
c) JVM
d) Byte Code
Answer:
a) Applet
Formative Assessment
2. Initially Java was named as ______________________
a) Silk
b) Oak
c) Jolt
d) DNA
Answer:
b) Oak
SO3:Classify the different features of JAVA
Simple Secure and
Dynamic Portable
Object
Oriented
Distributed
JAVA BUZZWORDS
Robust
High
Performance
Multithreaded
Interpreted Architecture
-Neutral
SO4:Retrieve the evolution of JAVA
J2SE 5.0
J2SE 1.3
JDK 1.1
JDK 1.0
J2SE 1.2
J2SE 1.4
Java SE 6 Java SE 8
Formative Assessment
1. What makes JAVA to “Write Once and Run Anywhere”?
a) JVM
b) RMI
c) TCP/IP
d) Internet
Answer:
a) JVM
Formative Assessment
2. Which of the following is not true about JAVA?
a) Java is Highly Secure and Portable
b) Java is Compiled and Interpreted Language
c) Java invokes methods across Networks
d) Java is structured and compiled language
Answer:
d) Java is structured and compiled language
Discussion
Mind Map
Multi
C Secure Threaded
and Interpreted
Portable and High
C++ Performance
Simple
History and
Robust Architecture
Features
Neutral
JAVA
Distributed
Genesis and
Object Dynamic
of JAVA
Oriented
JAVA
and Java Java
Internet 1.0 1.1
J2SE
JSE 8
Applets Servlets Evolution
J2SE 3
JSE 7
JSE 6 J2SE 4
J2SE 5
Summary
1 History
C,C++,JAVA
2 JAVA and Internet
Applets and Servlets
3 Features of JAVA
4 Evolution of JAVA
Stimulating Questions
1. JDK 1.6