You are on page 1of 4

Introduction to Java Lesson 1: Introduction

30 January 2015
12:06

Java is an object-oriented, popular programming language. In order to learn to program with java, we
need to gain the concept of object oriented programming. There are two types of programming Sequential and Object oriented. Sequential involves designing program in steps and routines whilst in
object oriented programming, entities relating to the programs are seen as objects that interact with
one another.
Java has evolved into a force it is today. It is made up of three distinct editions:
Java Standard Edition (Java SE) - for developing standalone desktop applications.
Java Enterprise Edition (Java EE) - for developing web and network related applications.
Java Micro Edition (Java EE) - for developing mobile application for memory constrained devices
such as BlackBerry phones.
In this tutorial, we will be focusing on the fundamentals of Java SE.
Programming and computers have become very useful in today's world. Programming and computers
can be found in the internet, medical research, automation, communication and so on.

Computers
Programming is the art and science of developing programs that are used to tell computers what to
do at a moment in time. Programs are responsible for controlling computers. If you gain absolute
control of a computer, you have to learn to program.
Computers perform operations and make decisions a lot faster than human beings do. Most
computers perform billions of calculations per seconds. Supercomputers perform higher. Operations
are controlled by programs written by individuals called programmers.
Computers are made up of logical units. They are: input unit, output unit, memory unit, arithmetic
logic unit, central processing unit and secondary storage unit. All these parts work together in order
to fully perform operations.
The cost of obtaining powerful computers have been reducing from year to year due to Moore's law.
As a result of this, the power of computers can be leveraged by simple individuals to perform great
things. All we need to do is learn to program.

Data Hierarchy
Computers perform operations on data. There are different levels of data. They are:
1. Bits - Single digit representing two contradictory values - ON (1) and OFF (0); TRUE (1) and
FALSE(0); HOT (1) and COLD (0)
2. Characters - These are values representing letters, numbers, symbols and other controls. They
are stored with 8 bits. For instance, the character 'A' has the value of 01000001 which is the
same as 65 (to decimal).
3. Fields - These are composed of one or more characters. The string "Emmanuel" can be
considered as a field.
4. Records - Records can be seen as entities that contain field. For example - our name can be seen
as a record because it contains three fields: first name, middle name and last name. Records can
also contain records.
5. File - A file is a group of records that is stored separately.

Tutorials by Oyudo Gerald (+2348078229930; gerald_oyudo@hotmail.com)

Computer Language
Programs are written in a specific language. There are levels of language that can be understood by
the computer. Machine languages are peculiar to a computer and can be understood by that computer
directly. Machine languages are represented by fields of 1's and 0's that prove cumbersome for
humans to understand. Instead of using these troublesome strings to send command to the computer,
we developed a way to use English-like codes to talk to the computer and have an intermediary
program "translate" them. These languages are called assembly languages, and the translators
themselves called assemblers.
Over the years, high-level languages were developed in which single statements could be written to
perform multiple tasks. This greatly reduced development time and resources. Their translators
became more complex and took more time to run. Some translators translate the whole program at
once before executing- called compilers; while some others translate programs line by line - called
interpreters. Java is a high level language that uses a mixture of compilers and interpreters to translate
programs.

Introduction to Object Technology


This is the concept in which everything in this world is perceived as an object. In reality, everything is
an object. In a football match, the goal post, field, football and the football players are seen as objects.
Objects that have the same attribute and perform the same functions belong to the same class of
objects. The 22 players playing on the field belong to a class of football players- the football player
class.
A class specifies attributes and functions. Attributes define what the class possesses while functions
(or methods) specifies what the class does. For instance, the football player class can have attributes
as follows:
Shot power
Dribbling skill
Heading power
Keeping skill
Finishing ability
The Football Player class can also have the following methods:
Run
Pass
Shoot
Dive
A combination of what football players have and can do defines its class. Each football player is distinct
from another and is referred to an object. All 22 players possess all these attributes and functions, so
belong to the same class. Although, one footballer can be better than another in shot power, dribbling
skill or finishing ability (i.e. their values). Objects have state which is represented by the values of each
attributes. No two objects can be the same but they can have the same values. For instance, Messi
may play as good as Ronaldo, but they are not the same football player.
Classes and Objects
From the illustration above, a class can be seen as an abstract representation of an object. It is the
blueprint or design of the object. Objects are created using these blueprints by a process known as
instantiation. Objects are instantiated from classes.
Just as a footballer can play for his club and for his country and can be transferred to another club,
classes and objects can be created once, and reused in different aspect of programs. Objects perform
functions through method calls - requesting that an object perform a function. For instance a
Tutorials by Oyudo Gerald (+2348078229930; gerald_oyudo@hotmail.com)

footballer object can kick a ball. Any instruction given to a football player, whether to kick, dribble or
dive are represented by method calls.
Attributes and Instance Variables
Every object has attributes that give value and state to the object. These attributes can be referred to
as capabilities. Attributes are represented by the properties of the class - its instance variables. Shot
power, dribbling skill and Heading power are instance variables of the class Football Player. An object
of Football Player, Messi, has attributes such as shot power, dribbling skill and heading power.
Methods
Methods specify what objects can do. Users of the objects call specific methods to instruct objects to
perform certain tasks. Methods can have input values and can return a result. Methods are created
by defining them in the class.
Properties of Object Oriented Analysis and Design (OOAD)
In order to develop complex program, we need to take time designing them. Since java uses an object
oriented language, design of java programs have to be object oriented.
There are four properties of object oriented design:
Encapsulation
Abstraction
Inheritance
Polymorphism
Encapsulation
When a footballer kicks the ball, the only effect seen is the ball moving away from the player. The
muscle action and other biological reactions involved in kicking the ball is not visible to other people.
For object oriented programming, encapsulation involves preventing users of the classes and object
from knowing how methods are performed. Clients of classes and objects simply call methods without
bothering themselves about how these methods were implemented. This little piece of detail is only
meant for the programmer.
Abstraction
This can be seen in two ways. In both ways, abstraction still means showing only things that matter.
In classification, abstraction can be seen as grouping objects in relation to only fields that matter. For
instance, a bat and an aeroplane may be put into the same group because they can both fly - neglecting
other differences. Here, grouping is done looking at similarities instead of differences.
In the same vein, when applied to object and classes, abstraction involves letting users of classes and
object access only what they need to access and nothing more. For instance, coaches need access to
tell players to run or dribble but they do not have any business with telling players when to breathe
or not. Some methods and attributes are made available externally, keeping the others private. This
is called abstraction, a complement to encapsulation. Abstraction and encapsulation go hand in hand.
Inheritance
Football players are a special kind of human beings that know how to play football. Hence, they inherit
attributes (hand, leg, head, toes, mouth etc.) and methods (breathe, walk, talk) from the human
beings class. This kind of relationship is known as inheritance.
Classes (sub-classes) can inherit from other classes (super-classes). Objects created from sub-classes
are a kinds of the super class. For example, Messi (an object of football player) is a kind of human
being.
Tutorials by Oyudo Gerald (+2348078229930; gerald_oyudo@hotmail.com)

Inheritance makes it easy for codes to be reused with only little modification made to make new
objects.
Polymorphism
This is a feature of objects that makes is possible to perform the same task in different ways.
Polymorphism makes it possible for the same method to be used in different ways. This would be
discussed later.
UML can be used to design programs in an Object Oriented manner. It is a graphical way of
representing various aspect of software design. There are different programming languages that exist.
Some are C, C++, Pascal, Fortran, C#, Objective C, Visual Basic, python, and JavaScript. There are so
many others.

Tutorials by Oyudo Gerald (+2348078229930; gerald_oyudo@hotmail.com)

You might also like