UNIVERSITY OF SULAIMANI

estrapadesherbetSoftware and s/w Development

Nov 18, 2013 (4 years and 1 month ago)

108 views

1


UNIVERSITY OF SULAIMANI


COLLEGE OF SCIENCE



Programming Fundamental

COURSE BOOK

FOR THE ACADEMIC

YEAR

2011
-
201
2




Contents


Course coordinator

List of lecturers of the course

Course overview

Course objectives

Course references

Syllabus

Subjects

Exa
ms





2




Programming

Fundamental
Course Book



College
:

Science

Department
:

Computer

Course
:

Programming

Fundamental


/
1
st


year students

Course coordinator
:

Dr.Sozan A. Mahmood



Sozan
-
mahmood@univsul.net


Course link in
the University




www.univsul.org


List of lecturers of this course





Name





Scientific title

E.ma
il


1
-

Ms
.

mihran






Assistant

lecturer


2
-

Mr. pshko



Assist programmer


Course overview

Getting Fluency

and
Understanding programming language is the major prerequisite to the
study o
f most of computer science. This course teaches students how to use the
java

programming language well; furthermore, teaches students to become competent in languages
that make use of the object oriented and event
-
driven programming paradigms.

The course a
lso

includes those skills and concepts that are essential to programming
practice. As a result, this area includes units on fundamental programming concepts, basic data

structures, algorithmic
and problem solving
processes, and basic security

fundamentals
in
3


programming; all in java language
. These units, however, by no means cover the full range of

programming knowledge that a computer science undergraduate must know.

Course objectives

By the end of this course, the student
can

be writing programs
in java
that take full advantage

programming features
.
More specifi
cally, after taking this course,

the
student
s can

be able to
accomplish the following:

1.

Create, compile, and run Java programs

2.

Primitive data types

3.

Java control flow

4.

Methods

5.

Arrays (for teaching J
ava in two semesters, this could be the end)

6.

Object
-
oriented programming

7.

Core Java classes (Swing, exception, internationalization, multithreading, multimedia, I/O,
networking, Java Collections Framework)

Also
the student

will be able to

a.

Develop programs
using Forte

b.

Write simple programs using primitive data types, control statements, methods, and
arrays.

c.

Create and use methods

d.

Develop a GUI interface and Java applets

e.

Write interesting projects

f.

Establish a firm foundation on Java concepts




4



Course refere
nces


References

1
-


H.M. Deitel and P.J. Deitel, “Java How to Program”, 6
th

Edition, Pearson Prentice Hall, 2005,
ISBN: 0
-
13
-
129014
-
2

2
-


Cay Horstmann, “ Big Java”, 3
rd

Edition, John Wiley and Sons, 2008, ISBN: 978
-
0
-
470
-
10554
-
2

3
. Essentials of
the Java programming Laguage. 2002 Monica Pawla

4
. Java Cookbook. 2004 Ian F. Darwin

5 Dnial Lang “introduction to java programming six edition 2007


In addition to the above text books, the students can also make use of the following references
and web li
nks:

1
-


C. Thomas Wu, “An Introduction to Object
-
Oriented Programming with Java”, 5
th

Edition,
McGraw Hill, 2009, ISBN: 0073523305

2
-


http://java.sun.com

3
-


http:/
/www.javaworld.com


4
-


http://www.freejavaguide.com


5
-


http://www.developer.com/java







5





Syllabus




1 Introduction to Computers, Programming, and Java



2 Primitive Data Types and Operations



3 Selection Statements



4 Loops



5 Methods



6 Arrays



7 Objects and Classes



8 Strings and Text I/O



9 Inheritance and Polymorphism



10 Abstract Classes and Interfaces



11 Object
-
Oriented Design



12 GUI Basics



13 Graphics



14 Event
-
Driven Programming



15 Creating User Interfaces



16 Applet
s and Multimedia



17 Exceptions and Assertions



18 Binary I/O



19 Recursion




6


Subj
ect

1
:



1 Introduction to Computers, Programming, and Java

Objective
:

To review computer basics, programs,
and operating syste
ms
.

To represent numbers in binary, decimal,

and hexadecimal
.

To understand the relationship between Java and the World Wide
Web
.

To know Java’s advantages
.

To distinguish the terms API, IDE, and JDK.

To write a simple Java program.

To create, compile
, and run Java programs.

To understand the
Java runtime environment
.

To know the basic
syntax of a Java program
.

To display output on the cons
ole and on the dialog box


Subject 2
:



Primitive Data Types and Operations

Ob
jective

To write Java programs to pe
rform simple calculations
.

To use identifiers to name variables, constants, methods, and classes .

To use variab
les to store data .

To program with assignment statements and assignment expressions.

To use constants to store permanent data .

To declare Java primitive data types: byte, short, int, long, float, double, and char .

To use Java operators to write expressi
ons

To represent a string using the String type.

To obtain input using the JOptionPane input dialog boxes .

(Optional) To obtain input from console

To become familiar with Java documentation, programming style, and naming
conventions .

To distinguish synt
ax errors, runtime errors, and logic errors .

To debug logic errors.



Subject

3
:

Selection Statements

Objective
:


To declare
Boolean

type and write Boolean expressions.

To distinguish between conditional and unconditional && and || operators.

To use Boo
lean expressions to control selection statements .

To implement selection control using if and nested if statements.

To implement selection control using switch statements.

To write expressions using the conditional operator .

To display formatted output
using the System.out.printf method and to format strings
using the String.

format method.

To know the rules governing operand evaluation order, operator precedence, and operator
associatively

.

7




Subject

4

:
Loops

Objective

To use while, do
-
while, and for loop statements to control the repetition of statements

To understand the flow of control in loop statements .

To use

Boolean expressions to control loop statements .

To write nested loops.

To know the similarities and differences of three types of loops .

To implement program control with break and continue .


Subject5

Methods


Objecti
ve

To declare methods, invoke methods, and pass arguments to a method.

To use method overloading and know ambiguous overloading .

To determine the scope of local variables .

To learn the concept of method abstraction .

To know how to use the methods in the

Math class.

To design and implement methods using stepwise refinement.

To group classes into packages.



Subject 6 Ar
rays

Objective
:

To describe why an array is necessary in programming.

To learn the steps involved in using arrays: declaring array reference variables and
creating arrays.

To initialize the values in an array.

To simplify programming using JDK 1.5 enhance
d for loop.

To copy contents from one array to another.

To develop and invoke methods with array arguments and ruturn type .

To sort an array using the selection sort algorithm.

To search elements using the linear or binary search algorithm.

To declare and

create multidimensional arrays .

To declare and create multidimensional arrays .



Subject 7 Objects and Classes

Ob
jective

8


To understand objects and classes and use classes to model objects .

To learn how to declare a class and how to create an object of a class .

To understand the roles of constructors and use constructors to create objects .

To use UML graphical nota
tions to describe classes and objects .

To distinguish between object reference variables and primitive data type variables .

To use classes in the Java library .

To declare private data fields with appropriate get and set methods to make class easy to
mai
ntain.

To develop methods with object arguments .

To understand the difference between instance and static variables and methods .

To determine the scope of variables in the context of a class .

To use the keyword this as the reference to the current objec
t that invokes the instance
method.

To store and process objects in arrays .

To apply class abstraction to develop software .

To declare inner classes



Subject 8 Strings and Text I/O

Objective

To use the String class to process fixed

strings .

To use the Character class to process a single character .

To use the StringBuilder/StringBuffer class to process flexible strings .

To know the differences between the String, StringBuilder, and StringBuffer classes .

To learn how to pass stri
ngs to the main method from the command line .

(Optional) To use the regular expressions to represent patterns for matching, replacing,
and splitting strings

To discover file properties, delete and rename files using the File class

To write data to a fil
e using the PrintWriter class.

To read data from
a file using the Scanner class
.

(Optional GUI) To add components to a frame .


Subject 9 Inheritance and Polymorphism

Objective

To develop a subclass from a superclass through inheritance .

To invoke the
superclass’s constructors and methods using the super keyword .

To override methods in the subclass .

To distinguish differences between overriding and overloading .

To explore the useful methods (equals(Object), hashCode(), toString(), finalize(), clone()
,
and getClass()) in the Object class

To comprehend polymorphism, dynamic binding, and generic programming

To describe casting and explain why explicit downcasting is necessary

To store, retrieve, and manipulates objects in an ArrayList .

To implement a

Stack class using ArrayList

To restrict access to data and methods using the protected visibility modifier.

To declare constants, unmodifiable methods, and nonextendable classes using the final
modifier To understand the effect of hiding data fields and

static methods.

9


(Optional) To initialize data using initialization blocks and to distinguish between
instance initialization and static initialization blocks.

(Optional GUI) To use inheritance in GUI programming



Subject 10 Abstract Classes and Interfaces

Objective

To design and use abstract classes .

To process a calendar using the Calendar and GregorianCalendar clas
ses.

To declare interfaces to model weak inheritance relationships.

To define a natural order using the Comparable interface.

To know the similarities and differences between an abstract class and an interface .

To declare custom interfaces .


To enable ob
jects cloneable using the Cloneable interface.

To use wrapper classes (Byte, Short, Integer, Long, Float, Double, Character, and
Boolean) to wrap primitive
data values into objects
.

To use the BigInteger and BigDecimal classes for computing very large num
bers with

arbitrary precisions

To create a generic so
rt method

To simplify programming using JDK 1.5 automatic conversion between primitive types
and wrapper class types

(Optional GU
I) To handle GUI events



Subject 11 Object
-
Oriented Design

Objective

To become familiar with the process

of program development

To the relationship types: association, aggregation, comp
osition, strong inheritanc
e, and
weak inheritance

To declare classes to represent the relation
ships among the classes

To design systems by identifying the classes and discovering the relationsh
ips among
these classes

To implement the Rational class and
process rational n
umbers using this class

To design classes that follow the
class
-
design guidelines

To model dynamic behavior using sequence diagrams

and statechart diagrams

To know the concept of framework
-
based progra
mming using Java API



Subject 12 GUI Basics

Objective

To distinguis
h simple GUI components


To describe the

Java GUI API hierarchy

10


To create user i
nterfaces using frames, panels, a
nd simple UI components

To understand the
role of layout managers

To use the FlowLayout, GridLayout, and BorderLayout managers to layout component
s
in a container

To specify colors and fonts using the Colo
r and Font clas
ses

To use
JPanel as subcontainers



Subject 13 Graphics

Objective

To understand
Java coordinate systems

To draw t
hings using the method
s in the Graphics class

To obtain a graphics context using t
he getGraphics() method

To override the paintComponent method to draw things

on a graphical context

To use a panel as
a canvas to draw things

To draw strings, lines, rect
angles, ovals, arcs, a
nd polygons

To obtain font properties using FontMetrics and know how
to center a message

To display im
age in a GUI component

To develop reusable GUI components FigurePanel, MessagePanel, StillClock, and
ImageViewe
r



Subject 14 Event
-
Driven Programming

Objective

To start with event
-
driven programming

with a simple example

To explain the concept

of

event
-
driven programming

To understand events, event sou
rces, and event classes

To declare listener classes and write th
e code to handle events

To register listener objec
ts in the source object

To understand

how an event is handled
.

To write progr
ams t
o deal with ActionEvent

To write programs to deal with MouseEvent .

To write
programs to deal with KeyEvent
.

To use the Timer class to control animations .



Subject 15 Creating User Interfaces

Objective

To create graphical user interfaces with various user
-
interface components: JButton,
JCheckBox, JRadioButton, JLabel, JTextField, JTextArea, JComboBox, JList,
JSc
rollB
ar, and JSlider

To create listeners for various t
ypes of events

11


To use borders to visually group us
er
-
interface components

To create image icons using the ImageIcon

class

To display multiple wind
ows in an application



Subject 16 Applets and Multimedia

Objective

To explain how the Web browser control
s and executes applets

To describe the init, start, stop, and
destroy metho
ds in the Applet class

To know how to embe
d applets in Web pages

To run applets from appletviewer and from Web b
rowsers

To pass string value
s to applets from HTML

To write a Java program that can run as both an app
lication and an applet

T
o get image files using the URL class and disp
lay images in the panel

To develop a reusable component Ima
geViewer to display images
.

To get audio files an
d play sound

To package and deploy Java projects using Java a
rchive files

To use Swing pluggable l
ook
-
and
-
feel



Subject 17 Exceptions and Assertions

Objective

To know what is exception and wha
t is exception handlin
g

To distinguish exception types: Error (fatal) vs. Exception (non
-
fatal), and checked v
s.
uncheck exceptions

To declare exceptio
ns in the method header

To throw exc
eptions out of a method

To write a try
-
catch block to handle exceptions

To explain how

an exception is propagated .

To rethrow exceptions in a try
-
catch block .

To use the finally clause in a try
-
catch block.

To know when to use exceptions .

To declare custom exception classes .

To apply assertions to help ensure program correctness



Subject 18 Binary I/O

Objective

To understand how I/O is processed in Java .

To distinguish between text I/O and binary I
/O .

To read and write bytes using FileInputStream and FileOutputStream.

To read and write primitive values and strings using DataInputStream/DataOutputStream
.

12


To store and restore objects using ObjectOutputStream and ObjectInputStream, and to
understand
how objects are serialized and what kind of objects can be serialized .

To use the Serializable interface to enable objects to be serializable

To know how to serialize arrays .

To use RandomAccessFile for both read and write.




Subject 19 Recursion

Objective

To know what is a recursive method and the benefits of u
sing recursive methods

To determine the base cases in
a

recursive method

To understand how recursive method calls are handle
d in a call stack

To solve problem
s using recursion

To use an overloaded helper method to de
rive a recursive method

To understand the relationship and difference between

recursion an
d iteration



A. Times

of exams

The following patterns of examinations are depended for the

Security
course
:


1.
Two
Pop quizzes of the first
and the Second
semester
(
5

marks).

The Pop quizzes are sudden short quizzes that can be taken

during any
theoreti
cal or practical lecture (without any

previous declaration).


2.
Two Final
-
term exams
(
4
5

marks).

The mid
-
term exams are usually taken by the end of the

first
and second
semester. They include:


a
.
A
10

mark
s

exam in theoretical lectures (first semester).

b
. A

15

mark
s

exam in the practical lectures (first semester).

C
.
A 10

mark
s

exam in theoretical lectures (second semester).

d
. A

15

mark
s

exam in the practical lectures second semester.



3
. The final exams
(50 marks).

13


The final exams are usually taken
by the end of the second

semester. They
include:

a.

A

50

mark exam in theoretical lectures.


B. Exam.s duration

No specific duration is determined for the Pop quizzes, it will

be determined
at their times depending on the number and

type of the questions b
ut
usually, the duration of the pop

quiz is not more than
10
minutes.

The
duration of the Mid
-
term and final exams is three hours.



C.

Answering technique by the student
:

Our advices to the students are:


1. To read and think about the questions deeply be
fore

answering.

2. If the student
doesn’t

know the correct answer of a

particular question, in
this case there is no benefit from

wasting the time and he (she) should skip
it and go to the

next, and at last when there is a space of time he (she)

could go b
ack and try to answer the skipped question.


D.

Type and samples of the exams

Questions

1.

1.

Which of the following is a valid value for a boolean variable?

1.

a.

"false"

2.

b.

false

3.

c.

10

2.

2.

Wh
ich of these is not a convention for naming variables in Java?

1.

a.

After the first word in the variable name, each successive word
begins with a capital letter.

2.

b.

The first letter of the variable name is lowercase.

3.

c.

All letters are capitalized.

14


3.

3.

Which of these data types holds numbers from 32,768 to 32,767?

1.

a.

char

2.

b.

byte

3.

c.

short

4.


Create a program that calculates how much a $14,000 investment would
be worth if it increased in value by 40% during the first year, lost
$1,500 in
value the second year, and increased 12% in the third year.

5.


Write a program that displays two numbers and uses the / and %
operators to display the result and remainder after they are divided. Use
the
\
t character escape code to separate the res
ult and remainder in your
output.


Solutions:

class Divider {


public static void main(String[] arguments) {


float number1 = 15;


float number2 = 6;


float result = number1 / number2;


float remainder = number1 % number2;



System.out.println(number1 + " divided by " + number2);


System.out.println("
\
nResult
\
tRemainder");


System.out.println(result + "
\
t" + remainder);


}

}





class Investor {


public static void main(String[] arguments) {


float total = 14000;


System.out.println("Original investment: $" + total);


// Inceases by 40 percent the first year


total = total + (total * .4F);


System.out.println("After one year: $" + total);


// Loses $1,500 the
second year


total = total
-

1500F;


System.out.println("After two years: $" + total);


// Increases by 12 percent the third year


total = total + (total * .12F);


System.out.println("After three years: $" + total);


}

}

Q3 fill the blanks

1.

The term "instance variable" is another name for ___.

2.

The term "class variable" is another name for ___.

3.

A local variable stores temporary state; it is declared inside a ___.

4.

A variable declared within the opening and closing parenth
esis of a method signature
is called a ____.

5.

What are the eight primitive data types supported by the Java programming language?

6.

Character strings are represented by the class ___.

15


7.

An ___ is a container object that holds a fixed number of values of a singl
e type.

Answer:

1
-

non
-
static field
.

2
-

static field
.

3
-

method
.

4
-

parameter
.

5
-

byte, short, int, long, float, double, boolean, char


6
-
java.lang.String
.

7
-
array






External Examiner

From now on every course should have its own external examiner
w
ith identified roles.

The one who can play the role of an external examiner should:



Have an academic post with the scientific rank of assistant
Professor and higher.



He/she should be an active, reputable and experienced academic
staff in his field or a rel
ated field to the course.



He/she should have not participated in lecturing or
administering of the course.

The roles of the external examiner are:



Evaluating the contents and the program of the course.



Prior to the exam, he/she should contribute to choosin
g the
questions and looking at the ideal answers.



Evaluating the process of the examinations: he/she should see
all the marked exam papers, then choose randomly nine marked
16


papers: three with high marks, three with medium and three with
low marks.



Evalua
ting the students' feedbacks



He/she should participate in the final meeting of the first round
examinations committee and give his assessment on the entire
course and the examination process, then to give his opinion
about the final results.



He/she should

participate in the final meeting of the second
round examinations committee and should have a main vote on
those problems that may face them.



Then the lecturer/ tutor in charge will respond to the external
examiner's questions and will reply officially

t
o all the questions

and

clarify
the reasons.


Student's feedback on the subject


Date: Course: Year: Lecturer/ tutor:

No.

Evaluation Questions

Subject's
Level

1
-
5

Subjective Remarks

1

The objectives and key messages of
the
subject were clear



2

The contents of the subject were useful and
related to the main objectives of the course



3

The materials were prepared carefully as
needed



4

The lecturer/ tutor while lecturing tried to
analyze the principles, contents and

the
important points of the subject simply and
properly.



5

The lecturer/ tutor while lecturing kept my
attention.



17


6

The lecturer/ tutor came into the classroom on
time and was committed to the duration of the
lecture.



7

The lecturer's behavior in

the classroom was
calm and respectful.



8

The slides used in the lecture were clear and
attractive.



9

At the end of the lecture, the lecturer gave the
students a chance for questions and comments.
His/ her answers were complete.



10

The reading
sources are new and compatible
with the subject.




Total of the levels








Standards to evaluate the level of the
contents

1

2

3

4

5

Very
bad

Bad

Medium

Good

Very
good