0% found this document useful (0 votes)
10 views

1.1 JAVA

Uploaded by

akshat prajapati
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

1.1 JAVA

Uploaded by

akshat prajapati
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 37

CSE3002- Programming in 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

• Computer language innovation and development occurs for


two fundamental reasons:
1) to adapt to changing environments and uses
2) to implement improvements in the art of programming
• The development of Java was driven by both in equal
measures.
• Many Java features are inherited from the earlier languages:
B  C  C++  Java
Recall the origin of C and C++ that led to JAVA

The Birth of Modern Programming: C

• Designed by Dennis Ritchie in 1970s.


• Before C: BASIC, COBOL, FORTRAN, PASCAL
• C- structured, efficient, high-level language that could
replace assembly code when creating systems programs.
• Designed, implemented and tested by programmers.
SO1:Recall the origin of C and C++ that led to JAVA

The Next Step : C ++


• Designed by Bjarne Stroustrup in 1979.
• Response to the increased complexity of programs and
respective improvements in the programming paradigms and
methods:
1) assembler languages
2) high-level languages
3) structured programming
4) object-oriented programming (OOP)
• OOP – methodology that helps organize complex programs
through the use of inheritance, encapsulation and
polymorphism.
• C++ extends C by adding object-oriented features.
Recall the origin of C and C++ that led to JAVA

The Creation of JAVA

Designed by James Gosling, Patrick Naughton, Chris Warth,


Ed Frank and Mike Sheridan at Sun Microsystems in 1991.
The original motivation is not Internet: platform-
independent software embedded in consumer electronics
devices.
Developing different types of compilers for different
languages is difficult
Instead , A code which can run on any environment needs
to be developed which resulted in JAVA
Java has led to the development of C#
Object Oriented Programming (OOPs) Concept in Java

• Object-oriented programming aims to implement


real-world entities like inheritance, hiding,
polymorphism etc in programming.
• The main aim of OOP is to bind together the data and
the functions that operate on them so that no other
part of the code can access this data except that
function.
What is Java?

• Java is a programming language and a platform. Java is a


high level, robust, object-oriented and secure
programming language.
• Java was developed by Sun Microsystems (which is now
the subsidiary of Oracle) in the year 1995. James
Gosling is known as the father of Java. Before Java, its
name was Oak. Since Oak was already a registered
company, so James Gosling and his team changed the
name from Oak to Java.
• Platform: Any hardware or software environment in which
a program runs, is known as a platform. Since Java has a
runtime environment (JRE) and API, it is called a platform.
CLASS
• A class is a user defined blueprint or prototype from which
objects are created. It represents the set of properties or
methods that are common to all objects of one type. In general,
class declarations can include these components, in order:
• Modifiers: A class can be public or has default access
• Class name: The name should begin with a initial letter
(capitalized by convention).
• Superclass(if any): The name of the class’s parent (superclass), if
any, preceded by the keyword extends. A class can only extend
(subclass) one parent.
• Interfaces(if any): n interface in Java is essentially a special kind
of class. Like classes, interfaces contain methods and variables;
unlike classes, interfaces are always completely abstract.
• Body: The class body surrounded by braces, { }.
Object
• Object is a basic unit of Object Oriented
Programming and represents the real life entities. A
typical Java program creates many objects, which as
you know, interact by invoking methods. An object
consists of:
• State : It is represented by attributes of an object. It
also reflects the properties of an object.
• Behavior : It is represented by methods of an object.
It also reflects the response of an object with other
objects.
• Identity : It gives a unique name to an object and
enables one object to interact with other objects.
• Method: A method is a collection of statements that
perform some specific task and return result to the
caller. A method can perform some specific task
without returning anything. Methods allow us
to reuse the code without retyping the code. In Java,
every method must be part of some class which is
different from languages like C, C++ and Python.
Methods are time savers and help us to reuse the
code without retyping the code.
Abstraction

• Data abstraction is the process of hiding certain details and


showing only essential information to the user.
Abstraction can be achieved with either abstract classes or
interfaces

• Ex: A car is viewed as a car rather than its individual


components.

• Data Abstraction may also be defined as the process of


identifying only the required characteristics of an object
ignoring the irrelevant details. The properties and behaviours
of an object differentiate it from other objects of similar type
and also help in classifying/grouping the objects.
.
Abstraction

• It can be achieved by using the interface and the abstract class. In


interfaces, only the methods are exposed to the end-user.

• Consider a real-life example of a man driving a car.

• 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

Developer Version Product Version(Internal) Features

Java 1.0 Initial Release


Java 1.1 JDBC,RMI,AWT
Java 1.2 Java 2- J2SE (Java 2 Swing, Collections
Standard Edition) Framework, Enhanced
JVM

Java 1.3 J2SE 1.3 Hotspot JVM,RMI to


support CORBA
Java 1.4 J2SE 1.4 Assert, chained
exceptions, Channel
based I/O Subsystem and
Networking classes
SO4:Retrieve the evolution of JAVA
Developer Version Product Version(Internal) Features
Java 1.5 (JDK 5) J2SE 5 Generics, Annotations,
Auto boxing and Auto-Un
Boxing, Enumerations,
For-each, Variable length
arguments, Static import,
Formatted I/O,
Concurrency Utilities
Java 1.6 (JDK 6) Java SE 6 More API Libraries,
Packages and improved
run time
Java 1.7 (JDK 7) Java SE 7 String for switch,
Expanded try, single catch
for multiple exceptions,
NIO and Fork/Join
Framework
Java 1.8 Java SE 8 Lambda Expression
SO4:Retrieve the evolution of JAVA
Java SE 7

J2SE 5.0
J2SE 1.3
JDK 1.1

JDK 1.0

1996 1997 1998 2000 2002 2004 2006 2011 2014

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. Which version of JAVA is used in our college?

2. What are all the IDEs available to code JAVA?


Stimulating Question - Answers

1. JDK 1.6

2. Netbeans, Eclipse, IntelliJ, Android Studio, Enide Studio,


BlueJ, jEdit, jGRASP, jSource, jDeveloper, DrJava
Thank You

You might also like