Java Lesson 1
Java Lesson 1
Department of Education
OBJECTIVES
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
2
4. What are words that have a special meaning in a programming language
which are used for their intended purpose only and usually called reserved
words?
_________________________________________________________________________________
5. What reads the entire program and translates it completely before the
program starts running?
_________________________________________________________________________________
WHAT IS A PROGRAM?
1. Display a message on the monitor: “How many hours did you work?”
2. The user enters the number of hours worked.
3. When the user enters the number, store it in memory.
4. Display a message on the monitor: “How much do you get paid per hour?”
5. The user enters an hourly rate.
6. When the user enters the number, store it in memory.
7. When the number of hours worked and the hourly rate are entered,
multiply the two numbers, and store the result in memory.
8. Display a message on the monitor that shows the amount of earnings
which is the result of the calculation of employee’s salary.
Central Processing Unit (CPU) can only process instructions that are written in
machine language. A machine language program is a stream of binary
numbers consisting of 1s and 0s. Binary numbers form low-level instructions
also called machine language instructions, which the CPU interprets as
commands.
3
Programming languages use words instead of numbers to ease the task of
programming. A program can be written in a programming language which is
much easier to understand than machine language, and then translated into
machine language.
4
Python is an object-oriented programming language that is used in both
business and academia. Many popular web sites have features that are
developed in Python.
Syntax are rules that must be followed when writing a program. Syntax
dictates how keywords and operators may be used, and where punctuation
symbols must appear.
5
Owned by Oracle and used for desktop applications, mobile applications, web
applications, games development and more.
Java is popular because it is platform independent which means that the same
compiled program can run on any computer in the world.
Java applications are typically compiled to bytecode that can run on any Java
virtual machine (JVM) regardless of the computer architecture.
OBJECT-ORIENTED PROGRAMMING
There are primarily two methods of programming in use today: procedural and
object-oriented. The earliest programming languages were procedural,
meaning a program was made of one or more procedures. A procedure is a set
of programming statements that perform a specific task.
In a procedural program, the data items are commonly passed from one
procedure to another as shown below.
Data
Item
Procedure A Procedure B
6
If procedural programming is centered on creating procedures, object-
oriented programming is centered on creating objects. An object is a
programming entity that contains data and procedures. The data contained
within an object is known as the object’s attributes. The procedures that an
object performs are known as the object’s methods. An object in concept
consists of data (attributes) and procedures (methods).
7
The following program is called the hello world program. All it does is display
the words “Hello, World!” on the screen. In Java, it looks like this:
4. The computer reads the translated code and performs the tasks requested.
Directions: Define the following and write your answers on the space
provided.
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
8
3. What is a compiler and how does it differ from an interpreter?
_________________________________________________________________________________
_________________________________________________________________________________
4. What is an object?
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________