Professional Documents
Culture Documents
Chapter 1
Introduction
Chapter Goals
To understand the activity of programming
To learn about the architecture of computers
To learn about machine code and high level programming languages
To become familiar with your computing environment and your compiler
To compile and run your first Java program
To recognize syntax and logic errors
Prerequisites
What is a computer?
Central processing unit
Memory
Peripherals
Executes very simple instructions
Executes instructions very rapidly
General purpose device
Programs describe specific actions
Programming Languages
Machine/Virtual Machine
21 40 16 100 163 240
Assembler
iload intRate
bipush 100
if_icmpgt
intError
High-level language
if (intRate > 100)
. . .
file:///C:/Users/kfh/Documents/Raj Study Material/A Level/Computer Science/Computing Concepts with Java Essentials, 3rd Edition/Ch01/ch01.html 2/6
9/22/22, 12:16 PM Horstmann Chapter 1
A Shell Window
File Hello.java
1 public class Hello
2{
4 {
5 // display a greeting
in the console window
6 System.out.println("Hello,
World!");
7 }
8}
A simple program
public class ClassName
public static void main(String[] args)
// comment
Method call
object.methodName(parameters)
System class
System.out object
println method
object.methodName(parameters)
Example:
file:///C:/Users/kfh/Documents/Raj Study Material/A Level/Computer Science/Computing Concepts with Java Essentials, 3rd Edition/Ch01/ch01.html 4/6
9/22/22, 12:16 PM Horstmann Chapter 1
System.out.println("Hello, Dave!");
Purpose:
To invoke a method of an object and supply any additional
parameters
Errors
Syntax errors
System.ouch.print("...");
System.out.print("Hello);
System.out.print("Hell");
Detected (hopefully) through testing
file:///C:/Users/kfh/Documents/Raj Study Material/A Level/Computer Science/Computing Concepts with Java Essentials, 3rd Edition/Ch01/ch01.html 5/6
9/22/22, 12:16 PM Horstmann Chapter 1
file:///C:/Users/kfh/Documents/Raj Study Material/A Level/Computer Science/Computing Concepts with Java Essentials, 3rd Edition/Ch01/ch01.html 6/6