0% found this document useful (0 votes)
24 views

Chapter 1 - Computer Programming

The document discusses computer programming, defining a computer, programs, and the basic building blocks of programming like input, output, math, and decision making. It then explains how to print 'Hello World' in Java and the basics of classes and methods in Java. It also covers compiling programs, defining source code and object code, and how Java both interprets and compiles code to make it portable across systems.

Uploaded by

jyt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

Chapter 1 - Computer Programming

The document discusses computer programming, defining a computer, programs, and the basic building blocks of programming like input, output, math, and decision making. It then explains how to print 'Hello World' in Java and the basics of classes and methods in Java. It also covers compiling programs, defining source code and object code, and how Java both interprets and compiles code to make it portable across systems.

Uploaded by

jyt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Chapter 1 - Computer

Programming
What is a Computer?

A programmable electronic device designed to accept data,


perform prescribed mathematical and logical operations at high
speed, and display the results of these operations.

Essentially: It is any device that stores and processes data.

The 2 Main components of a computer are

Processers - These perofrm the actual calculations

Memory - e.g. RAM which temporarily stores information

What is a Program

A sequence of instructions on how to perform a specific


computation on a computer.

The Building Blocks of Programming

Input: Get data from a connected device

Output: Display data on the screen

Math: Perform basic mathematical operations

Decision: Check for certain conditions and execute the appropriate code.

Repetition: Perform an action repeatedly, usually with some variation

‘Hello World’ in Java


This is how to print ‘Hello World’ in Java

Chapter 1 - Computer Programming 1


All Java programs are made up of:

Classes

Collection of Methods

The name of your class needs to match the name of the current file

Methods

Methods are made up of Statements

Compiling Programs
Programming languages are split into 2 groups

High Level Languages

Need to be compiled into machine language, e.g. Java

Low Level Languages

Advantages of High Level Languages

Easier to read, write and understand the code

Can run on many different computer systems

How Programs are Compiled

Method 1 - Interpreters

Reads and executes the code line by line

Methods 2 - Compilers

Reads and translates the entire code before executing the program

Chapter 1 - Computer Programming 2


Important Definitions

Source Code - The original code in the High Level Language

Object Code/Executable - The compiled code

The Issue

The Object Code is not portable, this means that it can’t run on different computing
systems without constant recompilation.

What Java Does

Java both interprets and compiles the code.

When the code is compiled, it generates a virtual machine that has functionality
available to all the different computer systems.

The compiler produces a .javac file.

This compiled code is then interpreted by the Java |Virtual Machine

The code is run.

Chapter 1 - Computer Programming 3

You might also like