CSIT111 Lecture 1
CSIT111 Lecture 1
1
Reference books
Recommended Textbook
Java how to Program (Early Objects), Eleventh Edition, Paul
Deitel and Harvey Deitel, Pearson, 2018
2
Lecture Plan
3
Subject structure
• Assignments : 3 assignments
• Quizzes: at least 3
• Labs: at least 5
4
Assessment
Assessment Items % Remarks
Assignment 1 7% Sequential designs
Assignment 2 8% Classes and objects
Assignment 3 8% Arrays
Labs and Quizzes 12%
Closed book term test 15% Around 3rd last lessons
Closed book written exam 50%
6
Labs
• All labs are take home lab. You should try your best to finish
your lab in one or two days.
7
Assignments
• There will be three programming assignments
• When an assignment is released, download the
assignment description from the subject web site. Read
carefully the specifications. Make sure you understand the
requirements.
• Take home assignments for programming parts
• Your solutions must be submitted electronically via the
Moodle system. No submission via email will be
accepted
• Late assignments will not be accepted without a
granted special consideration
• Exact time after which the submitted assignment will not
be accepted by the system will be indicated in every
assignment
8
Assignments
• When you submit an assignment, you need to follow the
submission instructions for this assignment and do not
make any assumptions
• In every submitted assignment file you submit must
include the following information header :
/*------------------------------------------------------
My name:
My student number:
Tutorial group:
Declaration: Make a declaration telling me if this is
your own work
-------------------------------------------------------*/
• No header, or an empty header is considered as an anonymous
submission. Such assignments are not marked (your mark will be 0)
• Make sure the submitted files are named as required. Files
submitted with incorrect names are not recognized by the assignment
9
test system and are not marked (your mark will be 0)
Assignments FAQ
1. How to submit my assignment electronically?
- Via Moodle system
10
Assignments
All assignments must be completed individually
When you submit an assessment task, you are declaring
the following:
1. It is your own work and you have not copied anything from others
and you have not discussed your work with others
2. You have not plagiarized from published work (including various
internet sources)
3. You have read your responsibilities under the UOW’s policy on
plagiarism and you understand possible consequences
4. You have not used storage devices which can be accessed by
others without passwords
Plagiarism = Big problems
You may be asked to have a formal meeting with the
lecturer to explain your assignment solution if there are
doubts that you worked on your assignment yourself
11
Subject web site
The subject web site is the subject’s “Notice Board”
12
Self-directed Study
Listening passively is useless
• Download lecture notes from the subject web site and
look through the lecture notes prior to lectures
• Attend all lectures. Take your own notes and add your
own comments or questions during the lectures
• Read related chapters in the textbook together with
lecture notes and implement Java examples discussed at
lectures on your computer at home
• Should you have any questions, ask!!
13
Subject Materials
Lecture notes:
The lecture notes are available on the subject web site
The lecture notes may not include some examples and
explanations given in lectures
14
Introduction
to
Programming Fundamentals
15
Digital World
In modern life, we are surrounded by digital electronic
devices
Microprocessors + Programs
16
Digital World
Military robots
Home robots
1) Scanner
2) CPU (Microprocessor)
3) Memory (RAM)
4) Expansion cards
(graphics cards, etc.)
5) Power supply
6) Optical disc drive
7) Storage (Hard disk or SSD)
8) Motherboard
9) Speakers
10) Monitor
11) System software
12) Application software
13) Keyboard
14) Mouse
15) External hard disk
By User:HereToHelp, CC BY 2.5 16) Printer
20
How computers work
/**
* The HelloWorldApp class implements an
* application that displays “Hello world!"
* to the standard output.
*/
class HelloWorldApp {
public static void main(String[] args){
// Display "Hello world!"
System.out.println("Hello world!");
}
21 }
How computer programs work
x86 instructions
-----------------------
ADD add
SUB substract
MUL multiply
Central CMP compare
INC increment
Processing MOV move data
Unit …
input output
(CPU)
program in memory
Program
Task:
Code
machine
instructions
z=x+y
00FF 01101001 read CPU instructions
01101010 read
00FF:F0F0
… add
main 00FF:F0F1 11100101 write Read location x
≈ Read location y
memory Program
Data
Add
10000100 x Write to location z
≈ 01001011 y
… z
The instruction binaries are not real and for illustration only
22
Evolution of Programming Languages
Machine Symbolic High-level
24
“Hello world” programs
Assembly
msg db ‘Hello world!$' global _start …
_start: compiled 10100101
.code mov eax, 4
start: mov ebx, 1
11000100
mov ah, 09h mov ecx, str 01101011
lea dx, msg mov edx, str_len …
int 21h int 80h
mov ax, 4C00h mov eax, 1
int 21h mov ebx, 0 Machine code
end start int 80h
Low
Levels of programming languages
#include <stdio.h>
compiled
int main() {
C
printf("Hello World!");
VM VM
}
interpreted
print "Hello World!" Python
25
Programming languages
Anything that can be done using one
• Compiled languages language can be done using any language.
– Compiled to machine code Some language may be easier for certain things
26
Why Java?
• General-purpose language
– Suitable for a wide range of applications
• Supports the most advanced software development concepts
– class-based, object-oriented, concurrent
• Architecture-neutral, portable
– write once, run anywhere
• Most popular
– Java is everywhere
• 97% of enterprise desktops run Java
• 3 billion mobile phones run Java
• 100% of Blu-ray disc players ship with Java
• 5 billion smart cards run Java Card applets
• 125 million TVs run Java
• Java powers set-top boxes, printers, Web cams, games, car navigation systems, lottery
terminals, medical devices, parking payment stations, and more
– 9 million programmers/developers
– Books, tutorials, exercises, compilers, environments are just as numerous
as stars If one is a good master of one programming language,
one would have few difficulties to pick up another quickly
27
TIOBE Programming Community Index
Long term trends for top 10 programming languages
32
The subject
• Objective
– Learn the fundamental principles of programming
• Object-oriented view of problem analysis and solving
• Learning Outcomes
1. Create and manipulate data types and structures.
2. Design and implement solutions using classes; implement
the behaviour of objects in a structured way.
3. Understand and apply the syntactic and semantic rules of an
object-oriented programming language.
4. Illustrate an understanding of tools and techniques for
program testing.
5. Illustrate an understanding of the concepts involved in
compilation, linking and execution
This subject is not just about Java, but you will learn programming in Java
33
Topics covered by CSIT111
34
Topics not covered by CSIT111
35
Learning programming
• Learn by doing
• If you want to learn programming, you must “do” programming
• Spend sufficient time doing it
Text Editor
Source
A text file
Code
File
Compiler
run
Executable
File
Debugger
37
Java Programming Process
• Implement a program
Java Program
– Use any text editor to write it
HelloWorldApp.java
– Save text into a file
HelloWorldApp.java
Compiler
HelloWorldApp.class
• Compile a program: compiler
– javac HelloWorldApp.java bytecode
Java bytecode is hardware platform independent
38
Java Program Execution
• The basic structural unit of a Java program is a class
• Instances of classes placed in memory become objects
Java Class Library Verification checks if bytecode is safe
and cannot crash the computer
Bytecode Verifier
Virtual
Class A Class memory
main(..) Loader
Execution
Class B Engine
Class C 11000110101
JVM loads all application 00000110100
Java Application A components class-by-class
39
1. Write your program
/**
* The HelloWorldApp class implements an application
* that displays “Hello world!" to the standard
* output.
*/
class HelloWorldApp{
public static void main(String[] args){
// Display “Hello world!"
System.out.println(“Hello world!");
A predefined
object
}
}
class HelloWorldApp
{public static void main(String[]
args){System.out.println("Hello world!");}}
Such code can be compiled, but you will lose marks for
submitting such code of bad style resulting in poor
readability
41
2. Compile and run your program
• To compile your program you need
Java Development Kit (JDK) that includes
- javac Java compiler
- Java Virtual Machine
- Java APIs
- other components and tools
Windows
Explorer
43
Integrated Development Environment
• Although JDK provides all tools needed for
compiling, debugging, running and
documenting your program, you may find it
more convenient to use an application that
integrates all tools and provides a
convenient graphical user interface
45
Java version used for CSIT111
• CSIT111 is based on Java Standard Edition 8 (Java SE8)
- This version supports all features needed to develop desktop and
server applications.
• Java SE8 adds support of a new programming concept -
functional programming (not covered by CSIT111)
• The Java Enterprise Edition (Java EE) is focused mostly on
developing large-scale, distributed networking applications
(not covered by CSIT111)
46
First Program
/**
* The HelloWorldApp class implements an application
* that displays “Hello world!" to the standard
* output. a bug
*/ ) is missing
class HelloWorldApp{
a bug
public static void main( String[] args {
// Display “Hello world!" n is missing
System.out.printl ("Hello world!"); Compilation errors
}
}
• Everything in a Java
program must be inside a
class
• Class – a container for the
program logic that defines
the behaviour of which all
Java applications are built
47
NetBeans IDE
• Once you get familiar with the basics of Java
programming, you can try using NetBeans IDE
• Although it is an advanced development tool, it is not hard to learn
how to use its basic features
- create a Java project
- edit source code files
- compile
- debug
- test run
• It supports many other things
which you don't need at this
stage
• NetBeans IDE does not have its own Java compiler. It uses JDK that
should be installed before you install NetBeans
48
NetBeans IDE
1. Create a new project or open an existing project Select Java Application
49
NetBeans IDE
2. Specify the project name, location of its folder and tick Create Main
Class. Then press Finish.
50
NetBeans IDE
3. A template source code will be generated that you can edit
51
NetBeans IDE
4. When you finish editing, you can compile you program by pressing
Build Project button
Code Analyser
may detect some
syntax errors even
before compilation
55