You are on page 1of 6

Hi, everyone. Welcome to Computer Science 102x: Introduction to Computing with Java.

I am TC Pong, the instructor of this course.


Hi, I am Tony Fung, one of the teaching assistants of this course. Hi, I am Leo Fan, the other
teaching assistant of this course.
We will be interacting with you mostly through the assignments and the discussion forum. So it's
great to see you all. We look forward to interacting with you during the next few months.

Welcome, everyone. This is Computer Science 102x, Introduction to Computing with Java.
I am the instructor for the course. My name is TC Pong, and I am a professor from the Department
of Computer Science and Engineering at HKUST. This is one of the three courses on introduction to
computer programming offered by HKUST. This course will use Java as the programming language
while the other two courses will use Python or Visual Basic.
This course is aimed at students with no or very little programming experience. So prior
programming experience is not a prerequisite for this course. The focus of this course is not just to
teach you how to program a computer, but also how to use computer to solve problems.
In this offering, the course is divided into 2 parts.
Part 1 of the course, that is the one that you're taking now, covers some programming
fundamentals
including primitive data types, variables, operators and expressions,
basic concept of object oriented programming, control flow structures including branching
and loops, and a simple type of data structure called array.
The second part of the course will cover more advanced topics, including character string
manipulation, file I/O, event-driven programming, recursion and abstract data types. We all
know that the main use of a computer is to help us in solving problems
We use computers to solve problems because it is usually more efficient and reliable in dealing with
certain tasks. However, this is not always true, at least not yet. For example, if one try to use a
computer to understand the scenery around us, in the current state-of-the-arts, computers
performance would still be far from being able to match that of human.
Lets first take a look at the learning objectives for this course, At the end of this course, if you as a
student and me as an instructor, have done our jobs right, we should be able to take a real-life
problem and extract the relevant information necessary to solve the problem.
And To think logically to formulate solutions to well defined problems using a programming
language.
Before we move on to other learning objectives, lets take a more careful look at what we mean by
well-defined problems. In general, a well-defined problem means there is a solution exists for
the problem and the solution can be found in a finite number of steps.
For example, if you were asked to find the solution to the arithmetic expression 1 x 2 + 3,
you would know that we should first multiply 1 by 2 which gives the intermediate result of 2
and then the result of the multiplication would be added to 3 and gives 5 as the final answer.
But if I ask you for the solution of 1 + 2 x 3, I want you to pause the video briefly to think about
what would be the answer. Different people may give different answers because some may think
that multiplication should be performed before addition, that is by first multiplying 2 and 3 which
gives 6 as the intermediate result and then add 6 to 1 and gives 7 as the final answer, but some may

just follow the order of operators in the arithmetic expression, in this case, first adding 1 and 2 and
gives 3 as the intermediate result and then multiplying 3 by 3 and produce 9 as the final result. So
which of the two is the correct answer?
Well, it depends on what rules are to be used in determining the order of operations. We will come
back to this issue later in this course. From this simple example, you can see that some pertinent or
additional information may be needed in solving this problem. Now, I want you to think about
whether the problem of finding the best way to travel from Hong Kong to London is a well defined
problem. I'll come back to this problem later in the lecture.
Let's now go back to other learning objectives.
The course would teach you how to implement solutions to problems using Java in an integrated
development environment (or IDE). Java is one of the most popular computer programming
languages in used nowadays. We will be learning a lot more about Java in the coming weeks.
The IDE that we are going to use in this course would be mainly BlueJ but I would also introduce
another IDE called Eclipse towards the end of this course.
There are many programming languages available, Java is just one of them. At the end of this
course, although you would have learned only one programming language, hopefully, you would be
able to pick up other programming languages by yourself after learning the programming concepts
from this course In fact, using myself as an example, when I learned my first programming
language some 30 years ago, well, I just revealed how old I am, Java didn't even exist.
I used a programming language call Fortran. But many of the programming concepts that I learned
are still applicable today. However, Java is a much better designed language than Fortran.
Java is an object-oriented language. This course would give you an understanding of the basics of
data abstraction using the object-oriented framework. I want to talk a little bit more about what is
data abstraction? Data abstraction separates what are the essential properties of data objects from
the details of how they are implemented, that is, the implementation details of data objects are
hidden from the users. In most applications, we usually care only about what the data objects can be
used for but not how they are represented.
For example, a number can be represented in many ways. In human language, the most commonly
used number system is Arabic numerals, they are listed here 0, 1, ... 9 and I'm sure that you can
recognize all of them but there are also Roman numerals, note that only three symbols, a vertical
bar, a V and a cross are used for representing the numbers from one to ten and there is no special
Roman numeral for zero, there are also Chinese numerals and many others.
And in computers, numbers are represented in 0's and 1's.
One important observation is that irrespective of how numbers are represented, we expect
operations performed on numbers will obey certain rules. For example, when you add 1 to 2, 3 is
expected as the answer irrespective of whether it is done by a Chinese, a Roman, an American or a
computer.
One can come up with other daily life examples using abstraction. For example, in driving a car,
when we step on the gas paddle, the car is supposed to accelerate and when we step on the brake,
it is supposed to slow down.
But we don't really care about the mechanics behind how they work. When you use apps on
smartphones, say an iPhone, you need to know only what the apps are supposed to do but you don't
really care how they were actually implemented.
You will find that data abstraction is a very important concept in programming, especially in an
object-oriented language such as Java.
By using this approach, even if the implementation is changed at some later time,
the behavior of the data object or program is expected to remain the same. I want also to put this
course in the context of computer science.

Computer Science is a discipline that studies the theory, design and applications of computational
systems.
This course is designed for both computer science as well as non-computer science majors (will
prepare you for the study of computer science). For those who have not decided whether CS is the
right discipline for you, this course would give you a taste of what CS is like.
Some of you may decide after taking this course that CS is not right for you, which is perfectly fine.
When we study computational systems, there are three important aspects, namely, hardware,
software and application aspects.
The study of hardware examines the design and construction of computer systems in the form of
physical devices for executing programs.
The study of software examines the behavior of algorithms or computer programs to determine
whether they are correct and efficient.
The focus of this course is on the software aspect of computer systems.
After all, the main use of computers is for solving real-world problems.
In this course, you would learn some fundamental programming concepts for solving problems
using computer programs.
I will use a lot of examples that deal with pictures and images to illustrate some of the important
programming concepts.
There is a saying that "A picture is worth a thousand words", hopefully, these examples could help
you get a better grasp of these concepts. You can apply these concepts for solving daily life
problems. So hopefully, you would learn also to be better problem solvers. I will elaborate more on
these three aspects in the rest of this lecture.

Lets now take a look at the major components of computer systems. In general, there are two major
components in a computer, namely, hardware and software components.
In 1946, the worlds first general purpose electronic computer was built at the U of Penn. It is called
ENIAC.
ENIAC stands for Electronic Numerical Integrator And Computer. As you can see in this picture,
ENIAC is a large machine that weighed over 30 tons, contained approximately 18,000 vacuum
tubes, and housed in a large room of 1,800 square feet or 180 square meters. When compare to
todays computer, you will find that the computer chip that is used in your mobile phone is many
many times more powerful than the ENIAC.
There is an important observation made by Gordon Moore, a co-founder of Intel, he predicted in
1965 that the processing power of a computer chip doubles approximately every 18 months.
This observation still holds today. This has some very important implications because a task that
requires one minute of processing time using todays machine would require over 40 years of
processing time using a computer developed 40 years ago, that is, the machine would still have not
completed the task after 40 years.
In general, a computer is an electronic device which operates under the control of instructions (or
programs) stored in its memory unit. The diagram here illustrates the data flow through different
hardware components. It would first accept data from input devices, then process data
arithmetically and logically by retrieve instructions and data from the main memory, sometimes it
will have to access more data or files from storage devices, the program would then produce results
to output devices, sometimes it may need to store the results back to storage devices for future use.
This model of computing is often referred to as stored program computer.
The main component of a computer is the central processing unit (or CPU) which is considered the
brain of a computer.
CPUs can be found in many modern devices including PCs, notebook computers, and mobile
devices such as smartphones and tablets.

The CPU retrieves instructions from the memory and performs computation on data.
It usually consists of two sub-units, namely, an arithmetic logic unit (or ALU) and a control unit.
The ALU is responsible for the computations including the basic arithmetic operations such as
addition, subtraction, multiplication and division, and logical evaluation of data including logical
comparisons such as "equal to", "larger than" or "smaller than".
The control unit controls and co-ordinates the overall operations inside a computer.
Major functions of the control unit include: Controlling access to the main memory storage.
Controlling the sequence in which instructions are executed. Regulating the timing of all operations
carried out within the CPU. Sending and receiving control signals to and from peripheral devices
such as keyboard and printer, and Controlling data flow between the ALU and Main Memory.
The memory that is located inside the CPU is known as "register. Registers are fast memory for
storing data that the processor is currently working on. All data must be stored in a register before it
can be processed. For example, in adding two numbers, both numbers must be in registers and the
result would also be placed in a register.
The main memory also known as Random Access Memory (or RAM) holds the program
instructions and the data for the program.
In modern computers, CPUs are also provided with cache memory which stores frequently used
data in order to reduce the access time to the main memory.
Input devices are responsible for obtaining information from users. The most common one is the
keyboard, which has become a standard device for most computers. In addition, there are other
input devices that help improve the user interface, for example, the mouse.
Some input devices are designed with a specific purpose in mind.
For instance, a microphone for capturing audio, a bar code reader for reading bar codes, a scanner
for scanning documents and a digital camera for taking pictures. I am sure you can think of many
more examples.
Output devices are responsible for presenting information to users.
Two main types of output devices are monitors and printers. Monitors display information on
screen.
However, information presented in such a way is volatile and non-portable.
Printers are often used to print out information on media that can be archived and transported.
There are other output devices such as speakers for outputting sound, plotters for generating
graphics
and some specially designed output devices such as the Braille display which can be used as a
tactile device for the visually challenged.
Nowadays, as mobile devices gain popularity, touch screens are being used as both input and output
devices.
Again, you may want to think about more examples. In addition, there are mass storage devices
such as CD, DVD and hard disks. The capacity of a hard disk nowadays can easily hold several
hundred Gigabyte of data. Mass storage devices are non-volatile storage media, that is, they could
store data permanently even when power is turned off. In general, they are slower and less efficient
than main memory.
During the past 10 years, a new kind of storage media that is becoming very popular is USB flash
drive or memory sticks. USB drives nowadays can easily hold 10s to even over 100 Gigabyte of
data. One recent development is cloud storage which allows a large amount of data to be stored in
off-site data centers accessible through the Internet. This is all I would talk about computer
hardware in this course. If you want to learn more about computer hardware, you can watch a video
by following this link.

Computer hardware by itself would not be very useful. This is like after constructing a building for
a library, before the books are put into the bookshelves, it would not function well as a library.
One needs to provide a computer clear instructions in order for it to perform something useful.
This kind of instructions can be called software. A software is the set of instructions that are given
to a computer for performing certain tasks. In general, software used by a computer can be
classified into two main categories, namely, system software and application software. Application
software are programs that are designed to perform specific tasks and hopefully could be used
easily by users. The focus of the course is on the development of application software.
System software are programs that support the execution and development of other programs.
Some examples of system software are operating systems and translation systems
or compilers for programming languages such as Java, Python and C++.
Another type of system software is called utility programs.
Some examples of utility programs include anti-virus program and device drivers for connecting
devices to different computers.
Here is a diagram that illustrates the interface between hardware and different types of software.
In the diagram, you can see that system software can on one hand interacts with hardware
and on the other hand interacts with application software.
For example, an application software may have to issue commands to the hardware connected to a
computer through system software,
say when a program wants to print out some results on a printer.
The diagram also illustrates that there is interface between the users and application software,
these users could be application programmers who developed the programs or user of the
applications.
There is also direct interface between users and software system and they are usually called system
programmers.
Lets also take a look at what we mean by user interface.
In general, user interface is the interaction between humans and computers, it is sometimes called
human-computer interaction (or HCI).
In general, the goal of HCI design is to produce a user interface that is easy to use and learn,
in other words, we want a user friendly interface.
An important part of an OS is to provide a user interface between the OS and the user.
For example, the file system is a part of the OS.
A good interface for a file management system would allow users
to maintain and manipulate their files efficiently and effectively.
In nowadays computers, there are mainly two kinds of user interfaces,
namely command line interface and Graphical User Interface (or GUI which is usually pronounced
as G-UI).
In command line interface, one would have to enter certain keywords or commands to instruct the
OS to perform certain actions.
An example is the Command Prompt that you will find in the Microsoft Windows system.
For this kind of interface, one would have to remember the set of commands in order to interact
with the system.
For example, the command cd .. that you see here is to change the current working directory to
one level up
and dir is to list out the files in the current directory.
From this simple example, you can probably see why such systems have become so unpopular
and seldom being used except for system programmers or system managers.
Please dont worry about remembering all these commands as you wont need them for the rest of
this course.

I am sure that all of you are familiar with some kind of graphical user interface (GUI).
In G-UI, one would find on the screen graphical objects such icons, pull-down menus and windows.
The user can do point-and-click by using a pointing device such as a mouse to activate the desired
operations.
One main advantage with this kind of interface is that you dont have to memorize different
commands as in the command line interface.
Here is an example showing how one could manipulate files using drag-and-drop.
I dont think any further explanation is needed as you should all be familiar with such operations.
We have often used graphical user interface developed by others.
In this course, you will also learn to develop your own graphical user interface using event driven
programming.
An example on the kind of graphical user interfaces that you could develop using Java is shown in
the following Java applet.

You might also like