Free University of Bolzano/Bozen
Faculty of Computer Science - Bachelor in Applied Computer Science
Bachelor in Production Engineering
Introduction to Programming
Lectures A.A. 2005/2006
Teaching material
[M1] Lecture Notes for
Introduction to Programming. Diego Calvanese.
[M2]
Absolute Java. Walter Savitch. Addison Wesley. 2nd edition 2005.
Lectures
Summary
Week |
Topics |
Monday
8:30-10:30 (lecture) |
Wednesday
8:30-10:30 (lecture) |
Tue, 16-18,
Wed. 14-16, 18-20 (lab) |
Extra
(lecture) |
#1 Oct. 3 |
Course presentation
|
-- |
Introduction to programming
(Lec 1,2)
|
-- |
#2 Oct. 10 |
Use of objects and variables
|
Use of objects, invocation of methods
(Lec 3,4)
|
Variables, object references
(Lec 5,6)
|
Java development environment
(Exer 1)
|
Costructors, input/output
(Lec 7,8)
|
#3 Oct. 17 |
Definition of methods and classes
|
Modularization, definition of static methods
(Lec 9,10)
|
Definition of classes, instance variables
(Lec 11,12)
|
Invocation of methods
(Exer 2)
|
#4 Oct. 24 |
Design of a class
| Constructors, design of a class
(Lec 13,14)
|
-- |
Definition of classes
(Exer 3)
|
#5 Oct. 31 |
Primitive data types
|
-- |
Primitive numeric data types
(Lec 15,16)
|
Realization of classes
(Exer 4)
|
#6 Nov. 7 |
Conditional statements
|
Primitive types for characters, booleans
(Lec 17,18)
|
if-else statement
(Lec 19,20)
|
Primitive types
(Exer 5)
|
#7 Nov. 14 |
Loop statements
|
Complex conditions, comparing objects, switch st.
(Lec 21,22)
|
for loop, do loop
(Lec 25,26)
|
Conditional statements
(Exer 6)
|
while loop, loop schemes
(Lec 23,24)
|
#8 Nov. 21 |
Nested loops
| Nested loops
(Lec 27,28)
|
-- |
Midterm lab exam
(Midterm)
|
#9 Nov. 28 |
Arrays
| Arrays
(Lec 29,30)
|
Matrices, Exercises on arrays
(Lec 31,32)
|
Loop statements
(Exer 7)
|
#10 Dec. 5 |
Inheritance and files
| Inheritance
(Lec 33,34)
|
Files and streams
(Lec 35,36)
|
Matrices and inheritance
(Exer 8)
|
#11 Dec. 12 |
Error handling and exceptions
| Errors and exceptions
(Lec 37,38)
|
Propagation of exceptions, Recursion
(Lec 39,40)
|
Files and exception handling
(Exer 9)
|
#12 Dec. 19 |
Recursion
| Memory management, recursive methods
(Lec 41,42)
|
Multiple recursion
(Lec 43,44)
|
Recursion
(Exer 10)
|
#13 Jan. 9 |
Linked lists
| Dynamic arrays and linked lists
(Lec 45,46)
|
Dynamic arrays and linked lists
(Lec 47,48)
|
Dynamic arrays
(Exer 11)
|
#14 Jan. 16 |
Exam exercises
| Exam exercise (in class)
(Exer 12)
|
-- |
Exam exercise
(Exer 12)
|
Details
Week 1:
Course presentation (Unit 1)
Lectures 1,2 - 3/10/2005
- Topics
[M1: Unit 1]
- course presentation
- programming languages
- program = objects + operations
- features of the Java language
- What you should know after the lecture
- distinction between objects and operations
Week 2:
Use of objects and variables (Unit 2)
Lectures 3,4 - 10/10/2005
- Topics
[M1:
Unit 1,
Unit 2]
- first Java program
- writing, compiling, and executing a program
- program errors
- objects and classes in Java
- the class
String
- method invocation
- static methods
- What you should know after the lecture
- how to input, compile, and execute a simple Java program
- writing simple programs consisting only of the
main
method that manipulate String
objects
Lab exercise 1 - 11,12/10/2005
Lectures 5,6 - 12/10/2005
- Topics
[M1:
Unit 2]
- variables
- assignment
- object references and referenced objects
- What you should know after the lecture
- memory model for objects and variables
- writing simple programs consisting only of the
main
method that make use of String
variables
- illustrating with appropriate diagrams what happens in memory
during the execution of such simple programs
Lectures 7,8 - 14/10/2005
- Topics
[M1:
Unit 2]
- creation of new objects: constructors
- mutable and immutable objects in Java
- methods that have side-effect
- the class
StringBuffer
- video output and keyboard input
- What you should know after the lecture
- write simple programs constituted only by the
main
method that use variables of type
String
and StringBuffer
- illustrate by means of diagrams what happens in memory during the
execution of the above programs
Week 3:
Definition of methods and classes (Unit 3)
Lectures 9,10 - 17/10/2005
- Topics
[M1:
Unit 3]
- modularization of programs
- abstraction on operations
- definition of static methods
- parameter passing
- What you should know after the lecture
- illustrate by means of diagrams what happens in memory during the
call of a static methods and during parameter passing (activation
record)
- write simple programs consisting of static methods that use
variables of type
String
and StringBuffer
- illustrate by means of diagrams what happens in memory during the
execution of the above programs
Lab exercise 2 - 18,19/10/2005
Lectures 11,12 - 19/10/2005
- Topics
[M1:
Unit 3]
- local variables (scope and lifetime)
- abstraction on objects
- definition of a class
- access modifiers:
public
and private
- instance variables
- definition of instance methods
- What you should know after the lecture
- understand which are the scope and lifetime of a local variable
- understand a class definition: data and operation fields
Week 4:
Design of a class (Unit 3)
Lectures 13,14 - 23/10/2005
- Topics
[M1:
Unit 3]
- constructors
- design methodology for a class
- What you should know after the lecture
- how to define and use constructors of a class
- realize simple Java classes starting from their specification, and
using the proposed methodology
Lab exercise 3 - 24,25/10/2005
- Exercises on the invocation of static methods and on the definition of
classes that realize abstraction on objects
[English,
Italian]
- Solutions [English,
Italian]
Week 5:
Primitive data types (Unit 4)
Lab exercise 4 - 2/11/2005
Lectures 15,16 - 2/11/2005
- Topics
[M1:
Unit 4]
- primitive data types in Java and variables of primitive data types
- wrapper classes, boxing, unboxing
- primitive data types to represent integer numbers:
int
, byte
short
,
long
- numeric overflow
- operators
- constants and magic numbers
- primitive data types to represent real numbers:
double
, float
- input and output of numbers
- What you should know after the lecture
- the difference between variables of type reference to object and
variables of primitive data types
- how to use primitive types for integer and real numbers
- how to define constants
- how to read numbers from standard input
- how to write numbers to standard output
Week 6:
Conditional statements (Unit 5)
Lectures 17,18 - 7/11/2005
- Topics
[M1:
Unit 4]
- type conversions
- primitive data type to represent characters:
char
- Boolean algebra and Boolean expressions
- primitive data type to represent booleans:
boolean
- What you should know after the lecture
- how to use primitive types in Java
- how implicit and explicit type conversions work
Lab exercise 5 - 8,9/11/2005
Lectures 19,20 - 9/11/2005
- Topics
[M1:
Unit 5]
- conditional statement
if-else
- variant without
else
- block statement and scope of variables defined inside a block
- nested
if-else
statements
- use of complex conditions in
if-else
statements
- conditional expression
- What you should know after the lecture
- how to use the
if-else
statement and the
if
variant in simple programs
- how to use
if-else
statements with complex conditions
- Proposed exercises
Week 7:
Loop statements (Unit 6)
Lectures 21,22 - 14/11/2005
- Topics
[M1:
Unit 5]
- comparison between
String
objects
- equality of objects vs. equality of references to objects
- the
switch
statement
- What you should know after the lecture
- how to test equality of strings and objects
- how to use the
switch
statement
Lectures 23,24 - 14,15/11/2005
- Topics
[M1:
Unit 6]
- definite and indefinite loops
- the
while
statement
- loop schemes (counter, accumulator, characteristic values in a set)
- What you should know after the lecture
- how to use the
while
statement in simple programs
- how to distinguish the control part of a loop from the part
containing the specific actions
- how to implement loops of various kinds
Lab exercise 6 - 15,16/11/2005
Lectures 25,26 - 16/11/2005
- Topics
[M1:
Unit 6]
- the
for
statement
- the
do
statement
- What you should know after the lecture
- how to use the
for
and do
statements in
simple programs
- Solved exercises
Week 8:
Nested loops (Unit 6)
Lectures 27,28 - 21/11/2005
- Topics
[M1:
Unit 6]
- What you should know after the lecture
- how to use
while
, for
and
do
statements to write programs that use nested loops
- how to use the class
StringTokenizer
- Solved exercises
- Proposed exercises
Midterm lab exam - 22-23/11/2005
Week 9:
Arrays (Unit 7)
Lectures 29,30 - 28/11/2005
- Topics
[M1:
Unit 7]
- storing collections of elements in memory
- declaration and initialization of arrays
- access to the elements of an array
- classes that make use of arrays
- What you should know after the lecture
- how to use arrays in simple programs
- Solved exercises
- the class
ApartmentOwner
[Unit 7, Sections
7.19 to
7.22]
- Proposed exercises
Lab exercise 7 - 29-30/11/2005
Lectures 31,32 - 30/11/2005
- Topics
[M1:
Unit 7]
- declaration and initialization of matrices
- access to the elements of a matrix
- exercises on arrays and matrices
- What you should know after the lecture
- how to use arrays in simple programs
- how to use matrices in simple programs
Week 10:
Inheritance (Unit 8) and files (Unit 9)
Lectures 33,34 - 5/12/2005
- Topics
[M1:
Unit 8]
- inheritance
- static type-checking
- overriding and polymorphism
- the class
Object
- the concept of file
- opening and closing a file
- writing to a text file using the classes
FileWriter
and PrintWriter
- What you should know after the lecture
- understand the basic principles of inheritance
- understand the meaning of overriding
- how to override methods
- steps that are necessary to work with a file from within a Java
program
- how to write to a text file in Java programs
Lab exercise 8 - 5,6/12/2005
Lectures 35,36 - 6/12/2005
- Topics
[M1:
Unit 9]
- reading from a text file using the classes
FileReader
and BufferedReader
- input and output streams
- reading data from a formatted text file
- What you should know after the lecture
- how to read from and write to a text file in Java programs
- how to open various types of input and output streams
- how to read from an input stream and how to write to an output
stream
- how to define and use a static method for reading from a text file
an object of a class
- Proposed exercises
Week 11:
Error handling and exceptions (Unit 10)
Lectures 37,38 - 12/12/2005
- Topics
[M1:
Unit 10]
- exam exercise
- types of program errors
- detecting and correcting errors
- exceptions in Java
- declaring exceptions
- throwing exceptions (
throw
statement)
- catching exceptions (
try-catch
statement)
- the
getMessage
method
- What you should know after the lecture
- how program errors can be classified
- how one can detect and correct errors
- what exceptions are and how they are classified
- how to handle errors in Java through exceptions
- Solved exercises
- Proposed exercises
Lectures 39,40 - 14/11/2005
- Topics
[M1:
Unit 10,
Unit 11]
- propagation and handling of exceptions
- inductively defined domains (natural numbers, strings, files, ...)
- recursive functions
- recursive methods
- What you should know after the lecture
- how a chain of exception propagations can be blocked
- how we can define a domain inductively
- characterizing recursively an operation over an inductively defined
domain
- design and realize in Java simple recursive methods that operate on
natural numbers and strings
Lab exercise 9 - 14/12/2005
Week 12:
Recursion (Unit 11)
Lectures 41,42 - 19/12/2005
- Topics
[M1:
Unit 11]
- examples of recursive methods that make use of simple recursion
- activation record
- evolution of the stack of activation records during the execution
of methods at runtime:
example program
- What you should know after the lecture
- design and realize in Java simple recursive methods that operate on
natural numbers, on strings, and on files
- know about the notions of activation record and of stack of
activation records
- understand how such notions support the invocation of methods in
programs, specifically for recursive methods
- Proposed exercises
Lectures 43,44 - 21/12/2005
- Topics
[M1:
Unit 11]
- evolution of the stack of activation records during the execution
of recursive methods:
example program
- multiple recursion
- What you should know after the lecture
- design and realize in Java recursive methods that make use of
multiple recursion
- understand the possible implications of using multiple recursion
from the computational complexity point of view
- Solved exercises
- towers of Hanoi
[Unit 11, Sections
11.23 and
11.24]
- Proposed exercises
Lab exercise 10 - 21/12/2005
Week 13:
Linked lists (Unit 12)
Lectures 45,46,47,48 - 9,11/1/2006
- Topics
[M1:
Unit 12]
- use of dynamic arrays to handle collections of elements
- representation of linked lists
- operations on linked lists
- iterative implementation of operations on linked lists through
static methods
- inductive characterization of linked lists
- recursive implementation of operations on linked lists through
static methods
- What you should know after the lecture
- what the advantages and disadvantages are of using arrays to handle
collections of elements
- how to used dynamic arrays to handle collections of elements
- what the basic operations on linked lists are
- how to provide a recursive characterization of operations on linked
lists
- how to implement operations on linked lists using recursive methods
- Solved exercises
Lab exercise 11 - 11/1/2006
Week 14:
Exam exercises
Exercise 12 (in class) - 16/1/2006
- Solved exercises
- Proposed exercises
Lab exercise 12 - 18/1/2006
course home page
Last modified:
Last modified: Sun Dec 10 13:28:35 CET 2006