Advance Computer Programming: by Hasnat Ali

Download as pdf or txt
Download as pdf or txt
You are on page 1of 48

Advance Computer

Programming

By
Hasnat Ali
Lecture Outlines
 Computer Programs and Programming Languages
 Programming Language Paradigms
 Introduction to Java
 Why Java
 History of Java Language
 Java’s Future
 Java’s Features
 Java Code Compiling Process
 Types of Java Applications
 The Java Language Specifications
 Java Application Programming Interface (API)
 The Java Development Kit (JDK)
 Java Development Tools (or IDEs)
 Summary
Computer Programs

 Computer programs known as software, are


instructions to the computer

 You tell a computer what to do through programs.


Computers do not understand human languages,
so you need to use computer languages to
communicate with them

 Programs are written using programming


languages
Programming Language

 A programming language is an artificial


language designed to communicate
instructions to a machine, particularly a
computer

 Programming languages can be used to create


programs that control the behavior of a machine
and/or to express algorithms precisely
Programming Language Paradigm

Programming Paradigms

Imperative Declarative

Procedural Modular Logic Functional

Structured Domain-Specific

Object-Oriented
Java - Introduction

 Java is the general purpose programming


language
 Java is the Internet Programming Language
 Java can be used to develop applications i.e.
 Desktop Applications, Java Applets
 Web applications Java Servlets and Java
Server Pages (JSP)
 Applications for hand-held devices such as
palm and cell phones
Why Java Language?
History of Java Language

Who Develops Java?

The Java language was developed at Sun


Microsystems in 1991 as part of a research project
to develop software for consumer electronics
devices.
Java’s Creator

Java is a programming language and


environment whose original name was
Oak and developed as a part of the
Green project at Sun started by James
Gosling.
Java’s Initial Goal

 Java’s goals at that time were to be small,


fast,
efficient, and easily portable to a wide
range of hardware devices.

 It is those same goals that made Java an


ideal language for distributing executable
programs via the World Wide Web.

“Write once, run anywhere!”


Java’s Features
Features of Java

 Java Is Simple
 Java Is Object-Oriented
 Java Is Distributed
 Java Is Interpreted
 Java Is Robust
 Java Is Secure
 Java Is Architecture-
Neutral
 Java Is Portable
 Java's Performance
 Java Is Multithreaded
 Java Is Dynamic
Features of Java

 Java Is Simple • Java is partially modeled on C++, but


 Java Is Object- greatly simplified and improved. Some
people refer to Java as "C++--" because it
Oriented is like C++ but with more functionality and
 Java Is Distributed fewer negative aspects
 Java Is Interpreted • Memory management is
automatic
 Java Is Robust • No pointers
 Java Is Architecture-
Neutral
 Java Is Portable
 Java's Performance
 Java Is Multithreaded
 Java Is Dynamic
Features of Java

 Java Is Simple • Java is inherently object-oriented.

 Java Is Object-Oriented Although many object-oriented


languages began strictly as procedural
 Java Is Distributed languages, Java was designed from

 Java Is Interpreted the start to be object- oriented.

 Java Is Robust • One of the central issues in software

 Java Is Secure development is how to reuse code.


Object- oriented programming provides
 Java Is Architecture- great flexibility, modularity, clarity, and
reusability through encapsulation,
Neutral inheritance, and polymorphism.
 Java Is Portable • Encapsulation
 Java's Performance • Inheritance

 Java Is Multithreaded • Polymorphism

 Java Is Dynamic
Features of Java

 Java Is Simple Distributed computing involves

 Java Is Object-Oriented
several computers working
together on a network.
 Java Is Distributed Java is designed to make
 Java Is Interpreted distributed computing easy. Since
 Java Is Robust networking capability is inherently
integrated into Java, writing
 Java Is Secure network programs is like sending
 Java Is Architecture- and receiving data to and from a
file.
Neutral
 Java Is Portable RMI(Remote Method
Invocation) CORBA
 Java's Performance
 Java Is Multithreaded
 Java Is Dynamic
Features of Java

 Java Is Simple You need an interpreter to run Java


 Java Is Object-Oriented programs. The programs are
compiled into the Java Virtual
 Java Is Distributed Machine code called bytecode.
 Java Is Interpreted
 Java Is Robust
The bytecode is machine-
independent and can run on any
 Java Is Secure machine that has a Java

 Java Is Architecture- interpreter, which is part of the


Java Virtual Machine (JVM).
Neutral
 Java Is Portable
 Java's Performance
 Java Is Multithreaded
 Java Is Dynamic
Features of Java
Java has eliminated certain types of
 Java Is Simple error- prone programming constructs

 Java Is Object-Oriented
found in other languages.

 Java Is Distributed Java has a runtime exception-

 Java Is Interpreted handling feature to provide


programming support for robustness.
 Java Is Robust
 Java Is Secure No error-prone constructs

 Java Is Architecture- Efficient Exception handling

Neutral
 Java Is Portable
 Java's Performance
 Java Is Multithreaded
 Java Is Dynamic
Features of Java

 Java Is Simple
 Java Is Object-Oriented
 Java Is Distributed Automatic null checking of references

 Java Is Interpreted Verification of type casting


Automatic array bound checking
 Java Is Robust Use of Final Classes
 Java Is Secure Security Manager

 Java Is Architecture-
Neutral
 Java Is Portable
 Java's Performance
 Java Is Multithreaded
 Java Is Dynamic
Features of Java

 Java Is Simple
Write once, run
anywhere
 Java Is Object- With a Java Virtual Machine (JVM),
you can write one program that will
Oriented run on any platform.
 Java Is Distributed
 Java Is Interpreted Byte code

 Java Is Robust
OS
independent
 Java Is Architecture-
Neutral
 Java Is Portable
 Java's Performance
 Java Is Multithreaded
 Java Is Dynamic
Features of Java

 Java Is Simple
 Java Is Object-Oriented
 Java Is Distributed
 Java Is Interpreted
 Java Is Robust
 Java Is Secure
 Java Is Architecture-
Neutral
 Java Is Portable Because Java is architecture neutral,
Java programs are portable.
 Java Is Multithreaded Java programs can be run on any
 Java Is Dynamic platform without being recompiled.
Features of Java

 Java Is Simple
 Java Is Object-Oriented
 Java Is Distributed
 Java Is Interpreted
 Java Is Robust
 Java Is Secure
 Java Is Architecture-
Neutral
 Java Is Portable Byte code includes compiling information
 Java's Performance Interpreter interprets byte code quickly

 Java Is Multithreaded
 Java Is Dynamic
Features of Java

 Java Is Simple
 Java Is Object-Oriented
 Java Is Distributed
 Java Is Interpreted
 Java Is Robust
 Java Is Secure
 Java Is Architecture- Multithread programming is smoothly
integrated in Java, whereas in other
Neutral
 Java Is Portable
languages you have to call procedures
specific to the operating system to
 Java's Performance enable multithreading.
 Java Is Multithreaded
 Java Is Dynamic Parallel task
Data sharing
Features of Java
Java was designed to adapt to an evolving
 Java Is Simple environment. New code can be loaded on

 Java Is Object- the fly without recompilation. There is no


need for developers to create, and for
Oriented users to install, major new software

 Java Is Distributed versions. New features can be incorporated


transparently as needed.
 Java Is Interpreted Extended class lib

 Java Is Robust Multiple inheritance based on


Interface
Secure
 Java Is Architecture-
Neutral
 Java Is Portable
 Java's Performance
 Java Is Multithreaded
 Java Is Dynamic
Summary of Java’s Features
Compiling C++ Source Code

A program written in a high-level language is called


a source program. Since a computer cannot
understand a source program. Program called a
compiler is used to translate the source program
into a machine language program called an object
program. The object program is often then linked
with other supporting library code before the object
can be executed on the machine.
Compiling Java Source Code
 Nowadays computers are networked to work together.
 Java was designed to run object programs on any platform.
 With Java, you write the program once, and compile the source
program into a special type of object code, known as bytecode.
 The bytecode can then run on any computer with a Java Virtual
Machine (JVM), as shown below.

 JVM is a software that interprets Java bytecode.


Creating, Compiling, and Running JAVA
Programs

Create/Modify Source C o d e

S ou rc e c od e (developed b y the p rogra m m er)


Sa ved o n the disk
public class Wel co me {
public static void main(String[] args) {
System.out.println("Welcome to Java!"); Source C o d e
}
}

Compile Source C o d e
B yt e c od e (generated b y the compiler for J V M i.e., javac Welcome.j ava
to read and interpret, not for you to understand)

Method Welcome() If compilation errors
0 aload_0 stored o n the disk

B ytecode
Method void main(java.lang.String[])
0 getstatic # 2 …
3 ldc # 3 <String "Wel co m e to
Java!">
5 invokevirtual # 4 …
8 return R u n Byteode
i.e., java Wel co me

R e su lt

If runtime errors or incorrect result


Platform-Independence

Other Language Java Platform


Types of Java Applications
In general, two types of
applications

 Normal/Desktop applications
 Web-based Applications

 Java Desktop Application


– Run on local computer
– Based on J2SE
 Java Applet
– Run on web browser
– Based on J2SE
 Java Servlet
– Run on application server
– Based on J2EE
 Enterprise JavaBeans
– Run on application server
– Based on J2EE
- JAVA Language Specification

- JAVA API (Application Programming


Interface)

- JAVA Editions

- JDK (Java Development Kit)

- JAVA IDE (Integrated Development


Environment)
Java’s Language Specification

The Java language specification is a technical


definition of the language that includes the
syntax and semantics of the Java programming
language. The complete Java language
specification can be found at

java.sun.com/docs/books/jls
Java API – Application Programming
Interface
The application program interface (API) contains predefined
classes and interfaces for developing Java programs.
The Java language specification is stable, but the API is still
expanding.
At the Sun Java Website (java.sun.com), you can view and
download the latest version of the Java API.
http://docs.oracle.com/javase/8/docs/index.html
Java’s Edition

Java is a full-fledged and powerful language that can be used in


many ways. It comes in three editions:
 Java Standard Edition (Java SE)
Java SE can be used to develop client-side standalone applications or
applets

 Java Enterprise Edition (Java EE)


Java EE can be used to develop server-side applications, such as Java
servlets and
Java Server Pages

 Java Micro Edition (Java ME)


Java ME can be used to develop applications for mobile devices, such as
cell phones.
Integrated Development Environments
(IDEs)

 An integrated development environment (IDE)


is a software application that provides
comprehensive facilities to computer
programmers for software development.

 An IDE normally consists of:


 a source code editor
 a debugger

 Some IDEs contain compiler, interpreter, or


both, such as Microsoft Visual Studio and
Eclipse
Integrated Development Environments
(IDEs)

 Besides JDK, you can use a Java development tool


(e.g., Net- Beans, Eclipse, and TextPad) — Software
that provides an integrated development environment
(IDE) for rapidly developing Java programs.

 Editing, compiling, building, debugging, and online


help are integrated in one graphical user interface. Just
enter source code in one window or open an existing file
in a window, then click a button, menu item, or function
key to compile and run the program.
JBuilder
Oracle JDeveloper
IntelliJIDEA
BEA Weblogic
Eclipse

• Eclipse Platform
• http://www.eclipse.org/platform
• Developed by the Apache Software
Foundation
NetBeans
JCreator
Notepad and Textpad
Java Communities

http://www.javaworld.com

http://docs.oracle.com/javase/tutorial/
Java Home
• http://java.sun.com
• http://www.java.com
• http://www.oracle.com/technetwork/java/index.htm
l
Java Supported Companies
Summary

 Introduction of Java
 Brief history of Java
 Features/characteristics of
Java
 Java compilation Process
 Types of Java Applications
 Java Development Kit
 Java Editions
 Java Development Tools

You might also like