0% found this document useful (0 votes)
8 views47 pages

Session 1

The document discusses structured programming and object-oriented programming paradigms. It explains structured programming breaks applications into hierarchical subprograms while object-oriented programming models real-world entities as objects that encapsulate both data and behavior. The document also describes how Java supports object-oriented programming and the steps for downloading and installing its development kit.

Uploaded by

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

Session 1

The document discusses structured programming and object-oriented programming paradigms. It explains structured programming breaks applications into hierarchical subprograms while object-oriented programming models real-world entities as objects that encapsulate both data and behavior. The document also describes how Java supports object-oriented programming and the steps for downloading and installing its development kit.

Uploaded by

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

Fo

rA
pt
ec
h
C
en
tre
U
se
O
Fundamentals of Java

nl
y
y
Explain the structured programming paradigm

nl

O
 Explain the object-oriented programming paradigm

se
 Explain the features of Java as a OOP language

U
 Describe Java platform and its components

tre
 List the different editions of Java

en
 Explain the evolution of Java Standard Edition (Java SE)
C
Describe the steps for downloading and installing Java
h

ec

Development Kit (JDK)


pt
rA
Fo

© Aptech Ltd. Introduction to Java/Session 1 2


y
The most prominent use of computers is to

nl

solve problems quickly and accurately.

O
se
 The solution adopted to solve a problem is

U
provided as a sequence of instructions or
specifications of activity which enables a

tre
user to achieve the desired result.

en
Software Applications
C
h
ec

• The solution for solving a problem in the field of


information technology is achieved by developing
pt

software applications.
rA

• A software application can be defined as a collection


Fo

of programs that are written in high-level


programming languages to solve a particular problem.
© Aptech Ltd. Introduction to Java/Session 1 3
y
Knowledge of Domain:

nl

O
 It plays an important role while developing software applications.
It can be defined as the field of business or technology to which a problem

se

belongs.

U
 Following figure shows the development of software application as a

tre
solution for managing various operations in a banking domain:

en
C
h
ec
pt
rA
Fo

© Aptech Ltd. Introduction to Java/Session 1 4


y
Programming Languages:

nl

O
 The development of software application is done using a programming
language.

se
 A programming language is used as a medium for communicating the

U
instruction to the computer.

tre
 The programming language enforces a particular style of programming
that is referred to as a programming paradigm.

en
 Following are the two types of programming paradigm:

C
h
Structured Object-oriented
ec

Programming Programming
pt
rA

Paradigm Paradigm
Fo

© Aptech Ltd. Introduction to Java/Session 1 5


y
Structured Programming

nl
O
• In structured programming paradigm, the application

se
development is decomposed into a hierarchy of subprograms.

U
• The subprograms are referred to as procedures, functions, or
modules in different structured programming languages.

tre
• Each subprogram is defined to perform a specific task.

en
• Some of structured programming languages are C, Pascal, and
Cobol.
 C
Following figure displays bank application activities broken down into
h
subprograms:
ec
pt
rA
Fo

© Aptech Ltd. Introduction to Java/Session 1 6


y
Main disadvantage of

nl

O
structured programming
languages are as follows:

se
Data is shared globally

U

between the subprograms.

tre
 Efforts are spent on

en
accomplishing the solution
rather than focusing on
problem domain. C
h
ec

 This often led to a software crisis, as the maintenance cost of


pt

complex applications became high and availability of reliable


rA

software was reduced.


Fo

© Aptech Ltd. Introduction to Java/Session 1 7


y
Growing complexity of software required change in

nl

O
programming style.

se
U
 Some of the features that were aimed are as follows:

tre
 Development of reliable software at reduced cost.

en
 Reduction in the maintenance cost.

C
Development of reusable software components.
h
 Completion of software development with the specified time
ec

interval.
pt
rA

 These features resulted in the evolution of object-


Fo

oriented programming paradigm.


© Aptech Ltd. Introduction to Java/Session 1 8
y
The software applications developed using object-oriented

nl

programming paradigm is:

O
Designed around data, rather than focusing only on the functionalities.

se

U
 Following shows different activities involved in the object-

tre
oriented software development:

en
C
h
ec
pt
rA
Fo

© Aptech Ltd. Introduction to Java/Session 1 9


y
nl
Object-oriented Analysis (OOA) phase determines

O
the functionality of the system.

se
U
Object-oriented Design (OOD) phases

tre
determines the process of planning a system in
which objects interact with each other to solve a

en
software problem.

C
h
Object-oriented Programming (OOP) deals with
ec

the actual implementation of the application.


pt
rA

 Unified Modeling Language (UML) helps to create visual models in the system.
The actual implementation of these visual models is done using an OOP
Fo

language.

© Aptech Ltd. Introduction to Java/Session 1 10


y
An OOP language is based on certain principles that are as

nl

follows:

O
Object – Represents an entity which possesses certain features and

se

behaviors.

U
 Class – Is a template that is used to create objects of that class.

tre
 Abstraction – Is a design technique that focuses only on the essential
features of an entity for a specific problem domain.

en
 Encapsulation – Is a mechanism that combines data and implementation

C
details into a single unit called class.
h
 Inheritance – Enables the developer to extend and reuse the features of
ec

existing classes and create new classes. The new classes are referred to as
derived classes.
pt

Polymorphism – Is the ability of an object to respond to same message in


rA

different ways.
Fo

© Aptech Ltd. Introduction to Java/Session 1 11


y
nl
 An object represents a real-world entity.

O
 Any tangible or touchable entity in the real-world can be

se
described as an object.

U
 Following figure shows some real-world entities:

tre
en
C
h
ec
pt
rA
Fo

© Aptech Ltd. Introduction to Java/Session 1 12


y
nl
 Each object has:

O
 Characteristics – Defined as attributes, properties, or features
describing the object.

se
 Actions – Defined as activities or operations performed by the

U
object.

tre
 Example of an object, Dog.

en
 Properties – Breed, Color, and Age

C
Actions – Barking, Eating, and Running
h
ec
pt

 The concept of objects in the real-world can be extended to


rA

the programming world where software ‘objects’ can be


Fo

defined.

© Aptech Ltd. Introduction to Java/Session 1 13


y
A software object has state and behavior.

nl

O
 ‘State’ refers to object’s characteristics or attributes.

se
 ‘Behavior’ of the software object comprises its actions.

U
 Following figure shows a software object, a Car with its state and
behavior:

tre
en
C
h
ec
pt
rA
Fo

© Aptech Ltd. Introduction to Java/Session 1 14


y
The advantages of using objects are as follows:

nl

O
• They help to understand the real-world.

se
1

U
• They map attributes and actions of real-world

tre
entities with state and behavior of software

en
2 objects.

C
h
ec
pt
rA
Fo

© Aptech Ltd. Introduction to Java/Session 1 15


y
In the real-world, several objects:

nl

O
 Have common state and behavior.
Can be grouped under a single class.

se

 Example: All car objects have attributes, such as color, make, or model.

U
 Class:

tre
 Can be defined that a class is a template or blueprint which defines the

en
state and behavior for all objects belonging to that class.
 Following figure shows a car as a template and a Toyota car as an object or
instance of the class: C
h
ec
pt
rA
Fo

© Aptech Ltd. Introduction to Java/Session 1 16


y
Class comprises fields and methods, collectively called as

nl

members.

O
Fields – Are variables that depict the state of objects.

se

 Methods – Are functions that depict the behavior of objects.

U
tre
en
C
h
ec
pt
rA
Fo

© Aptech Ltd. Introduction to Java/Session 1 17


y
Following table shows the difference between a class and an

nl

object:

O
se
Class Object

U
Class is a conceptual model Object is a real thing

tre
Class describes an entity Object is the actual entity

en
Class consists of fields (data Object is an instance of a class
members) and functions
C
h
ec
pt
rA
Fo

© Aptech Ltd. Introduction to Java/Session 1 18


y
It is one of the most popular OOP language.

nl

O
 It helps programmers to develop wide range of applications that
can run on various hardware and Operating System (OS).

se
It is also a platform that creates an environment for executing

U

Java application.

tre
 It caters to small-scale to large-scale problems across the

en
Internet.

C
Java applications are built on variety of platforms that range
h
from:
ec

 Embedded devices to desktop applications


pt

 Web applications to mobile phones


rA

 Large business applications to supercomputers


Fo

© Aptech Ltd. Introduction to Java/Session 1 19


y
Java Origins: Embedded Systems

nl

O
• Team of engineers from Sun Microsystems wanted to

se
design a language for consumer devices.

U
• Project was named as ‘Green Project’.

tre
• Team included: James Gosling, Mike Sheridan, and
Patrick Naughton.
1991

en
• Efforts were taken to produce portable and a platform
independent language that can run on any machine.
C
• Result was evolution of Java.
h
• Initially called ‘OAK’ and later renamed to Java .
ec
pt
rA
Fo

© Aptech Ltd. Introduction to Java/Session 1 20


y
Java Wonder: Internet

nl

• Internet and Web started emerging and was used

O
worldwide.

se
• Sun Microsystems turned Java into an Internet
programming language.
1995

U
• It emerged as a Web technology that added dynamic

tre
capabilities to the Web pages.
Java Moved: Middle-tier

en

• Sun Microsystems defined Servlets API to generate


C
dynamic HTML for Web pages and Enterprise JavaBeans
h
1997 for developing business logics.
ec
pt

• Sun Microsystems released three versions for free under


rA

General Public License (GPL)


• These are: Java Platform, Standard Edition (Java SE), Java
2006
Fo

Platform, Enterprise Edition (Java EE), and Java Platform


Micro Edition (Java ME)
© Aptech Ltd. Introduction to Java/Session 1 21
y
Java Ahead: Acquisition

nl

O
• Sun Microsystems was acquired by Oracle Corporation.

se
• The project Coin was launched to enhance Java
programming language.

U
2009 • Java EE 6 was released with simplified development and

tre
deployment model.

en
C
• The specification for Java 7 was approved by the Java
Community Process (JCP).
h
2010
ec
pt
rA
Fo

© Aptech Ltd. Introduction to Java/Session 1 22


y
Java is a high level OOP language as well a platform used for developing

nl

applications that can be executed on different platforms.

O
 It is characterized by following features:

se
Simple

U
tre
• Inherits its syntax from predecessor programming languages,
such as C/C++.

en
• Helps programmers to adapt to Java language without any
extra skills and extensive trainings.
C
• Eliminates the use of pointers, operator overloading, and
h
multiple inheritance features supported by predecessor
ec

languages.
pt
rA
Fo

© Aptech Ltd. Introduction to Java/Session 1 23


y
Object-oriented

nl
O
• Java is a pure OOP language that uses classes and objects that
address to the real-world problem domains.

se
• Even, the application development in Java starts with a class
designing.

U
tre
Robust

en
• C and C++ languages - Dynamic memory allocation/deallocation is
done manually through pointers that resulted in memory related
errors.
C
h
• Java incorporates:
ec

• Strong memory management - Handles memory allocation and deallocation using


Garbage Collection Mechanism that destroys unused objects in memory
pt

automatically.
rA

• Exception handling mechanism - Stops abnormal termination of code at runtime.


• Compile-time checking – Ensures variables are declared which contain specific type
of data.
Fo

• Run-time checking – Ensures purity of Java code during execution.

© Aptech Ltd. Introduction to Java/Session 1 24


y
nl
Secure

O
se
• Security checks applied at different layers ensures that the Java
programs are protected against malicious codes.

U
• Java programs that are accessed on the network are known as

tre
applets.
• Java applies security to applets by placing them in a sandbox that

en
ensures it should not have direct access to files or resources

C
available on the local system.
• Java Virtual Machine (JVM) which is a runtime environment for
h
executing Java programs applies its own security features to Java
ec

language.
pt

• JVM ensures that the code loaded for execution is well-formed and
rA

conforms to Java standards.


Fo

© Aptech Ltd. Introduction to Java/Session 1 25


y
nl
Architecture Neutral and Portable

O
se
• Supports portability by converting application into architecture
neutral bytecode during compilation.

U
• Java has defined language specifications, such as size of

tre
primitive data types and operators that are independent of the
hardware platform.

en
• For example, an integer variable in Java always occupies 32 bits
on whichever machine the code is executed.
C
• These features satisfies the major goal of Java language which is
h
‘Write once, run anywhere’.
ec
pt

Multithreaded
rA

• Allows a single program to perform multiple tasks


Fo

simultaneously with different threads.

© Aptech Ltd. Introduction to Java/Session 1 26


y
nl
Distributed

O
• Supports distributed programming in which resources can be

se
accessed across the network.

U
tre
Dynamic

en
• At runtime an application can dynamically decide which classes
it requires and loads them accordingly.
C
• This gives new perspective to Java for designing and developing
h
applications.
ec
pt
rA
Fo

© Aptech Ltd. Introduction to Java/Session 1 27


y
Is a software-only platform that runs on top of other

nl

O
hardware-based platforms.

se
 Contains Java Runtime Environment (JRE) with

U
components namely:

tre
 Java Virtual Machine (JVM)

en
 Java class library also referred to as Java Programming
Interface (Java API)
C
h
ec
pt
rA
Fo

© Aptech Ltd. Introduction to Java/Session 1 28


y
It is an executable engine that creates an environment for

nl

executing Java compiled code, that is, bytecode.

O
It is known as a virtual machine because it is an imitation of a

se

Java processor on the physical machine.

U
 There are different implementations of JVM available for

tre
different platforms, such as Windows, Unix, and Solaris.

en
C
h
ec
pt
rA
Fo

© Aptech Ltd. Introduction to Java/Session 1 29


y
Bytecode:

nl

O
 Is an intermediate form closer to
machine representation.

se
 Is an optimized set of instructions

U
executed by the Java runtime
environment.

tre
 This environment is known as

en
JVM.
 The same bytecode can be
executed by different C
h
ec

implementations of JVM on
pt

various platforms.
rA
Fo

© Aptech Ltd. Introduction to Java/Session 1 30


y
It is a large collection of ready-made software components.

nl

O
 These components are classes and interface grouped into
libraries referred to as packages in Java.

se
Example:

U

The Swing library provides classes for User Interface (UI) components.

tre

 The Input/Output (I/O) library provides the standard interface for reading

en
and writing data into files stored in the system.

C
h
ec
pt
rA
Fo

© Aptech Ltd. Introduction to Java/Session 1 31


y
Java Standard Edition (Java SE) - Is a base platform and enables

nl

to develop console and networking applications for desktop

O
computers.

se
 Java Enterprise Edition (Java EE) - Is built on top of Java SE

U
platform and provides a standard specification for developing

tre
and deploying distributed, scalable, and multi-tier enterprise

en
applications.
Java Mobile Edition (Java ME) - Is a robust platform for

C
developing embedded Java applications for consumer electronic
h
ec

devices, such as mobiles, Personal Digital Assistants (PDAs), and


TV set-top boxes.
pt
rA
Fo

© Aptech Ltd. Introduction to Java/Session 1 32


y
Provides two software components:

nl

O
 JRE
JRE provides JVM and Java libraries that are used to run a Java program.

se

 JDK

U
 Known as Java Development Kit (JDK).

tre
 Is a binary software development kit released by Oracle Corporation.
 Is an implementation of Java and distributed for different platforms, such as

en
Windows, Linux, Mac OS X, and so on.

C
 Contains a comprehensive set of tools, such as compilers and debuggers that
are used to develop Java applications.
h
ec
pt
rA
Fo

© Aptech Ltd. Introduction to Java/Session 1 33


y
Development Tools – Include tools used for compiling, running,

nl

debugging, and documenting a Java application.

O
se
U
API - Provides the core functionality of the Java programming

tre

language.

en
 Deployment Tools – Provides software for deploying the
C
developed applications to end-users.
h
 User Interface Toolkits - Enables the developer to create
ec

graphical interfaces in a Java application.


pt

 Integration libraries - Enable developers to access and


rA

manipulate database and remote objects in an application.


Fo

© Aptech Ltd. Introduction to Java/Session 1 34


y
Table lists the different releases of JDK.

nl

Releases Implementation

O
JDK 1.0 Creation of packages with classes in the standard library

se
JDK 1.1 Included an event delegation model for Graphical User
Interface (GUI) package AWT, JavaBeans, and Java

U
Database Connectivity (JDBC) API

tre
JDK 1.2 (Java 2) Included a new graphical API, named Swing. Also, added
APIs for reflection and collection framework (based on data

en
structure)

C
JDK 1.3 Included a directory interface to lookup for components,
named, Java Naming and Directory Interface (JNDI)
h
JDK 1.4 Included regular expression API, assertions, exception
ec

chaining, channel-based I/O API, an XML API for parsing


pt

and processing
rA

JDK 1.5 Included new features in the language such as for-each


loop, generics, annotations, and auto-boxing
Fo

JDK 1.6 Included script language, visual basic language support, and
improvements in the GUI
© Aptech Ltd. Introduction to Java/Session 1 35
y
Java SE 7 is the new major release of Java with internal version

nl

number as 1.7.

O
The lists of new features that are incorporated in the language

se

are as follows:

U
 Supports the use of String class in the switch decision-making

tre
construct.

en
 Integer types can be assigned with a binary number value.
 Supports the use of underscore character ( _ ) between the digits of a
numeric value. C
h
 An expandable try statement called try-with-resources
ec

statement used for automatic resource management.


pt

 Constructor of a generic class declaration can be replaced with an empty


rA

set of parameters (<>).


 Enhancement in exception handling mechanism. In exception handling
Fo

code, a single catch can be used to handle one or more exceptions.


 Compiler warnings generated for varargs methods has been improved.
© Aptech Ltd. Introduction to Java/Session 1 36
y
nl
O
On Oracle site, click

se
Download button to install

U
the JDK on download page

tre
en
C
h
ec
pt
rA
Fo

© Aptech Ltd. Introduction to Java/Session 1 37


y
nl
O
se
On Java SE Development Kit 7
Downloads Web page, click

U
Accept License Agreement.

tre
The agreement outlines that the
user agrees to Oracle by

en
installing the JDK

C
h
ec
pt
rA
Fo

© Aptech Ltd. Introduction to Java/Session 1 38


y
nl
O
se
U
tre
To download JDK 7 for

en
Windows 32-bit OS, click
jdk-7u11-windows-
i586.exe under C
h
Download
ec
pt
rA
Fo

© Aptech Ltd. Introduction to Java/Session 1 39


y
nl
O
se
U
tre
In the Save As dialog

en
box, select the location
C to save the JDK
installer and then, click
h
ec

Save
pt
rA
Fo

© Aptech Ltd. Introduction to Java/Session 1 40


y
Double-click the installer icon and follow the instructions

nl

provided by the JDK installer.

O
The installer installs development tools, source code, and the JRE

se

in the default directory, C:\Program Files\Java.

U
 Following figure shows the directory structure of the installed

tre
JDK on the system:

en
C
h
ec
pt
rA
Fo

© Aptech Ltd. Introduction to Java/Session 1 41


y
Following table lists the common directories that are part of the

nl

typical JDK installation:

O
se
Directory Description

U
bin Contains tools that are used for developing a
Java application, such as compiler and JVM

tre
db Contains a relational database named

en
Apache Derby

C
include Contains header files that are used to interact
with C applications
h
jre Represents the JRE used by the JDK
ec
pt
rA
Fo

© Aptech Ltd. Introduction to Java/Session 1 42


y
To work with JDK and Java programs, certain settings need to be

nl

made to the environment variables .

O
Environment variables are pointers pointing to programs or other

se

resources. The variables to be configured are as follows:

U
 PATH - Set to point to the location of Java executables (javac.exe and java.

tre
exe).

en
 CLASSPATH - Specifies the location of the class files and libraries needed
by the Java compiler to compile applications.
C
h
ec
pt
rA
Fo

© Aptech Ltd. Introduction to Java/Session 1 43


y
To set the value for the PATH variable, perform the following

nl

steps in Windows 7:

O
Right-click My Computer icon on the desktop and then, click Properties

se

from the context menu.

U
 Click Advanced system settings link on the left tab.

tre
 Under Advanced tab, click Environment Variables.
In the System variables area, select the PATH variable and then, click Edit

en

button to enter the JDK installation folder path.



C
Type path of the bin folder in the Variable Value text box.
h
 For example, the path can be:
ec

C:\ WINDOWS\system32;C:\WINDOWS;C:\Program
pt

Files\Java\jdk1.7.0\bin
rA
Fo

© Aptech Ltd. Introduction to Java/Session 1 44


y
To set CLASSPATH variable in Windows 7, perform the following

nl

steps:

O
Right-click My Computer icon on the desktop and click Properties from

se

the context menu.

U
 Click Advanced system settings link on the left tab.

tre
 Under Advanced tab, click Environment Variables.
In the System variables area, click New button.

en

 Type CLASSPATH in Variable Name and then, type C:\<jdk _


C
installation _ folder> in the Variable Value.
h
ec
pt
rA
Fo

© Aptech Ltd. Introduction to Java/Session 1 45


y
The development of application software is performed using

nl

a programming language that enforces a particular style of

O
programming, also referred to as programming paradigm.

se
In structured programming paradigm, the application

U

development is decomposed into a hierarchy of

tre
subprograms.

en
 In object-oriented programming paradigm, applications are
C
designed around data, rather than focusing only on the
h
functionalities.
ec

The main building blocks of an OOP language are classes


pt

and objects. An object represents a real-world entity and a


rA

class is a conceptual model.


Fo

© Aptech Ltd. Introduction to Java/Session 1 46


y
Java is an OOP language as well a platform used for

nl

developing applications that can be executed on different

O
platforms. Java platform is a software-only platform that

se
runs on top of the other hardware-based platforms.

U
The editions of Java platform are Java SE, Java EE, and Java

tre

ME.

en
 The components of Java SE platform are JDK and JRE. JRE
C
provides JVM and Java libraries that are used to run a Java
h
program. JDK includes the necessary development tools,
ec

runtime environment, and APIs for creating Java programs.


pt
rA
Fo

© Aptech Ltd. Introduction to Java/Session 1 47

You might also like