Chapter 1 Introduction to Computers, Programs, and Java
1
CS170 Introduction to Computer Science
What is a Computer?
2
Chapter 1 Introduction to Computers, Programs, and Java CS170 - - PDF document
Chapter 1 Introduction to Computers, Programs, and Java CS170 Introduction to Computer Science 1 What is a Computer? A machine that manipulates data according to a list of instructions Consists of hardware and software Many
1
2
4
5
6
7
8
9
11
Windows (XP, Vista), Unix,
12
13
14
Why don’t we use those languages?
15
Need to convert assembly code to machine code
16
17
18
COBOL (COmmon Business Oriented Language) FORTRAN (FORmula TRANslation) BASIC (Beginner All-purpose Symbolic Instructional Code) Pascal (named for Blaise Pascal) Ada (named for Ada Lovelace) C (whose developer designed B first) Visual Basic (Basic-like visual language developed by Microsoft) Delphi (Pascal-like visual language developed by Borland) C++ (an object-oriented language, based on C) C# (a Java-like language developed by Microsoft) Java (We will use this one!!!)
19
The first Java-enabled Web browser
20
Internet services (Java Applets, Java Web Applications) Desktop computers Hand-held devices
Langpop.com
21
Java Is Object-Oriented Java Is Distributed Java Is Robust Java Is Architecture-Neutral Java Is Portable Java Is Secure Java Is Multithreaded
22
Designed to be Object-
Object-Oriented
Java Is Object-Oriented Java Is Distributed Java Is Robust Java Is Architecture-Neutral Java Is Portable Java Is Secure Java Is Multithreaded
23
Distributed computing
Designed to make
Java Is Object-Oriented Java Is Distributed Java Is Robust Java Is Architecture-Neutral Java Is Portable Java Is Secure Java Is Multithreaded
24
Java Is Object-Oriented Java Is Distributed Java Is Robust Java Is Architecture-Neutral Java Is Portable Java Is Secure Java Is Multithreaded Compilers can detect many
A runtime exception-
25
Java Is Object-Oriented Java Is Distributed Java Is Robust Java Is Architecture-Neutral Java Is Portable Java Is Secure Java Is Multithreaded Write once, run anywhere
26
Java Is Object-Oriented Java Is Distributed Java Is Robust Java Is Architecture-Neutral Java Is Portable Java Is Secure Java Is Multithreaded Implements several security
27
Java Is Object-Oriented Java Is Distributed Java Is Robust Java Is Architecture-Neutral Java Is Portable Java Is Secure Java Is Multithreaded What is multithreading? Multithread programming is
1 ________ is the physical aspect of the computer that can be seen.
2 __________ is the brain of a computer.
3 Which of the following are input and output devices?
1 ____________ are instructions to the computer. A. Hardware B. Software C. Mouse D. Keyboards 2 Computer can execute the code in ____________. A. machine language B. assembly language C. high-level language D. none of the above
Syntax and semantics of Java language
Predefined classes for developing java programs
31
J2SE can be used to develop client-side standalone
J2EE can be used to develop server-side applications such as
J2ME can be used to develop applications for mobile devices
32
33
Source Code Create/Modify Source Code Compile Source Code i.e., javac Welcome.java Bytecode Run Byteode i.e., java Welcome Result If compilation errors If runtime errors or incorrect result public class Welcome { public static void main(String[] args) { System.out.println("Welcome to Java!"); } } … 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 Saved on the disk stored on the disk Source code (developed by the programmer) Byte code (generated by the compiler for JVM to read and interpret, not for you to understand)
Command line interface (CLI) through shell window GNOME desktop environment
vi or Vim gedit
javac included in JDK
java
36
Companion Website
38
gedit Welcome.java
javac Welcome.java
java Welcome
40
41
Enter main method
42
Execute statement
43
print a message to the console
44
45
46
47
48
49
50
public class Test { public static void main(String[] args) { System.out.println("Welcome to Java!"); } }
Class block Method block
51
52
53
54
56
57
58