SlideShare uma empresa Scribd logo
1 de 50
AN OVERVIEW OF
COMPUTERS &
PROGRAMMING
LANGUAGES
GOALS
 To understand the activity of programming
 To learn about the components of computers
 To learn about level of programming languages
 To become familiar with your computing
environment and your compiler
 To compile and run your first Java program
 To recognize 3 types of errors
What is Programming?
 Computer programming
 the art and science of designing and writing
computer programs.
 Computer program
 a sequences of instructions written in a
programming language to achieve a task/to solve
a problem.
What is a computer?
 Hardware
 the physical, tangible parts of a computer
 keyboard, monitor, disks, wires, chips, etc.
 Software
 programs and data
 a program is a series of instructions
 A computer requires both hardware and software
 Each is essentially useless without the other
Computer System Organization
Hardware
•CPU
•Main Memory (RAM)
•Secondary Storage
•I/O Device
Software
•System Programs
•Application Programs
Computer Organization
Hardware Components
of a Computer
Hardware Components
of a Computer – motherboard
processor chip
adapter cards
memory chips
memory slots
motherboard
Expansion
slots for
adapter cards
Hardware Components of a Computer
CPU
Brain of the
computer, most
expensive, the
faster computer.
CPU components–
control unit,
program counter,
register instruction,
arithmetic logic
unit, accumulator.
RAM
Temporary memory,
volatile, directly
connected to the
CPU, using
memory cells unit.
SECONDARY STORAGE
•Provides permanent storage for
information.
•Examples of secondary storage:
•Hard disks
•Floppy disks
•Zip disks
•CD-ROMs
•Tapes.
Hardware Components of a Computer
RAM vs Secondary Storage
 Primary memory
 volatile
 Fast
 Expensive
 Low capacity
 Works directly with the processor
 Secondary Storage
 Nonvolatile
 Slow
 Cheap
 Large capacity
 Not connected directly to the processor
INPUT DEVICES
Sheet-fed
Hardware Components of a Computer
OUTPUT DEVICES
Hardware Components of a Computer
CPU and Main Memory
Central
Processing
Unit
Main
Memory
Chip that executes
program commands
Eg.
Intel Pentium 4
Sun ultraSPARC III
Primary storage area
for programs and data
that are in active use
Synonymous with
RAM
Secondary Memory Devices
Central
Processing
Unit
Main
Memory
Floppy Disk
Hard Disk
Secondary memory
devices provide
long-term storage
Information is moved
between main memory
and secondary memory
as needed
Hard disks
Floppy disks
USB drives
Writable CDs
Writable DVDs
Tapes
Input / Output Devices
Central
Processing
Unit
Main
Memory
Floppy Disk
Hard Disk
Monitor
Keyboard
I/O devices facilitate
user interaction
Monitor screen
Keyboard
Mouse
Joystick
Bar code scanner
Touch screen
Software
 In contrast to hardware, software is an abstract, intangible
entity.
 Software can be categorized as system or application
software (refer next slide)
 It consists of program and data to be used to perform
certain tasks
 A program is a sequence of simple steps and operations,
stated in a precise language that the hardware can interpret
 The process of programming involve algorithm design &
coding.
Software Categories
 System Software
 Systems programs keep all the hardware and software running
together smoothly
 The most important system software is the operating system (OS)
 controls all machine activities
 provides the user interface to the computer
 manages resources such as the CPU, memory & I/O
 Windows XP, Unix, Linux, Mac OS
 Application Software
 generic term for any other kind of softwares
 word processors, Spreadsheets, Web browsers, games
Algorithm
Algorithm refers to the strategy to solve a problem
It is a clear step by step sequence of instructions that
describes how to accomplish a certain task.
2 ways can be used to represent algorithm:
a) pseudocode
- using english-like-phrases to describe the
algorithm
b) flowchart
-using diagrams that employ the
symbol to describe the algorithm.
Coding
Algorithm need to be translated into computer
language so that it can be executed
Coding refers to the process of expressing
algorithm in a programming language
The product of coding is a program.
The act of carrying out the instructions contained
in a program is called program execution
 A computer program is stored internally as a
series of binary numbers known as the machine
language of the computer
Digital Information
 Computers store all information digitally:
 numbers
 text
 graphics and images
 video
 audio
 program instructions
 In some way, all information is digitized - broken
down into pieces and represented as numbers
Representing Text Digitally
 For example, every character is stored as a
number, including spaces, digits, and punctuation
 Corresponding upper and lower case letters are
separate characters
H i , H e a t h e r .
72 105 44 32 72 101 97 116 104 101 114 46
p. 4.15 Fig. 4-16 Next
The ASCII data set  128 characters (0 until 127)
Character A in ASCII  01000001
American Standard Code for Computer
InterChange (ASCII)
Binary Numbers
 Once information is digitized, it is represented
and stored in memory using the binary number
system
 A single binary digit (0 or 1) is called a bit
 A byte consists of 8 bits.
 Each byte in main memory resides at a
numbered location called its address.
Memory
24
Main memory is divided
into many memory
locations (or cells)
9278
9279
9280
9281
9282
9283
9284
9285
9286
Each memory cell has a
numeric address, which
uniquely identifies it
Storing Information
25
9278
9279
9280
9281
9282
9283
9284
9285
9286
Large values are
stored in consecutive
memory locations
10011010
Each memory cell stores a
set number of bits (usually
8 bits, or one byte)
Main Memory
Storage Capacity
 Every memory device has a storage capacity,
indicating the number of bytes it can hold
 Capacities are expressed in various units:
27
KB 2
10
= 1024
MB 2
20
(over 1 million)
GB 2
30
(over 1 billion)
TB 2
40
(over 1 trillion)
Unit Symbol Number of Bytes
kilobyte
megabyte
gigabyte
terabyte
Language Levels
 Levels of programming language levels:
 machine language
 assembly language
 high-level language
 Each type of CPU has its own specific
machine language
 The other levels were created to make it easier
for a human being to read and write programs
28
Programming Languages
Machine language
101101100110 011011010
Assembly language
iload intRate
bipush 100
if_icmpgt intError
High-level language
if (intRate > 100) . . .
Programming Languages
 Each type of CPU executes instructions only in a
particular machine language
 A program must be translated into machine
language before it can be executed
 A compiler is a software tool which translates from
high level language into a specific machine
language
 An assembler translates from assembly language
into a specific machine language
30
Language Description Examples Translator
Machine Instruction in 0
and 1 bits
0111000011000
001
None
Assembly Instruction in
mnemonic code
LOAD 3
STOR 4
ADD
assembler
High-level Similar to human
language,
FORTRAN,
COBOL, Pascal,
C, C++, Java…
sum = 4 + 3; Compiler &
interpreter
Programming Languages
The Java Programming Language
 Created by Sun Microsystems, Inc.
introduced in 1995 and it's popularity has
grown quickly since
Rich library
Platform-independent ("write once, run
anywhere") or architecture-neutral
Java Translation
 The Java compiler translates Java source code
into a special representation called bytecode
 Java bytecode is not the machine language for any
traditional CPU
 Another Java software tool, called an interpreter
(or Java Virtual Machine (JVM)) , translates
bytecode into machine language and executes it
33
Java Translation
34
Java source
code (program)
Machine
code
Java
bytecode
Bytecode
interpreter
Java
compiler
Portability
 After compiling a Java program into byte-code, that
byte-code can be used on any computer with a byte-
code interpreter and without a need to recompile.
 Byte-code can be sent over the Internet and used
anywhere in the world.
 This makes Java suitable for Internet applications.
Becoming Familiar with your
Computer to use Java
 Understand files and folders/directories
 Locate the Java compiler/ Install J2SE
 Set path & Java class path
 Write a simple program (later)
 Save your work
 Compile & run
 Use Dos Command Prompt or IDE
A DOS Command Window
An Integrated Development
Environment
File Hello.java
1 public class Hello
2 {
3 public static void main(String[] args)
4 {
5 // display a greeting in the console window
6 System.out.println("Hello, World!");
7 }
8 }
Java Program Elements
 A Java program is made up of class definitions.
 A class definition must contains a header and a
body.
 A class contains zero or more methods
 A method is a named section of code that also has
a header & body
 A method contains program statements
 Single-line (starts with //) and multi-line (enclosed
by /* and */) comments are used to document the
code
Java Program Structure
41
public class Hello
{
}
// comments about the class
class header
class body
//Comments can be placed almost anywhere
Java Program Structure
42
public class MyProgram
{
}
// comments about the class
public static void main (String[] args)
{
}
// comments about the method
method header
method body
Compiling and Running
Type program into text editor
Save (file name must be similar to class name)
Open Dos Window
Change directory to saved file directory
Compile into byte codes
javac Hello.java
Execute byte codes
java Hello
Hello.java
javac
Hello.class
java
Class Loader
Processing a Java Program
Class Loader
 A Java program typically consists of several pieces
called classes.
 Each class may have a separate author and each is
compiled (translated into byte-code) separately.
 A class loader (called a linker in other programming
languages) automatically connects the classes
together and loads the compiled code (bytecode) into
main memory.
JVM
Create/modify source code
Source code
Compile source code
Byte code
Run byte code
Output
Syntax errors
Runtime errors or
incorrect results
Creating a Java Program…
Errors
 It is common for programmer to make mistake
in a program.
 Three kinds of errors
 Syntax errors
 Runtime errors
 Logic errors
Syntax Errors
 Grammatical mistakes in a program
 The grammatical rules for writing a program are very
strict
 The compiler catches syntax errors and prints
an error message.
 Example: using a period where a program
expects a semicolon
 System.out.print("..."),
 System.out.print("Hello);
Runtime Errors
 Errors that are detected when your program is
running, but not during compilation
 When the computer detects an error, it
terminates the program and prints an error
message.
 Example: attempting to divide by 0
Logic Errors
 Errors that are not detected during compilation or
while running, but which cause the program to
produce incorrect results
 Example: an attempt to calculate a Fahrenheit
temperature from a Celsius temperature by
multiplying by 9/5 and adding 23 instead of 32
 E.g
 System.out.print("Hell");

Mais conteúdo relacionado

Mais procurados

Generations of programming language
Generations of programming languageGenerations of programming language
Generations of programming languageJamie Hyman
 
Generations of programming language
Generations of programming languageGenerations of programming language
Generations of programming languageJamie Hyman
 
Chapter 1: Intro to Funds of Programming
Chapter 1: Intro to Funds of ProgrammingChapter 1: Intro to Funds of Programming
Chapter 1: Intro to Funds of Programmingricsanmae
 
Generations of programming language
Generations of programming languageGenerations of programming language
Generations of programming languageJamie Hyman
 
Generations of programming language
Generations of programming languageGenerations of programming language
Generations of programming languageJamie Hyman
 
Introduction to Computer System
Introduction to Computer System Introduction to Computer System
Introduction to Computer System sonykhan3
 
computer language with full detail
computer language with full detail computer language with full detail
computer language with full detail sonykhan3
 
Input output devices
Input output devicesInput output devices
Input output devicessonykhan3
 
C++ Training - Lecture 01
C++ Training - Lecture 01C++ Training - Lecture 01
C++ Training - Lecture 01Babak Farhang
 
Lecture 3 - Processors, Memory and I/O devices
Lecture 3 - Processors, Memory and I/O devicesLecture 3 - Processors, Memory and I/O devices
Lecture 3 - Processors, Memory and I/O devicesMd. Imran Hossain Showrov
 
Introduction to computer programming
Introduction to computer programmingIntroduction to computer programming
Introduction to computer programmingNSU-Biliran Campus
 
My cool new Slideshow!
My cool new Slideshow!My cool new Slideshow!
My cool new Slideshow!manishamorya
 

Mais procurados (20)

Generations of programming language
Generations of programming languageGenerations of programming language
Generations of programming language
 
Generations of programming language
Generations of programming languageGenerations of programming language
Generations of programming language
 
Lecture 2 - Introductory Concepts
Lecture 2 - Introductory ConceptsLecture 2 - Introductory Concepts
Lecture 2 - Introductory Concepts
 
Chapter 1: Intro to Funds of Programming
Chapter 1: Intro to Funds of ProgrammingChapter 1: Intro to Funds of Programming
Chapter 1: Intro to Funds of Programming
 
Software Concepts Notes
Software Concepts NotesSoftware Concepts Notes
Software Concepts Notes
 
Generations of programming language
Generations of programming languageGenerations of programming language
Generations of programming language
 
Generations of programming language
Generations of programming languageGenerations of programming language
Generations of programming language
 
Introduction to Computer System
Introduction to Computer System Introduction to Computer System
Introduction to Computer System
 
Savitch ch 01
Savitch ch 01Savitch ch 01
Savitch ch 01
 
Savitch Ch 01
Savitch Ch 01Savitch Ch 01
Savitch Ch 01
 
computer language with full detail
computer language with full detail computer language with full detail
computer language with full detail
 
Input output devices
Input output devicesInput output devices
Input output devices
 
C++ Training - Lecture 01
C++ Training - Lecture 01C++ Training - Lecture 01
C++ Training - Lecture 01
 
Perfect Papers Software
Perfect Papers   SoftwarePerfect Papers   Software
Perfect Papers Software
 
Lecture 3 - Processors, Memory and I/O devices
Lecture 3 - Processors, Memory and I/O devicesLecture 3 - Processors, Memory and I/O devices
Lecture 3 - Processors, Memory and I/O devices
 
Software
SoftwareSoftware
Software
 
Computer Systems Hardware
Computer Systems   HardwareComputer Systems   Hardware
Computer Systems Hardware
 
Introduction to computer programming
Introduction to computer programmingIntroduction to computer programming
Introduction to computer programming
 
Enee114 01
Enee114 01Enee114 01
Enee114 01
 
My cool new Slideshow!
My cool new Slideshow!My cool new Slideshow!
My cool new Slideshow!
 

Destaque

Destaque (15)

LA5_PL Approach
LA5_PL ApproachLA5_PL Approach
LA5_PL Approach
 
Ch4
Ch4Ch4
Ch4
 
Study buddyresearchresources
Study buddyresearchresourcesStudy buddyresearchresources
Study buddyresearchresources
 
Presentacion abaitua
Presentacion abaituaPresentacion abaitua
Presentacion abaitua
 
Multimedia software (squick)
Multimedia software (squick)Multimedia software (squick)
Multimedia software (squick)
 
La 5 Pl Translator
La 5   Pl TranslatorLa 5   Pl Translator
La 5 Pl Translator
 
Ch 31 Nuclear Physics and Radioactivity
Ch 31 Nuclear Physics and RadioactivityCh 31 Nuclear Physics and Radioactivity
Ch 31 Nuclear Physics and Radioactivity
 
X rays
X raysX rays
X rays
 
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java Programming
 
Physics semiconductors project
Physics semiconductors projectPhysics semiconductors project
Physics semiconductors project
 
X ray physics
X ray physicsX ray physics
X ray physics
 
Physics project class 12 EMI
Physics project class 12 EMIPhysics project class 12 EMI
Physics project class 12 EMI
 
Quiz quiz hota hai : Movie Quiz
Quiz quiz hota hai : Movie QuizQuiz quiz hota hai : Movie Quiz
Quiz quiz hota hai : Movie Quiz
 
Physics Investigatory Project Class 12
Physics Investigatory Project Class 12Physics Investigatory Project Class 12
Physics Investigatory Project Class 12
 
Magnetism
MagnetismMagnetism
Magnetism
 

Semelhante a Introduction To Computer and Java

Chapter 1.1
Chapter 1.1Chapter 1.1
Chapter 1.1sotlsoc
 
Computer and programing basics.pptx
Computer and programing basics.pptxComputer and programing basics.pptx
Computer and programing basics.pptxgaafergoda
 
Lec 01 basic concepts
Lec 01 basic conceptsLec 01 basic concepts
Lec 01 basic conceptsAbdul Khan
 
PPS UNIT 1- R18.docx
PPS UNIT 1- R18.docxPPS UNIT 1- R18.docx
PPS UNIT 1- R18.docxUzma1102
 
microprocesser-140306112352-phpapp01.pdf
microprocesser-140306112352-phpapp01.pdfmicroprocesser-140306112352-phpapp01.pdf
microprocesser-140306112352-phpapp01.pdfPriyankaRana171346
 
Essential Knowledge of Computers.pptx
Essential Knowledge of Computers.pptxEssential Knowledge of Computers.pptx
Essential Knowledge of Computers.pptxHODCSE74
 
Introduction To Programming in Matlab
Introduction To Programming in MatlabIntroduction To Programming in Matlab
Introduction To Programming in MatlabDataminingTools Inc
 
IP-CBSC_STD-11_Ch-1 COMPUTER SYSTEM.pptx
IP-CBSC_STD-11_Ch-1 COMPUTER SYSTEM.pptxIP-CBSC_STD-11_Ch-1 COMPUTER SYSTEM.pptx
IP-CBSC_STD-11_Ch-1 COMPUTER SYSTEM.pptxrinkalchawda
 
Understanding Computer Systems
Understanding Computer SystemsUnderstanding Computer Systems
Understanding Computer SystemsAr Kyu Dee
 
Introduction to Computer Programming (general background)
Introduction to Computer Programming (general background)Introduction to Computer Programming (general background)
Introduction to Computer Programming (general background)Chao-Lung Yang
 
Introduction to programming principles languages
Introduction to programming principles languagesIntroduction to programming principles languages
Introduction to programming principles languagesFrankie Jones
 
Chapter 1 Introduction to C .pptx
Chapter 1 Introduction to C .pptxChapter 1 Introduction to C .pptx
Chapter 1 Introduction to C .pptxAbdalla536859
 
Power Point Lesson 04
Power Point  Lesson 04Power Point  Lesson 04
Power Point Lesson 04Nasir Jumani
 
Unit i (part2) b.sc
Unit i (part2)   b.scUnit i (part2)   b.sc
Unit i (part2) b.scHepsijeba
 
introductiontocomputerprogramming.pptx
introductiontocomputerprogramming.pptxintroductiontocomputerprogramming.pptx
introductiontocomputerprogramming.pptxHazardRhenz1
 

Semelhante a Introduction To Computer and Java (20)

Chapter 1.1
Chapter 1.1Chapter 1.1
Chapter 1.1
 
Computer and programing basics.pptx
Computer and programing basics.pptxComputer and programing basics.pptx
Computer and programing basics.pptx
 
Lec 01 basic concepts
Lec 01 basic conceptsLec 01 basic concepts
Lec 01 basic concepts
 
PPS UNIT 1- R18.docx
PPS UNIT 1- R18.docxPPS UNIT 1- R18.docx
PPS UNIT 1- R18.docx
 
microprocesser-140306112352-phpapp01.pdf
microprocesser-140306112352-phpapp01.pdfmicroprocesser-140306112352-phpapp01.pdf
microprocesser-140306112352-phpapp01.pdf
 
L2 ch1
L2  ch1L2  ch1
L2 ch1
 
Essential Knowledge of Computers.pptx
Essential Knowledge of Computers.pptxEssential Knowledge of Computers.pptx
Essential Knowledge of Computers.pptx
 
Savitch ch 01
Savitch ch 01Savitch ch 01
Savitch ch 01
 
Introduction To Programming in Matlab
Introduction To Programming in MatlabIntroduction To Programming in Matlab
Introduction To Programming in Matlab
 
Assembly Language
Assembly LanguageAssembly Language
Assembly Language
 
IP-CBSC_STD-11_Ch-1 COMPUTER SYSTEM.pptx
IP-CBSC_STD-11_Ch-1 COMPUTER SYSTEM.pptxIP-CBSC_STD-11_Ch-1 COMPUTER SYSTEM.pptx
IP-CBSC_STD-11_Ch-1 COMPUTER SYSTEM.pptx
 
Understanding Computer Systems
Understanding Computer SystemsUnderstanding Computer Systems
Understanding Computer Systems
 
Introduction to Computer Programming (general background)
Introduction to Computer Programming (general background)Introduction to Computer Programming (general background)
Introduction to Computer Programming (general background)
 
Introduction to programming principles languages
Introduction to programming principles languagesIntroduction to programming principles languages
Introduction to programming principles languages
 
Chapter 1 Introduction to C .pptx
Chapter 1 Introduction to C .pptxChapter 1 Introduction to C .pptx
Chapter 1 Introduction to C .pptx
 
Lecture1
Lecture1Lecture1
Lecture1
 
Power Point Lesson 04
Power Point  Lesson 04Power Point  Lesson 04
Power Point Lesson 04
 
Unit i (part2) b.sc
Unit i (part2)   b.scUnit i (part2)   b.sc
Unit i (part2) b.sc
 
Chap 1 c++
Chap 1 c++Chap 1 c++
Chap 1 c++
 
introductiontocomputerprogramming.pptx
introductiontocomputerprogramming.pptxintroductiontocomputerprogramming.pptx
introductiontocomputerprogramming.pptx
 

Mais de PRN USM

Graphical User Interface (GUI) - 2
Graphical User Interface (GUI) - 2Graphical User Interface (GUI) - 2
Graphical User Interface (GUI) - 2PRN USM
 
Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1PRN USM
 
File Input & Output
File Input & OutputFile Input & Output
File Input & OutputPRN USM
 
Exception Handling
Exception HandlingException Handling
Exception HandlingPRN USM
 
Inheritance & Polymorphism - 2
Inheritance & Polymorphism - 2Inheritance & Polymorphism - 2
Inheritance & Polymorphism - 2PRN USM
 
Inheritance & Polymorphism - 1
Inheritance & Polymorphism - 1Inheritance & Polymorphism - 1
Inheritance & Polymorphism - 1PRN USM
 
Class & Object - User Defined Method
Class & Object - User Defined MethodClass & Object - User Defined Method
Class & Object - User Defined MethodPRN USM
 
Class & Object - Intro
Class & Object - IntroClass & Object - Intro
Class & Object - IntroPRN USM
 
Repetition Structure
Repetition StructureRepetition Structure
Repetition StructurePRN USM
 
Selection Control Structures
Selection Control StructuresSelection Control Structures
Selection Control StructuresPRN USM
 
Numerical Data And Expression
Numerical Data And ExpressionNumerical Data And Expression
Numerical Data And ExpressionPRN USM
 
Corporate Social Responsibility And Challenges In Creating Smoke Free Environ...
Corporate Social Responsibility And Challenges In Creating Smoke Free Environ...Corporate Social Responsibility And Challenges In Creating Smoke Free Environ...
Corporate Social Responsibility And Challenges In Creating Smoke Free Environ...PRN USM
 
Empowering Women Towards Smokefree Homes
Empowering  Women  Towards  Smokefree  HomesEmpowering  Women  Towards  Smokefree  Homes
Empowering Women Towards Smokefree HomesPRN USM
 
Sfe The Singaporean Experience
Sfe The Singaporean ExperienceSfe The Singaporean Experience
Sfe The Singaporean ExperiencePRN USM
 
Corporate Social Responsibility And Challenges In Creating Smoke Free Environ...
Corporate Social Responsibility And Challenges In Creating Smoke Free Environ...Corporate Social Responsibility And Challenges In Creating Smoke Free Environ...
Corporate Social Responsibility And Challenges In Creating Smoke Free Environ...PRN USM
 
Malaysian Health Promotion Board (Mhpb) Objectives, Functions And Priorities
Malaysian Health Promotion Board (Mhpb) Objectives, Functions And PrioritiesMalaysian Health Promotion Board (Mhpb) Objectives, Functions And Priorities
Malaysian Health Promotion Board (Mhpb) Objectives, Functions And PrioritiesPRN USM
 
Role Of Ng Os In Tobacco Control
Role Of Ng Os In Tobacco ControlRole Of Ng Os In Tobacco Control
Role Of Ng Os In Tobacco ControlPRN USM
 
Application Of Grants From Mhpb
Application Of Grants From MhpbApplication Of Grants From Mhpb
Application Of Grants From MhpbPRN USM
 

Mais de PRN USM (19)

Graphical User Interface (GUI) - 2
Graphical User Interface (GUI) - 2Graphical User Interface (GUI) - 2
Graphical User Interface (GUI) - 2
 
Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1
 
File Input & Output
File Input & OutputFile Input & Output
File Input & Output
 
Exception Handling
Exception HandlingException Handling
Exception Handling
 
Inheritance & Polymorphism - 2
Inheritance & Polymorphism - 2Inheritance & Polymorphism - 2
Inheritance & Polymorphism - 2
 
Inheritance & Polymorphism - 1
Inheritance & Polymorphism - 1Inheritance & Polymorphism - 1
Inheritance & Polymorphism - 1
 
Array
ArrayArray
Array
 
Class & Object - User Defined Method
Class & Object - User Defined MethodClass & Object - User Defined Method
Class & Object - User Defined Method
 
Class & Object - Intro
Class & Object - IntroClass & Object - Intro
Class & Object - Intro
 
Repetition Structure
Repetition StructureRepetition Structure
Repetition Structure
 
Selection Control Structures
Selection Control StructuresSelection Control Structures
Selection Control Structures
 
Numerical Data And Expression
Numerical Data And ExpressionNumerical Data And Expression
Numerical Data And Expression
 
Corporate Social Responsibility And Challenges In Creating Smoke Free Environ...
Corporate Social Responsibility And Challenges In Creating Smoke Free Environ...Corporate Social Responsibility And Challenges In Creating Smoke Free Environ...
Corporate Social Responsibility And Challenges In Creating Smoke Free Environ...
 
Empowering Women Towards Smokefree Homes
Empowering  Women  Towards  Smokefree  HomesEmpowering  Women  Towards  Smokefree  Homes
Empowering Women Towards Smokefree Homes
 
Sfe The Singaporean Experience
Sfe The Singaporean ExperienceSfe The Singaporean Experience
Sfe The Singaporean Experience
 
Corporate Social Responsibility And Challenges In Creating Smoke Free Environ...
Corporate Social Responsibility And Challenges In Creating Smoke Free Environ...Corporate Social Responsibility And Challenges In Creating Smoke Free Environ...
Corporate Social Responsibility And Challenges In Creating Smoke Free Environ...
 
Malaysian Health Promotion Board (Mhpb) Objectives, Functions And Priorities
Malaysian Health Promotion Board (Mhpb) Objectives, Functions And PrioritiesMalaysian Health Promotion Board (Mhpb) Objectives, Functions And Priorities
Malaysian Health Promotion Board (Mhpb) Objectives, Functions And Priorities
 
Role Of Ng Os In Tobacco Control
Role Of Ng Os In Tobacco ControlRole Of Ng Os In Tobacco Control
Role Of Ng Os In Tobacco Control
 
Application Of Grants From Mhpb
Application Of Grants From MhpbApplication Of Grants From Mhpb
Application Of Grants From Mhpb
 

Último

microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 

Último (20)

microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 

Introduction To Computer and Java

  • 1. AN OVERVIEW OF COMPUTERS & PROGRAMMING LANGUAGES
  • 2. GOALS  To understand the activity of programming  To learn about the components of computers  To learn about level of programming languages  To become familiar with your computing environment and your compiler  To compile and run your first Java program  To recognize 3 types of errors
  • 3. What is Programming?  Computer programming  the art and science of designing and writing computer programs.  Computer program  a sequences of instructions written in a programming language to achieve a task/to solve a problem.
  • 4. What is a computer?  Hardware  the physical, tangible parts of a computer  keyboard, monitor, disks, wires, chips, etc.  Software  programs and data  a program is a series of instructions  A computer requires both hardware and software  Each is essentially useless without the other
  • 5. Computer System Organization Hardware •CPU •Main Memory (RAM) •Secondary Storage •I/O Device Software •System Programs •Application Programs Computer Organization
  • 7. Hardware Components of a Computer – motherboard processor chip adapter cards memory chips memory slots motherboard Expansion slots for adapter cards
  • 8. Hardware Components of a Computer CPU Brain of the computer, most expensive, the faster computer. CPU components– control unit, program counter, register instruction, arithmetic logic unit, accumulator. RAM Temporary memory, volatile, directly connected to the CPU, using memory cells unit.
  • 9. SECONDARY STORAGE •Provides permanent storage for information. •Examples of secondary storage: •Hard disks •Floppy disks •Zip disks •CD-ROMs •Tapes. Hardware Components of a Computer
  • 10. RAM vs Secondary Storage  Primary memory  volatile  Fast  Expensive  Low capacity  Works directly with the processor  Secondary Storage  Nonvolatile  Slow  Cheap  Large capacity  Not connected directly to the processor
  • 13. CPU and Main Memory Central Processing Unit Main Memory Chip that executes program commands Eg. Intel Pentium 4 Sun ultraSPARC III Primary storage area for programs and data that are in active use Synonymous with RAM
  • 14. Secondary Memory Devices Central Processing Unit Main Memory Floppy Disk Hard Disk Secondary memory devices provide long-term storage Information is moved between main memory and secondary memory as needed Hard disks Floppy disks USB drives Writable CDs Writable DVDs Tapes
  • 15. Input / Output Devices Central Processing Unit Main Memory Floppy Disk Hard Disk Monitor Keyboard I/O devices facilitate user interaction Monitor screen Keyboard Mouse Joystick Bar code scanner Touch screen
  • 16. Software  In contrast to hardware, software is an abstract, intangible entity.  Software can be categorized as system or application software (refer next slide)  It consists of program and data to be used to perform certain tasks  A program is a sequence of simple steps and operations, stated in a precise language that the hardware can interpret  The process of programming involve algorithm design & coding.
  • 17. Software Categories  System Software  Systems programs keep all the hardware and software running together smoothly  The most important system software is the operating system (OS)  controls all machine activities  provides the user interface to the computer  manages resources such as the CPU, memory & I/O  Windows XP, Unix, Linux, Mac OS  Application Software  generic term for any other kind of softwares  word processors, Spreadsheets, Web browsers, games
  • 18. Algorithm Algorithm refers to the strategy to solve a problem It is a clear step by step sequence of instructions that describes how to accomplish a certain task. 2 ways can be used to represent algorithm: a) pseudocode - using english-like-phrases to describe the algorithm b) flowchart -using diagrams that employ the symbol to describe the algorithm.
  • 19. Coding Algorithm need to be translated into computer language so that it can be executed Coding refers to the process of expressing algorithm in a programming language The product of coding is a program. The act of carrying out the instructions contained in a program is called program execution  A computer program is stored internally as a series of binary numbers known as the machine language of the computer
  • 20. Digital Information  Computers store all information digitally:  numbers  text  graphics and images  video  audio  program instructions  In some way, all information is digitized - broken down into pieces and represented as numbers
  • 21. Representing Text Digitally  For example, every character is stored as a number, including spaces, digits, and punctuation  Corresponding upper and lower case letters are separate characters H i , H e a t h e r . 72 105 44 32 72 101 97 116 104 101 114 46
  • 22. p. 4.15 Fig. 4-16 Next The ASCII data set  128 characters (0 until 127) Character A in ASCII  01000001 American Standard Code for Computer InterChange (ASCII)
  • 23. Binary Numbers  Once information is digitized, it is represented and stored in memory using the binary number system  A single binary digit (0 or 1) is called a bit  A byte consists of 8 bits.  Each byte in main memory resides at a numbered location called its address.
  • 24. Memory 24 Main memory is divided into many memory locations (or cells) 9278 9279 9280 9281 9282 9283 9284 9285 9286 Each memory cell has a numeric address, which uniquely identifies it
  • 25. Storing Information 25 9278 9279 9280 9281 9282 9283 9284 9285 9286 Large values are stored in consecutive memory locations 10011010 Each memory cell stores a set number of bits (usually 8 bits, or one byte)
  • 27. Storage Capacity  Every memory device has a storage capacity, indicating the number of bytes it can hold  Capacities are expressed in various units: 27 KB 2 10 = 1024 MB 2 20 (over 1 million) GB 2 30 (over 1 billion) TB 2 40 (over 1 trillion) Unit Symbol Number of Bytes kilobyte megabyte gigabyte terabyte
  • 28. Language Levels  Levels of programming language levels:  machine language  assembly language  high-level language  Each type of CPU has its own specific machine language  The other levels were created to make it easier for a human being to read and write programs 28
  • 29. Programming Languages Machine language 101101100110 011011010 Assembly language iload intRate bipush 100 if_icmpgt intError High-level language if (intRate > 100) . . .
  • 30. Programming Languages  Each type of CPU executes instructions only in a particular machine language  A program must be translated into machine language before it can be executed  A compiler is a software tool which translates from high level language into a specific machine language  An assembler translates from assembly language into a specific machine language 30
  • 31. Language Description Examples Translator Machine Instruction in 0 and 1 bits 0111000011000 001 None Assembly Instruction in mnemonic code LOAD 3 STOR 4 ADD assembler High-level Similar to human language, FORTRAN, COBOL, Pascal, C, C++, Java… sum = 4 + 3; Compiler & interpreter Programming Languages
  • 32. The Java Programming Language  Created by Sun Microsystems, Inc. introduced in 1995 and it's popularity has grown quickly since Rich library Platform-independent ("write once, run anywhere") or architecture-neutral
  • 33. Java Translation  The Java compiler translates Java source code into a special representation called bytecode  Java bytecode is not the machine language for any traditional CPU  Another Java software tool, called an interpreter (or Java Virtual Machine (JVM)) , translates bytecode into machine language and executes it 33
  • 34. Java Translation 34 Java source code (program) Machine code Java bytecode Bytecode interpreter Java compiler
  • 35. Portability  After compiling a Java program into byte-code, that byte-code can be used on any computer with a byte- code interpreter and without a need to recompile.  Byte-code can be sent over the Internet and used anywhere in the world.  This makes Java suitable for Internet applications.
  • 36. Becoming Familiar with your Computer to use Java  Understand files and folders/directories  Locate the Java compiler/ Install J2SE  Set path & Java class path  Write a simple program (later)  Save your work  Compile & run  Use Dos Command Prompt or IDE
  • 37. A DOS Command Window
  • 39. File Hello.java 1 public class Hello 2 { 3 public static void main(String[] args) 4 { 5 // display a greeting in the console window 6 System.out.println("Hello, World!"); 7 } 8 }
  • 40. Java Program Elements  A Java program is made up of class definitions.  A class definition must contains a header and a body.  A class contains zero or more methods  A method is a named section of code that also has a header & body  A method contains program statements  Single-line (starts with //) and multi-line (enclosed by /* and */) comments are used to document the code
  • 41. Java Program Structure 41 public class Hello { } // comments about the class class header class body //Comments can be placed almost anywhere
  • 42. Java Program Structure 42 public class MyProgram { } // comments about the class public static void main (String[] args) { } // comments about the method method header method body
  • 43. Compiling and Running Type program into text editor Save (file name must be similar to class name) Open Dos Window Change directory to saved file directory Compile into byte codes javac Hello.java Execute byte codes java Hello
  • 45. Class Loader  A Java program typically consists of several pieces called classes.  Each class may have a separate author and each is compiled (translated into byte-code) separately.  A class loader (called a linker in other programming languages) automatically connects the classes together and loads the compiled code (bytecode) into main memory.
  • 46. JVM Create/modify source code Source code Compile source code Byte code Run byte code Output Syntax errors Runtime errors or incorrect results Creating a Java Program…
  • 47. Errors  It is common for programmer to make mistake in a program.  Three kinds of errors  Syntax errors  Runtime errors  Logic errors
  • 48. Syntax Errors  Grammatical mistakes in a program  The grammatical rules for writing a program are very strict  The compiler catches syntax errors and prints an error message.  Example: using a period where a program expects a semicolon  System.out.print("..."),  System.out.print("Hello);
  • 49. Runtime Errors  Errors that are detected when your program is running, but not during compilation  When the computer detects an error, it terminates the program and prints an error message.  Example: attempting to divide by 0
  • 50. Logic Errors  Errors that are not detected during compilation or while running, but which cause the program to produce incorrect results  Example: an attempt to calculate a Fahrenheit temperature from a Celsius temperature by multiplying by 9/5 and adding 23 instead of 32  E.g  System.out.print("Hell");