SlideShare a Scribd company logo
IMPERATIVE PROGRAMMING LANGUAGE
IPL Paradigm
Closely resemble the architectural structure of actual computer
Based on manipulating bits and values and machine states.
Features
Use of abstract programming units like procedures and functions to encapsulate sequence
Statements which are executed in succession.
The way sequence of statements is executed is abstracted through a program or instruction
counter, which executes the series of instructions stored in memory.
Flow of execution can be manipulated or modified using conditional or looping statements
by abstracting the underlying branch instructions within the machine instruction set.
Usage of actual memory storage of the machine is abstracted through the use of variables
and using assignment statements to assign values to the variables.
Examples of IPL
FORTRAN, Algol, COBOL, Pascal, C/C++, BASIC, Ada, Java, PHP, C# and many more.
The Von Neumann Architecture
ALU CU
MEMORY
CPU
Instruction Set Architecture (ISA)
- Actual CPU instructions visible for the programmers can use
-They form the boundary between hardware and software
-Dimensions of ISA: Class, Memory Addressing, Address Modes, Operand types and
sizes, Operations, control flow instructions, encoding (fixed-length or variable)
IPL Characteristics
Variables and Storage
Commands:
Assignments
-Simple assignment : x = y + 1;
-Multiple assignments: v1 = v2 = v3 = v4 = 200;
-Simultaneous assignment: n1, n2, n3, n4 = m1, m2, m3, m4
-Operator-assignment : m += n
Procedure Calls
Sequential commands
-Control flow mechanism for executing commands in specific order,
Given C1; C2; C2 is executed after C1 is done
Collateral commands
Set of nondeterministic commands, where commands are executed in no particular order.
Conditional commands
-Given a set of subcommands, one is executed if a certain condition is met.
- Example: if-then and switch statements
Iterative commands
-Repeats execution of commands based on defined conditions.
-Uses control variables
-Example: for and while statements
IPL Side effects
Sequential execution can cause side-effects such as values of global variables are changed
inside procedure calls, which may make the program unreadable because some parts of
the program depend on what happens inside other parts.
imperative programming language, java, android
JAVA PROGRAMMING LANGUAGE
What is Java?
A general purpose, imperative, strongly-typed high-level, purely OOP language
Language by programmers for programmers.
Java Design
Platform-independent or architectural-neutral
Let developers create "write once, run anywhere“ applications
Origins
Created by James Gosling, Patrick Naughton, Chris Warth, Ed Frank, and Mike Sheridan in
1991 while at Sun Microsystems.
Initially called “Oak,” but was renamed “Java” in 1995.
Originally intended for embedded systems in consumer electronics, but eventually found
popularity in use for the world wide
Java remains a de facto standard, controlled through the Java Community Process.
9 million developers.
Java today
Java Platform
• Java Card for smartcards.
• Java Platform, Micro Edition (Java ME) – targeting environments with limited
resources.
• Java Platform, Standard Edition (Java SE) – targeting workstation environments.
• Java Platform, Enterprise Edition (Java EE) – targeting large distributed enterprise or
Internet environments.
Java development tools
Eclipse
Netbeans
Java Runtime Environment (JRE)
JVM, class libraries, and launcher
Java Development Kit (JDK)
Environment for building applications, applets, and components. Includes tools for
developing and testing and running Java programs.
Java resources
Java Native Interface (JNI)
Enables programmers to write native methods
The JNI framework lets a native method use Java objects
Java compilation
Source code
Java compiler
Byte code
JVM
(Architecture-
specific)
Target Instruction Set
C++: Compiles to a low-level instruction set that operates
on raw binary data and is specific to the target hardware,
such as x86, ARM, or PowerPC.
Java: Compiles to a higher-level portable bytecode that
operates on typed values: objects, primitive types, and
arrays thereof.
Compiler Optimizations
C++: Numerous code optimizations are performed at
compile time. Inline substitution results in copies of the
given (member) function being scattered around the
binary image; use of the preprocessor combined with
compile-time evaluation of expressions may leave no
trace of the constants defined in the source code; and so
on.
Java: Relies on dynamic (Just-In-Time) compilation for
performance improvement. The standard javac compiler
is straightforward, it does no compile time optimizations
commonly found in C++ compilers. The idea is to enable
the JIT compiler to perform all optimizations at run time,
taking the execution profile into account.
Linkage
C++: Programs are statically linked, and
metaprogramming facilities (reflection) are absent in the
core language. So the names of classes, members, and
variables need not be present in the compiled and linked
program, except for names exported from dynamic
libraries (DLLs/shared objects.)
Java: Dependencies are resolved at run time, when
classes are loaded. So the name of the class and names of
its methods and fields must be present in a class file, as
well as names of all imported classes, called methods,
and accessed fields.
Delivery Format
C++: An application is delivered as a monolithic
executable (maybe with a few dynamic libraries), so it is
not easy to identify all member functions of a given class
or reconstruct the class hierarchy.
Java: An application is typically delivered as a set of jar
files, which are just non-encrypted archives containing
individual class files.
Java vs. C/C++ Compilation
Java Virtual Machine
abstract
assert
boolean
break
byte
case
catch
char
class
Java language
const
continue
default
do
double
else
enum
extends
final
finally
Float
for
goto
if
implements
import
instanceof
int
interface
long
native
new
package
private
protected
public
return
short
static
strictfp
super
switch
synchronized
this
throw
throws
transient
try
void
volatile
while
Java primitive data types
Integers (byte, short, int long)
Floating point (float, double)
Others (char, boolean, arrays)
Java operators
Arithmetic: + * / % ++ += -= *= *= /= %= --
Bitwise : ~ & | ^ >> >>> << &= |= ^= >>= >>>= <<=
Relational : == != > < >= <=
Logical: && ! || != ?:
Java Arrays
type var-name[ ];
array-var = new type [size];
Java separators
“()” , “[]”, “{}”, “;” , “,” , “.”
Java control statements
if-else-statement
if (condition) statement1;
else statement2;
if(condition)
statement;
else if(condition)
statement;
else if(condition)
statement;
...
else
statement;
switch statement
switch (expression) {
case <value1>:
statement-list
break;
…
default: statement-list
}
while(condition) {
// body of loop
}
while statement
do-while statement
do {
// body of loop
} while (condition);
for statement
for(initialization;
condition;
iteration) {
// body
}
Polymorphism
Methods can share the same name as long as their parameter declarations are
different.
Java object-oriented paradigm
Encapsulation
Links data with the code that manipulates it.
Access modifers are public, private, and protected (affects inheritance).
Public : member can be accessed by any other code
Private: member can only be accessed by other members of its class.
Inheritance
class subclass-name extends superclass-name {
// body of class
}
A class member that has been declared as private will remain private to its class. It is not
accessible by any code outside its class, including subclasses.
Superclass
Whenever a subclass needs to refer to its immediate superclass, it can do so by use of the
keyword super.
super has two general forms. The first calls the superclass’ constructor. The second is
used to access a member of the superclass that has been hidden by a member of a
subclass
this keyword
this can be used inside any method to refer to the current object. It is always a reference to
the object on which the method was invoked.
Java object-oriented paradigm
A static member be accessed before any objects of its class are created, and without
reference to any object.
Both methods and variables can be declared as static.
Static keyword
Automatically handles the deallocation of objects.
Garbage Collection
Java exceptions
An exception is an object that describes an exceptional (that is, error) condition that has
occurred in a piece of code.
Exceptions thrown by Java relate to fundamental errors that violate the rules of the Java
language or the constraints of the Java execution environment. Manually generated
exceptions are typically used to report some error condition to the caller of a method.
Exception Handling
try
{
// block of code to monitor for errors
}
catch (ExceptionType execeptionObject)
{
//exception handler
}
...
finally
{
//final block of code to be executed
at the end
}
Java classes and objects
class classname
{
variable declarations
...
method declarations
...
}
class definition
Object declaration
classname varname = new classname();
type name(parameter-list) {
// body of method
}
Method declaration
Java program units
Package – used to partition class name space into smaller chunks
Class – fundamental code units in java; consists of functions and variables.
Function – encapsulates 1 or more statements; may also contain local variables
Statement blocks – consists of one or more java statements enclosed in curly brackets
Bindings
Identifiers – Static
Type – static
Address – Dynamic
Value – Dynamic
Storage – Objects are dynamically allocated
Local variable storage lasts until the method returns.
Package Scope Rules
Private No Modifier Protected Public
Same class Yes Yes Yes Yes
Same package
subclass
No Yes Yes Yes
Same package,
non subclass
NO Yes Yes Yes
Different
package,
subclass
No No Yes Yes
Different
package, non
subclass
No No No Yes
Class Scope Rules
All members of a class are visible to any part of the class (depends if the static keyword
Is used on some members, which affects scope visibility)
Local variables within methods is only visible within the method.
Variables declared within blocks is only visible within the block.
Multithreading
In a thread-based multitasking environment, the thread is the smallest unit of
dispatchable code. This means that a single program can perform two or more tasks
simultaneously
Creating a Thread
In the most general sense, you create a thread by instantiating an object of type Thread.
Java denotes two ways in which this can be accomplished:
• You can implement the Runnable interface.
• You can extend the Thread class, itself.
class NewThread implements Runnable {
Thread t;
NewThread() {
t = new Thread(this,"Demo thread");
System.out.println("child thread: " + t);
t.start();
}
public void run() {
try {
//some statements here
Thread.sleep(500);
}
catch(Exception e) {
System.out.println("Exiting child thread.");
}
}
}
class ThreadDemo{
public static void main(String []args) {
new NewThread();
// main thread statements
}
}
Example using Runnable :
class NewThread extends Thread{
NewThread(){
System.out.println("Child thread: " + this);
start();
}
public void run(){
// thread statements
Thread.sleep(500);
}
}
class ExtendThread{
public static void main(String [] args){
new NewThread();
//main thread statement
Thread.sleep(1000);
}
}
Example by extending Thread:
imperative programming language, java, android
ANDROID
Android the OS
Android is a mobile operating system developed by Google, based on the Linux kernel and
designed primarily for mobile devices such as smartphones and tablets.
Android, Inc. was by Andy Rubin in 2003 (Acquired by Google in 2005)
On the Open Handset Alliance, a consortium of technology companies including Google,
device manufacturers such as HTC, Sony and Samsung, wireless carriers such as Sprint
Nextel and T-Mobile, and chipset makers such as Qualcomm and Texas Instruments,
unveiled itself, with a goal to develop open standards for mobile devices.
Dalvik is a process virtual machine (VM) that executes Android applications (Android 4.4
and earlier). Dalvik is open-source software, originally written by Dan Bornstein, who
named it after the fishing village of Dalvík in Eyjafjörður, Iceland.
Android Runtime Environment
Android Runtime (ART) is an application runtime environment replacing Dalvik
ART performs the translation of the application's bytecode into native instructions that
are later executed by the device's runtime environment.
imperative programming language, java, android
Android SDK
For developing applications for the Android operating system.
Applications are usually developed in Java programming language using the Android
software development kit (SDK), but other development environments are also available.
Linux, Mac OS X, and Windows are supported platforms.
Officially supported integrated development environments (IDE) are Eclipse using the
Android Development Tools (ADT) Plugin, NetBeans IDE, and Android Studio, made by
Google and powered by IntelliJ.
Developers may use any text editor to edit Java and XML files, then use command line
tools (Java Development Kit and Apache Ant are required) to create, build and debug
Android applications as well as control attached Android devices.
The SDK includes a debugger, libraries, a handset emulator based on QEMU,
documentation, sample code, and tutorials.
Android Development Platform
Android ADB
A command line tool that for communicating with an emulator or Android-powered device.
Support native development in C/C++.
Android Native Development Kit (NDK)
Extensions for IDEs to support android development, such as Eclipse.
Android Development Toolkit (ADT)
Android Development Platform
Android SDK Manager
Manages download or updating of SDK packages and tools.
Android ADB
Android Application Build Process
Java source
Java
Compiler
Java class
(byte code)
Dx ToolDex file
APK BuilderJar signer
APK file
Library
resources

More Related Content

What's hot (20)

Java basics notes
Java basics notes
poonguzhali1826
 
Introduction to java
Introduction to java
Ajay Sharma
 
SMI - Introduction to Java
SMI - Introduction to Java
SMIJava
 
Lecture 3 java basics
Lecture 3 java basics
the_wumberlog
 
Core Java
Core Java
Prakash Dimmita
 
C progrmming
C progrmming
Shivam Singhal
 
Core java online training
Core java online training
Glory IT Technologies Pvt. Ltd.
 
Object oriented programming-with_java
Object oriented programming-with_java
Hoang Nguyen
 
Java Presentation For Syntax
Java Presentation For Syntax
PravinYalameli
 
Java &amp; advanced java
Java &amp; advanced java
BASAVARAJ HUNSHAL
 
Introduction to java
Introduction to java
Sandeep Rawat
 
JAVA Program Examples
JAVA Program Examples
Prof Chethan Raj C
 
Java tutorial PPT
Java tutorial PPT
Intelligo Technologies
 
java tutorial for beginner - Free Download
java tutorial for beginner - Free Download
TIB Academy
 
Java Tutorial
Java Tutorial
Vijay A Raj
 
Introduction to Java programming - Java tutorial for beginners to teach Java ...
Introduction to Java programming - Java tutorial for beginners to teach Java ...
Duckademy IT courses
 
Java notes
Java notes
Debasish Biswas
 
Java introduction
Java introduction
The icfai university jaipur
 
Core java
Core java
kasaragaddaslide
 
Core java
Core java
Shivaraj R
 

Similar to imperative programming language, java, android (20)

Introduction to java (revised)
Introduction to java (revised)
Sujit Majety
 
java notes.pdf
java notes.pdf
JitendraYadav351971
 
Java training materials for computer engineering.pdf
Java training materials for computer engineering.pdf
SkvKirupasri
 
introduction to object orinted programming through java
introduction to object orinted programming through java
Parameshwar Maddela
 
PJ_M01_C01_PPT_Introduction to Object Oriented Programming Using Java.pdf
PJ_M01_C01_PPT_Introduction to Object Oriented Programming Using Java.pdf
projectfora2
 
UNIT 1.pptx
UNIT 1.pptx
EduclentMegasoftel
 
Java
Java
Sneha Mudraje
 
Java UNITbgbgbfdbv v bbfbf cvbgfbvc gf 1.pptx
Java UNITbgbgbfdbv v bbfbf cvbgfbvc gf 1.pptx
hofon47654
 
object oriented programming unit one ppt
object oriented programming unit one ppt
isiagnel2
 
Basics-Of-Java
Basics-Of-Java
ssuser200038
 
Mpl 1
Mpl 1
AHHAAH
 
j-chap1-Basics.ppt
j-chap1-Basics.ppt
SmitaBorkar9
 
Knowledge of Javascript
Knowledge of Javascript
Samuel Abraham
 
Module--fundamentals and operators in java1.pptx
Module--fundamentals and operators in java1.pptx
Radhika Venkatesh
 
Unit1 introduction to Java
Unit1 introduction to Java
DevaKumari Vijay
 
oop unit1.pptx
oop unit1.pptx
sureshkumara29
 
Learning Java Beginning programming with java for dummies First Edition John ...
Learning Java Beginning programming with java for dummies First Edition John ...
dionegorra0l
 
Top 10 Important Core Java Interview questions and answers.pdf
Top 10 Important Core Java Interview questions and answers.pdf
Umesh Kumar
 
Introduction To Java.
Introduction To Java.
Tushar Chauhan
 
CS8392 OOP
CS8392 OOP
DhanalakshmiVelusamy1
 
Introduction to java (revised)
Introduction to java (revised)
Sujit Majety
 
Java training materials for computer engineering.pdf
Java training materials for computer engineering.pdf
SkvKirupasri
 
introduction to object orinted programming through java
introduction to object orinted programming through java
Parameshwar Maddela
 
PJ_M01_C01_PPT_Introduction to Object Oriented Programming Using Java.pdf
PJ_M01_C01_PPT_Introduction to Object Oriented Programming Using Java.pdf
projectfora2
 
Java UNITbgbgbfdbv v bbfbf cvbgfbvc gf 1.pptx
Java UNITbgbgbfdbv v bbfbf cvbgfbvc gf 1.pptx
hofon47654
 
object oriented programming unit one ppt
object oriented programming unit one ppt
isiagnel2
 
j-chap1-Basics.ppt
j-chap1-Basics.ppt
SmitaBorkar9
 
Knowledge of Javascript
Knowledge of Javascript
Samuel Abraham
 
Module--fundamentals and operators in java1.pptx
Module--fundamentals and operators in java1.pptx
Radhika Venkatesh
 
Unit1 introduction to Java
Unit1 introduction to Java
DevaKumari Vijay
 
Learning Java Beginning programming with java for dummies First Edition John ...
Learning Java Beginning programming with java for dummies First Edition John ...
dionegorra0l
 
Top 10 Important Core Java Interview questions and answers.pdf
Top 10 Important Core Java Interview questions and answers.pdf
Umesh Kumar
 
Ad

More from i i (15)

Bouncing circle
Bouncing circle
i i
 
0-1 KNAPSACK PROBLEM
0-1 KNAPSACK PROBLEM
i i
 
sequential and combinational circuits exam
sequential and combinational circuits exam
i i
 
hypothesis testing overview
hypothesis testing overview
i i
 
x86 architecture
x86 architecture
i i
 
boolean algebra exercises
boolean algebra exercises
i i
 
database normalization case study
database normalization case study
i i
 
cpbricks context diagram
cpbricks context diagram
i i
 
cpbricks project document
cpbricks project document
i i
 
cpbricks manual
cpbricks manual
i i
 
shortest job first
shortest job first
i i
 
designing reports
designing reports
i i
 
bnf of c switch statement
bnf of c switch statement
i i
 
shell and merge sort
shell and merge sort
i i
 
adders/subtractors, multiplexers, intro to ISA
adders/subtractors, multiplexers, intro to ISA
i i
 
Bouncing circle
Bouncing circle
i i
 
0-1 KNAPSACK PROBLEM
0-1 KNAPSACK PROBLEM
i i
 
sequential and combinational circuits exam
sequential and combinational circuits exam
i i
 
hypothesis testing overview
hypothesis testing overview
i i
 
x86 architecture
x86 architecture
i i
 
boolean algebra exercises
boolean algebra exercises
i i
 
database normalization case study
database normalization case study
i i
 
cpbricks context diagram
cpbricks context diagram
i i
 
cpbricks project document
cpbricks project document
i i
 
cpbricks manual
cpbricks manual
i i
 
shortest job first
shortest job first
i i
 
designing reports
designing reports
i i
 
bnf of c switch statement
bnf of c switch statement
i i
 
shell and merge sort
shell and merge sort
i i
 
adders/subtractors, multiplexers, intro to ISA
adders/subtractors, multiplexers, intro to ISA
i i
 
Ad

Recently uploaded (20)

IBM Rational Unified Process For Software Engineering - Introduction
IBM Rational Unified Process For Software Engineering - Introduction
Gaurav Sharma
 
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Varsha Nayak
 
Generative Artificial Intelligence and its Applications
Generative Artificial Intelligence and its Applications
SandeepKS52
 
wAIred_RabobankIgniteSession_12062025.pptx
wAIred_RabobankIgniteSession_12062025.pptx
SimonedeGijt
 
Migrating to Azure Cosmos DB the Right Way
Migrating to Azure Cosmos DB the Right Way
Alexander (Alex) Komyagin
 
Zoneranker’s Digital marketing solutions
Zoneranker’s Digital marketing solutions
reenashriee
 
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
WSO2
 
Software Engineering Process, Notation & Tools Introduction - Part 3
Software Engineering Process, Notation & Tools Introduction - Part 3
Gaurav Sharma
 
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
joybepari360
 
Advanced Token Development - Decentralized Innovation
Advanced Token Development - Decentralized Innovation
arohisinghas720
 
FME as an Orchestration Tool - Peak of Data & AI 2025
FME as an Orchestration Tool - Peak of Data & AI 2025
Safe Software
 
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
usmanch7829
 
MOVIE RECOMMENDATION SYSTEM, UDUMULA GOPI REDDY, Y24MC13085.pptx
MOVIE RECOMMENDATION SYSTEM, UDUMULA GOPI REDDY, Y24MC13085.pptx
Maharshi Mallela
 
What is data visualization and how data visualization tool can help.pdf
What is data visualization and how data visualization tool can help.pdf
Varsha Nayak
 
How Insurance Policy Management Software Streamlines Operations
How Insurance Policy Management Software Streamlines Operations
Insurance Tech Services
 
Reimagining Software Development and DevOps with Agentic AI
Reimagining Software Development and DevOps with Agentic AI
Maxim Salnikov
 
Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...
Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...
Natan Silnitsky
 
Who will create the languages of the future?
Who will create the languages of the future?
Jordi Cabot
 
AI-Powered Compliance Solutions for Global Regulations | Certivo
AI-Powered Compliance Solutions for Global Regulations | Certivo
certivoai
 
Neuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
Neuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
alexandernoetzold
 
IBM Rational Unified Process For Software Engineering - Introduction
IBM Rational Unified Process For Software Engineering - Introduction
Gaurav Sharma
 
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Varsha Nayak
 
Generative Artificial Intelligence and its Applications
Generative Artificial Intelligence and its Applications
SandeepKS52
 
wAIred_RabobankIgniteSession_12062025.pptx
wAIred_RabobankIgniteSession_12062025.pptx
SimonedeGijt
 
Zoneranker’s Digital marketing solutions
Zoneranker’s Digital marketing solutions
reenashriee
 
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
WSO2
 
Software Engineering Process, Notation & Tools Introduction - Part 3
Software Engineering Process, Notation & Tools Introduction - Part 3
Gaurav Sharma
 
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
joybepari360
 
Advanced Token Development - Decentralized Innovation
Advanced Token Development - Decentralized Innovation
arohisinghas720
 
FME as an Orchestration Tool - Peak of Data & AI 2025
FME as an Orchestration Tool - Peak of Data & AI 2025
Safe Software
 
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
usmanch7829
 
MOVIE RECOMMENDATION SYSTEM, UDUMULA GOPI REDDY, Y24MC13085.pptx
MOVIE RECOMMENDATION SYSTEM, UDUMULA GOPI REDDY, Y24MC13085.pptx
Maharshi Mallela
 
What is data visualization and how data visualization tool can help.pdf
What is data visualization and how data visualization tool can help.pdf
Varsha Nayak
 
How Insurance Policy Management Software Streamlines Operations
How Insurance Policy Management Software Streamlines Operations
Insurance Tech Services
 
Reimagining Software Development and DevOps with Agentic AI
Reimagining Software Development and DevOps with Agentic AI
Maxim Salnikov
 
Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...
Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...
Natan Silnitsky
 
Who will create the languages of the future?
Who will create the languages of the future?
Jordi Cabot
 
AI-Powered Compliance Solutions for Global Regulations | Certivo
AI-Powered Compliance Solutions for Global Regulations | Certivo
certivoai
 
Neuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
Neuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
alexandernoetzold
 

imperative programming language, java, android

  • 2. IPL Paradigm Closely resemble the architectural structure of actual computer Based on manipulating bits and values and machine states. Features Use of abstract programming units like procedures and functions to encapsulate sequence Statements which are executed in succession. The way sequence of statements is executed is abstracted through a program or instruction counter, which executes the series of instructions stored in memory. Flow of execution can be manipulated or modified using conditional or looping statements by abstracting the underlying branch instructions within the machine instruction set. Usage of actual memory storage of the machine is abstracted through the use of variables and using assignment statements to assign values to the variables. Examples of IPL FORTRAN, Algol, COBOL, Pascal, C/C++, BASIC, Ada, Java, PHP, C# and many more.
  • 3. The Von Neumann Architecture ALU CU MEMORY CPU Instruction Set Architecture (ISA) - Actual CPU instructions visible for the programmers can use -They form the boundary between hardware and software -Dimensions of ISA: Class, Memory Addressing, Address Modes, Operand types and sizes, Operations, control flow instructions, encoding (fixed-length or variable)
  • 4. IPL Characteristics Variables and Storage Commands: Assignments -Simple assignment : x = y + 1; -Multiple assignments: v1 = v2 = v3 = v4 = 200; -Simultaneous assignment: n1, n2, n3, n4 = m1, m2, m3, m4 -Operator-assignment : m += n Procedure Calls Sequential commands -Control flow mechanism for executing commands in specific order, Given C1; C2; C2 is executed after C1 is done Collateral commands Set of nondeterministic commands, where commands are executed in no particular order. Conditional commands -Given a set of subcommands, one is executed if a certain condition is met. - Example: if-then and switch statements Iterative commands -Repeats execution of commands based on defined conditions. -Uses control variables -Example: for and while statements
  • 5. IPL Side effects Sequential execution can cause side-effects such as values of global variables are changed inside procedure calls, which may make the program unreadable because some parts of the program depend on what happens inside other parts.
  • 8. What is Java? A general purpose, imperative, strongly-typed high-level, purely OOP language Language by programmers for programmers. Java Design Platform-independent or architectural-neutral Let developers create "write once, run anywhere“ applications Origins Created by James Gosling, Patrick Naughton, Chris Warth, Ed Frank, and Mike Sheridan in 1991 while at Sun Microsystems. Initially called “Oak,” but was renamed “Java” in 1995. Originally intended for embedded systems in consumer electronics, but eventually found popularity in use for the world wide Java remains a de facto standard, controlled through the Java Community Process. 9 million developers. Java today
  • 9. Java Platform • Java Card for smartcards. • Java Platform, Micro Edition (Java ME) – targeting environments with limited resources. • Java Platform, Standard Edition (Java SE) – targeting workstation environments. • Java Platform, Enterprise Edition (Java EE) – targeting large distributed enterprise or Internet environments. Java development tools Eclipse Netbeans Java Runtime Environment (JRE) JVM, class libraries, and launcher Java Development Kit (JDK) Environment for building applications, applets, and components. Includes tools for developing and testing and running Java programs. Java resources Java Native Interface (JNI) Enables programmers to write native methods The JNI framework lets a native method use Java objects
  • 10. Java compilation Source code Java compiler Byte code JVM (Architecture- specific)
  • 11. Target Instruction Set C++: Compiles to a low-level instruction set that operates on raw binary data and is specific to the target hardware, such as x86, ARM, or PowerPC. Java: Compiles to a higher-level portable bytecode that operates on typed values: objects, primitive types, and arrays thereof. Compiler Optimizations C++: Numerous code optimizations are performed at compile time. Inline substitution results in copies of the given (member) function being scattered around the binary image; use of the preprocessor combined with compile-time evaluation of expressions may leave no trace of the constants defined in the source code; and so on. Java: Relies on dynamic (Just-In-Time) compilation for performance improvement. The standard javac compiler is straightforward, it does no compile time optimizations commonly found in C++ compilers. The idea is to enable the JIT compiler to perform all optimizations at run time, taking the execution profile into account. Linkage C++: Programs are statically linked, and metaprogramming facilities (reflection) are absent in the core language. So the names of classes, members, and variables need not be present in the compiled and linked program, except for names exported from dynamic libraries (DLLs/shared objects.) Java: Dependencies are resolved at run time, when classes are loaded. So the name of the class and names of its methods and fields must be present in a class file, as well as names of all imported classes, called methods, and accessed fields. Delivery Format C++: An application is delivered as a monolithic executable (maybe with a few dynamic libraries), so it is not easy to identify all member functions of a given class or reconstruct the class hierarchy. Java: An application is typically delivered as a set of jar files, which are just non-encrypted archives containing individual class files. Java vs. C/C++ Compilation
  • 13. abstract assert boolean break byte case catch char class Java language const continue default do double else enum extends final finally Float for goto if implements import instanceof int interface long native new package private protected public return short static strictfp super switch synchronized this throw throws transient try void volatile while Java primitive data types Integers (byte, short, int long) Floating point (float, double) Others (char, boolean, arrays) Java operators Arithmetic: + * / % ++ += -= *= *= /= %= -- Bitwise : ~ & | ^ >> >>> << &= |= ^= >>= >>>= <<= Relational : == != > < >= <= Logical: && ! || != ?: Java Arrays type var-name[ ]; array-var = new type [size]; Java separators “()” , “[]”, “{}”, “;” , “,” , “.”
  • 14. Java control statements if-else-statement if (condition) statement1; else statement2; if(condition) statement; else if(condition) statement; else if(condition) statement; ... else statement; switch statement switch (expression) { case <value1>: statement-list break; … default: statement-list } while(condition) { // body of loop } while statement do-while statement do { // body of loop } while (condition); for statement for(initialization; condition; iteration) { // body }
  • 15. Polymorphism Methods can share the same name as long as their parameter declarations are different. Java object-oriented paradigm Encapsulation Links data with the code that manipulates it. Access modifers are public, private, and protected (affects inheritance). Public : member can be accessed by any other code Private: member can only be accessed by other members of its class. Inheritance class subclass-name extends superclass-name { // body of class } A class member that has been declared as private will remain private to its class. It is not accessible by any code outside its class, including subclasses.
  • 16. Superclass Whenever a subclass needs to refer to its immediate superclass, it can do so by use of the keyword super. super has two general forms. The first calls the superclass’ constructor. The second is used to access a member of the superclass that has been hidden by a member of a subclass this keyword this can be used inside any method to refer to the current object. It is always a reference to the object on which the method was invoked. Java object-oriented paradigm A static member be accessed before any objects of its class are created, and without reference to any object. Both methods and variables can be declared as static. Static keyword Automatically handles the deallocation of objects. Garbage Collection
  • 17. Java exceptions An exception is an object that describes an exceptional (that is, error) condition that has occurred in a piece of code. Exceptions thrown by Java relate to fundamental errors that violate the rules of the Java language or the constraints of the Java execution environment. Manually generated exceptions are typically used to report some error condition to the caller of a method. Exception Handling try { // block of code to monitor for errors } catch (ExceptionType execeptionObject) { //exception handler } ... finally { //final block of code to be executed at the end }
  • 18. Java classes and objects class classname { variable declarations ... method declarations ... } class definition Object declaration classname varname = new classname(); type name(parameter-list) { // body of method } Method declaration
  • 19. Java program units Package – used to partition class name space into smaller chunks Class – fundamental code units in java; consists of functions and variables. Function – encapsulates 1 or more statements; may also contain local variables Statement blocks – consists of one or more java statements enclosed in curly brackets Bindings Identifiers – Static Type – static Address – Dynamic Value – Dynamic Storage – Objects are dynamically allocated Local variable storage lasts until the method returns.
  • 20. Package Scope Rules Private No Modifier Protected Public Same class Yes Yes Yes Yes Same package subclass No Yes Yes Yes Same package, non subclass NO Yes Yes Yes Different package, subclass No No Yes Yes Different package, non subclass No No No Yes
  • 21. Class Scope Rules All members of a class are visible to any part of the class (depends if the static keyword Is used on some members, which affects scope visibility) Local variables within methods is only visible within the method. Variables declared within blocks is only visible within the block.
  • 22. Multithreading In a thread-based multitasking environment, the thread is the smallest unit of dispatchable code. This means that a single program can perform two or more tasks simultaneously Creating a Thread In the most general sense, you create a thread by instantiating an object of type Thread. Java denotes two ways in which this can be accomplished: • You can implement the Runnable interface. • You can extend the Thread class, itself.
  • 23. class NewThread implements Runnable { Thread t; NewThread() { t = new Thread(this,"Demo thread"); System.out.println("child thread: " + t); t.start(); } public void run() { try { //some statements here Thread.sleep(500); } catch(Exception e) { System.out.println("Exiting child thread."); } } } class ThreadDemo{ public static void main(String []args) { new NewThread(); // main thread statements } } Example using Runnable :
  • 24. class NewThread extends Thread{ NewThread(){ System.out.println("Child thread: " + this); start(); } public void run(){ // thread statements Thread.sleep(500); } } class ExtendThread{ public static void main(String [] args){ new NewThread(); //main thread statement Thread.sleep(1000); } } Example by extending Thread:
  • 27. Android the OS Android is a mobile operating system developed by Google, based on the Linux kernel and designed primarily for mobile devices such as smartphones and tablets. Android, Inc. was by Andy Rubin in 2003 (Acquired by Google in 2005) On the Open Handset Alliance, a consortium of technology companies including Google, device manufacturers such as HTC, Sony and Samsung, wireless carriers such as Sprint Nextel and T-Mobile, and chipset makers such as Qualcomm and Texas Instruments, unveiled itself, with a goal to develop open standards for mobile devices.
  • 28. Dalvik is a process virtual machine (VM) that executes Android applications (Android 4.4 and earlier). Dalvik is open-source software, originally written by Dan Bornstein, who named it after the fishing village of Dalvík in Eyjafjörður, Iceland. Android Runtime Environment Android Runtime (ART) is an application runtime environment replacing Dalvik ART performs the translation of the application's bytecode into native instructions that are later executed by the device's runtime environment.
  • 30. Android SDK For developing applications for the Android operating system. Applications are usually developed in Java programming language using the Android software development kit (SDK), but other development environments are also available. Linux, Mac OS X, and Windows are supported platforms. Officially supported integrated development environments (IDE) are Eclipse using the Android Development Tools (ADT) Plugin, NetBeans IDE, and Android Studio, made by Google and powered by IntelliJ. Developers may use any text editor to edit Java and XML files, then use command line tools (Java Development Kit and Apache Ant are required) to create, build and debug Android applications as well as control attached Android devices. The SDK includes a debugger, libraries, a handset emulator based on QEMU, documentation, sample code, and tutorials. Android Development Platform
  • 31. Android ADB A command line tool that for communicating with an emulator or Android-powered device. Support native development in C/C++. Android Native Development Kit (NDK) Extensions for IDEs to support android development, such as Eclipse. Android Development Toolkit (ADT) Android Development Platform Android SDK Manager Manages download or updating of SDK packages and tools.
  • 33. Android Application Build Process Java source Java Compiler Java class (byte code) Dx ToolDex file APK BuilderJar signer APK file Library resources