MISY 2312: Introductory Programming For Information Systems: Dr. Washah

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 41

Chapter 1

MISY 2312:
Introductory Programming
for Information Systems

Dr. Washah

1
Chapter 1
Computers, Programs, and Java
Chapter 1

A Typical PC

3
Chapter 1

Computer System consists of :


Hardware and Software
Hardware: Physical devices that you
see on your desktop

Software: Programs that give the


hardware useful functionality

4
Chapter 1

The Hardware
CPU Memory

Primary

ALU
Bus Secondary

Control
Unit Bus I/O

Internal Input
Registers
Output

5
Chapter 1

The Central Processing Unit (CPU)


The central processing unit (CPU) is
the brain and nerve center of the
entire system. This is where all of the
calculations and decisions are made.
In a PC system, the entire CPU is
contained within a single integrated
circuit (IC) chip called a
microprocessor.

6
Chapter 1

CPU

Internal Registers
ALU

Control Unit

7
Chapter 1

Typical Operations Performed by the ALU


Addition +
Subtraction 
Multiplication *
Division /
Modulus (Remainder) %
Equal to ==
Not equal to !=
Less than <
Less than or equal to <=
Greater than >
Greater than or equal to >=

8
Chapter 1

Primary Memory:
Primary memory often is called main
working memory. The reason for this
is that primary, or main, memory is used
To store programs and data while they
are being “worked,” or executed, by
the CPU.

9
Chapter 1

Binary Values

bit 0 or 1
byte 8 bits
kilobyte(KB) 1024 bytes
megabyte(MB) 1,048,576 bytes
gigabyte(GB) 1,073,741,824 bytes

10
Chapter 1
64 MB RAM
Memory Memory
Addresses Contents
(Data)

67,108,863 10010011
67,108,862 10010110

. .

. .
. .

1 11010111
0 10110111
11
Chapter 1

Secondary Memory:
Secondary memory, sometimes called bulk
or mass storage, is used to hold programs
and data on a semi-permanent basis. The
most common types of secondary memory
used in PC systems are magnetic disks and
CDs.

12
Chapter 1

Input:
Input is what goes into the system. Input
devices are hardware devices that provide a
means of entering programs and data into the
system. The major input devices for a PC
system are the keyboard, mouse, and disk
drive.

13
Chapter 1

Output:
Output is what comes out of the
system. Output devices are hardware
devices that provide a means of
getting data out of the system. The
four major output devices with which
you will be concerned are the display
monitor, printer, disk drive, and
modem.

14
Chapter 1

The Software
Computer software can be likened to
the driver of an automobile. Without
the driver, nothing happens. In other
words, the computer hardware by
itself can do nothing. A set of software
instructions that tells the computer
what to do is called a computer
program.

15
Chapter 1

Machine Language
All of the hardware components in a
computer system, including the CPU,
operate on a language made up of
binary 1’s and 0’s. A CPU does not
understand any other language.

16
Chapter 1

Assembly Language
Assembly language employs
alphabetic abbreviations called
mnemonics that are easily remembered
by you, the programmer. For instance,
the mnemonic for addition is ADD, the
mnemonic for move is MOV, and so
forth.

17
Chapter 1

High-Level Language:
A high-level language consists of
instructions, or statements, that are
similar to English and common
mathematical notation. When
programming in a high-level language, you
do not have to concern yourself with the
specific machine language of the CPU.
Rather, you can concentrate on solving
the problem at hand.

18
Chapter 1

Operating Systems
An operating system, or OS, is the
“glue” that binds the hardware to the
application software. Actually, an
operating system is a collection of
software programs dedicated to
managing the resources of the
system.

19
Chapter 1

A Quick Language Comparison


Feature C C++ C# VB.NET Java
ject-Oriented No Yes Yes Yes Yes
sy GUIs No No Yes Yes Yes
rtable No No No No Yes
ernet Programming No No Yes No Yes
sy Multitasking No No Yes No Yes
sy Database Connectivity No No Yes Yes Yes
ilt-In Security No No Yes No Yes
mplicity No No Yes Yes Yes
gh Speed Execution Yes Yes No No No
w Level Coding Yes Yes Yes No No
dely Accepted Yes Yes No Yes Yes
20
Chapter 1

In Java, you can write many different kinds of


programs, including applications, applets,
servlets, EJBs, and JavaBeans.

A Java application is designed to be run on a


computer just like any other computer program
written in any other language.

A Java applet is a program designed only to be


run over the Internet using a Web browser.
21
Chapter 1

Companies of all sizes are using Java as the main


programming language to develop various
applications/projects world wide
Java plays a significant role in the
corporate world.
It has found its use in various sectors
including banking, insurance, retail,
media, education, manufacturing and so
on.
E-commerce, Gaming, Mobile,
Embedded, Media and many more types
of applications are being developed
using Java 22
Chapter 1

What is Java
• Java is a simple and yet powerful object
oriented programming language and it is
in many respects similar to C++. Java
originated at Sun Microsystems, Inc. in
1991

23
Chapter 1

Java is a Platform
Java (with a capital J) is a platform for
application development. A platform is a
loosely defined computer industry
buzzword that typically means some
combination of hardware and system
software that will mostly run all the
same software. For instance PowerMacs
running Mac OS 9.2 would be one
platform.

24
Chapter 1
Computer programs are very
closely tied to the specific
hardware and operating system
they run. A Windows program
will not run on a computer that
only runs DOS. A Mac
application can't run on a Unix
workstation. VMS code can't
be executed on an IBM
mainframe
25
Chapter 1

Java solves the problem of


platform-independence by using
byte code. The Java compiler does
not produce native executable code
for a particular machine like a C
compiler would. Instead it
produces a special format called
byte code.
unlike machine language Java byte
code is exactly the same on every
platform
26
Chapter 1
Java is Object-Oriented
In object-oriented programs data is
represented by objects. Objects have two
sections, fields (instance variables) and
methods. Fields tell you what an object is.
Methods tell you what an object does.
These fields and methods are closely tied
to the object's real world characteristics
and behavior. When a program is run
messages are passed back and forth
between objects. When an object receives a
message it responds accordingly as defined
by its methods.
27
Chapter 1
Benefits of using Java

• 1) Java programming language is very simple and object-oriented. It’s


easy .

2) Java application run inside a Java Virtual Machine and now all
major operating systems are able to run Java including Windows,Mac
OS and UNIX. java application runs on all java platforms

3) Java technologies have been improved by community involvement.


This means it is suitable for most types of applications especially
complex systems that are used widely in network and distributed
computing

4) Java is also secure. Only Java applications that have permission can
access the resources of the main computer. This means that the main
computer is protected from virus attackers and hackers.

28
Chapter 1

Language Translation

A source program is the one that you


write in the Java language and that
always has a file extension of .java.

An object program is the binary byte-


code program generated by the Java
compiler, which always has a file
extension of .class.

29
Chapter 1

The .class file generated by the Java compiler


contains bytecode which is a low-level code
similar to machine language, but generic and not
specific to any particular CPU.
A given computer must have its own Java
interpreter as part of a Java Virtual Machine, or
JVM, to translate the generic bytecode into
machine language for that CPU.

30
Chapter 1
Compilers, Interpreters and
the Java Virtual Machine
Machine language consists of very simple instructions
that can be executed directly by the CPU of a
computer as it computes, retrieves and stores simple
binary numbers. Almost all programs, though, are
written in 'high-level languages' such as Java, Pascal
or C++. A program written in a high-level language
cannot be run directly on any computer. First, it has to
be translated into machine language. This translation
is carried out by a program called a compiler.

31
Chapter 1

Compilers
A compiler takes a high-level-language
program and translates it into an executable
machine-language program (translates the
program all at once). Once the translation
is done, the machine-language program can
be run any number of times, but of course
it can only be run on one type of computer
(since each type of computer has its own
machine language). If the program is to run
on another type of computer it has to be re-
translated, using a different compiler, into
the appropriate machine language 32
Chapter 1
Interpreters
There is an alternative to compiling a high-
level language program. Instead of using a
compiler, which translates the program all at
once, you can use an interpreter, which
translates it instruction-by-instruction, as
required.
purpose: they can let you use a machine-
language program meant for one type of
computer on a completely different type of
computer, thus performing a last moment
translation service
33
Chapter 1
The Java Virtual Machine
The designers of Java chose to use a
combination of compilation and
interpretation. Programs written in Java
are compiled into machine language, but it
is a machine language for a computer that
doesn't really exist. This so-called
"virtual" computer is known as the 'Java
Virtual Machine'. The machine language
for the Java virtual machine is called 'Java
Bytecode'.
34
Chapter 1
Cont.

one of the main selling points of


Java is that it can actually be used
on any computer. All that the
computer needs is an interpreter
for Java bytecode. Such an
interpreter simulates the Java
virtual machine

35
Chapter 1

36
Chapter 1
Enter/edit the Java program

Save

Source (.java) file

Java Fail
Correct errors
Compiler

Success

Java Translation Java Bytecode

Java Bytecode
Interpreter

Machine Language
Instructions Data for the Program

CPU Execution of Machine Language Instructions

Program Output

37
Chapter 1

Structured vs. Object-Oriented Languages:

The C language is a structured language


that allows complex problems to be
solved using a modular, top/down,
approach.
The Java language is an object-oriented
language that allows complex problems to
be solved in terms of their attributes and
behaviors, much like we humans view the
world.

38
Chapter 1

Object-oriented programming
(OOP)

Allows complex problems to be


solved using more natural objects
that model the way we humans think
about things in terms of attributes
and behavior.

39
Chapter 1
1   /*
2    HelloWorld.java Hello World!
3   *
4    Created on April 23, 2002, 7:47 AM
5    *
6    @author Andrew C. Staugaard, Jr. Block comment
7    @version 1.0
8    */
9            
10          Import StaugIO class Line comment
11  import staugIO.StaugIO; //FOR INPUT/OUTPUT METHODS
12         
13  public class HelloWorld
14  {//BEGIN CLASS
15         
16     public static void main (String args[]) Application class
17    {//BEGIN main()
18        StaugIO io = new StaugIO();
19         
Method main()
//DEFINE INPUT/OUTPUT OBJECT

20   io.writeInfo("Hello World!"); //USE OBJECT TO CALL writeInfo()


21         
22        //EXIT PROGRAM
23        System.exit(0);
24     }//END main()
25 }//END HelloWorld

Create io object
Use object to call
method 40
Chapter 1

End of Lecture Notes:


Please make sure to complete first
Assignment on time.
Due Date to be announced in the class
Please make sure to read chapter one of
your text book.

41

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy