Chapter 01 - Introduction To Computer System
Chapter 01 - Introduction To Computer System
Learning Outcome
At the end of this chapter, student should be able to:
Describe the basic of computer component (A1) Differentiate type of programming languages (C1) Compile and execute the sample given. Identify type of error (P3)
What is a Computer?
A computer is a machine that performs computations, logical operations, or more generally, data manipulation according to some prescribed sequence of instructions called a computer program.
The physical components of a computer are termed hardware and the programs software.
The Hardware
The major hardware components:
The central processing unit (CPU) Primary or random access memory (RAM) Secondary or long term memory Input and output devices (I/O devices)
Primary memory is also known as random access memory (RAM) because data may be retrieved or accessed in random, rather than sequential, order.
Secondary Memory
Long term Permanent storage Secondary memory devices: hard disks tapes CDs flash memory sticks.
Secondary Memory
The programs that you use every day such as word processors, spreadsheets, and games are permanently stored on secondary storage devices. Compared to RAM, secondary memory is, in general, cheaper (per bit), slower, larger, electromechanical rather than electronic, and persistent: secondary memory devices do not lose their values when you turn off the computer.
Input/Output Devices
Standard input devices: keyboards mouses joysticks stylus pens cameras microphones Output devices: monitors printers speakers
Special-Purpose Computers
Is a computer designed for a particular function, executing the same stored set of instructions whenever requested. For example
microwave ovens washing machine medical diagnostic equipment
General-Purpose Computers
Is a computer that can be used for solving many different types of problems. Available in many sizes and a wide range of capabilities. Can be classified as follows:
1. Microcomputers a. Laptop computers b. Desktop computers c. Workstations 2. Minicomputers 3. Mainframe computers 4. Supercomputers
Microcomputers
Sometimes referred to as a personal computer (PC), is one that can be placed on a desktop or carried from room to room. The smallest microcomputers are known as laptop computers or notebook computers. Desktop computers are compact microcomputer systems that fit on a desk and are designed for use by individuals. A workstation is the largest type of microcomputer and is generally used in scientific and engineering applications.
Minicomputers
More powerful and more expensive than microcomputers. Are smaller and cheaper compared to mainframes. Also can be server, which is used for managing internal company networks or Web sites. Server computers are specifically optimized to support a computer network enabling users to share files, software, peripheral devices (such as printers), or other network resources.
Mainframe Computer
The largest computer, a powerhouse with massive memory and e extremely rapid processing power. It is used for very large business, scientific or military application where a computer must handle massive amounts of data or many complicated processes.
Supercomputer
Is highly sophisticated and powerful computer that is used for tasks requiring extremely rapid and complex calculations with hundreds of thousands of variable factors. Used in many areas of scientific research, weather prediction, aircraft design, nuclear weapon and so on.
Computer Software
Application Software
Refers to programs that are developed to solve some specific problems. There are two types of application software:
application program to solve special classes of problems Application programs that you can write to solve your own problems.
word processing database programs spreadsheets graphic programs
System Software
Refers to programs that make the computer usable and accessible to the developers and programmers of applications software. Examples of system software:
Operating systems Language translator Linker Loader Preprocessors
Programming Languages
Programming Language is an agreed upon format of symbols that allow a programmer to instruct a computer to perform certain predefined tasks. Provide features to support the data processing activities, which include declaring variables, evaluating numeric expressions, assigning values to variables, reading and writing data to devices, looping and making decisions.
a. Machine Languages
Is the natural language of a computer. Does not need to translate and is ready for immediate execution. Machine language instruction is a binary string of 0s and 1s.
010 1 1000 0001 0000 1100 0000 0001 0000
Are machine-dependent - each computer type has its own machine language. Programs written in machine languages are not portable because programs written in for one type of computer cannot be run on another type
Assembly Languages
Consists of English-like abbreviations. Easier to understand.
L 1, GROSSPAY S 1, TAX ST 1, NETPAY
Program written in assembly languages cannot be directly processed by a computer. Must use language translators, called assemblers, to convert them to machine code. Disadvantages:
In general, each assembly language instruction corresponds to one machine language instruction. Therefore, the programs written in them are lengthy.
Because of variations in assembly languages, programs written using them are not portable.
High-Level languages
Instructions are quite English-like, and a single instruction can be written to correspond to many operations at the machine level. For example, the assembly language program can be written in high-level languages as follows:
Netpay = gross pay tax
Are easier to learn than machine or assembly languages. Have to be converted to machine languages before they can be executed using compilers, system software that translates a source program into an almost executable object program
For example:
COBOL developed in the 1960s for business transactions. FORTRAN developed for mathematic calculations. Pascal - is a structured high-level language. C is designed to support only procedure-oriented programming. Popular language for developing system applications such as operating system and compilers. Java is an object-oriented language. C++ - is extension of C programming language that support object oriented programming and procedureoriented approach.
Programs
Computer programs, known as software, are instructions to the computer. You tell a computer what to do through programs. Without programs, a computer is an empty machine. Computers do not understand human languages, so you need to use computer languages to communicate with them. Programs are written using programming languages.
26
Compiler
Object File
Linker
Excutable File
28
29
Operating Systems
The operating system (OS) is a program that manages and controlsacomputersactivities. You are probably using Windows 98, NT, 2000, XP, or ME. Windows is currently the most popular PC operating system. Application programs such as an Internet browser and a word processor cannot run without an operating system.
User
Application Programs
Operating System
Hardware
30
Why Java?
The answer is that Java enables users to deploy applications on the Internet for servers, desktop computers, and small hand-held devices. The future of computing will be profoundly influenced by the Internet, and Java promises to remain a big part of that future.
Java Java
ExamplesofJavasVersatility
Standalone Applet:
Application: TicTacToe
Servlets: Mobile
32
33
JavasHistory
James Gosling and Sun Microsystems Originally called Oak Java, May 20, 1995, Sun World HotJava
The first Java-enabled Web browser
http://java.sun.com/features/1998/05/birthday.h tml
34
JDK Versions
JDK 1.02 (1995) JDK 1.1 (1996) major changes Java 2 SDK v 1.2 (a.k.a JDK 1.2, 1998) Java 2 SDK v 1.3 (a.k.a JDK 1.3, 2000) Java 2 SDK v 1.4 (a.k.a JDK 1.4, 2002) Java 2 SDK v 1.5 (a.k.a JDK 1.5, 2004)
36
JDK Editions
Java Development Toolkit (JDK) consists of a set of separate programs for developing and testing Java programs.
39
package chapter1; public class Welcome { public static void main(String[] args) { System.out.println("Welcome to Java!"); } }
Source Code
Byte code (generated by the compiler for JVM to read and interpret, not for you to understand)
Method Welcome() 0 aload_0 Method void main(java.lang.String[]) 0 getstatic #2 3 ldc #3 <String "Welcome to Java!"> 5 invokevirtual #4 8 return
Bytecode
Result
40
If runtime errors or incorrect result
Comments
In Java, comments are preceded by two slashes (//) in a line, or enclosed between /* and */ in one or multiple lines. When the compiler sees //, it ignores all text after // in the same line. When it sees /*, it scans for the next */ and ignores any text between /* and */.
42
Package
The second line in the program (package chapter1;) specifies a package name, chapter1, for the class Welcome. Forte compiles the source code in Welcome.java, generates Welcome.class, and stores Welcome.class in the chapter1 folder.
43
Reserved Words
Reserved words or keywords are words that have a specific meaning to the compiler and cannot be used for other purposes in the program. For example, when the compiler sees the word class, it understands that the word after class is the name for the class. Other reserved words in Example 1.1 are public, static, and void. Their use will be introduced later in the book.
44
Modifiers
Java uses certain reserved words called modifiers that specify the properties of the data, methods, and classes and how they can be used. Examples of modifiers are public and static. Other modifiers are private, final, abstract, and protected. A public datum, method, or class can be accessed by other programs. A private datum or method cannot be accessed by other programs. Modifiers are discussed in Chapter 6, ObjectsandClasses.
45
Statements
A statement represents an action or a sequence of actions. The statement System.out.println("Welcome to Java!") in the program in Example 1.1 is a statement to display the greeting "Welcome to Java!" Every statement in Java ends with a semicolon (;).
46
Blocks
A pair of braces in a program forms a block that groups components of a program.
public class Test { public static void main(String[] args) { System.out.println("Welcome to Java!"); } }
47
Classes
The class is the essential Java construct. A class is a template or blueprint for objects. To program in Java, you must understand classes and be able to write and use them. The mystery of the class will continue to be unveiled throughout this book. For now, though, understand that a program is defined by using one or more classes.
48
Methods
What is System.out.println? It is a method: a collection of statements that performs a sequence of operations to display a message on the console. It can be used even without fully understanding the details of how it works. It is used by invoking a statement with a string argument. The string argument is enclosed within parentheses. In this case, the argument is "Welcome to Java!" You can call the same println method with a different argument to print a different message.
49
main Method
The main method provides the control of program flow. The Java interpreter executes the application by invoking the main method. The main method looks like this: public static void main(String[] args) { // Statements; }
50