Announcement
30st December, 2013
The eighth lab:
The task for eighth lab has published.
31st November, 2013
The third lab:
The task for third lab has published.
3rd October, 2013
The first lab:
The first lab will be held until next week
on 10 October 2013.
1st October, 2013
The advertising point:
Here is the place where important news on lectures and exercises
will be published.
Java is a programming language originally developed
by James Gosling at Sun Microsystems and
released in 1995.
It is an object-oriented programming language.
The language derives much of its syntax from C++ but has a simpler
object model and fewer low-level facilities.
The main goal of this course is to teach programming in Java
and introduction to basic Java technologies.
Prerequisites:
- C++ programming language;
- basic data structures (arrays, lists, trees, graphs).
Bibliography
Books:
-
Ken Arnold, James Gosling, David Holmes:
The Java Programming Language. Fourth Edition.
Prentice Hall PTR, 2005.
-
Herbert Schildt:
Java: A Beginner’s Guide. Third Edition.
McGraw-Hill, 2005.
-
Joshua Bloh:
Effective Java. Second Edition.
Sun Microsystems, 2008.
-
Pat Niemeyer, Jonathan Knudsen:
Learning Java. Third Edition.
O'Reilly Media, 2005.
-
Kathy Sierra, Bert Bates:
Head First. Java. Second Edition.
O'Reilly Media, 2005.
-
James Gosling, Bill Joy, Guy Steele, Gilad Bracha:
The Java Language Specification. Third Edition.
Prentice Hall PTR, 2005.
-
Tim Lindholm, Frank Yellin:
The Java Virtual Machine Specification. Second Edition.
Prentice Hall PTR, 1999.
Internet:
My secret library
- the password: "java"
Schedule
-
Lecture: Wednesday 10-12, room 139
-
Lab: Wednesday 12-14, room 110
Labs
Lab rules
- General:
-
At this site several simple programming tasks will be published.
For each properly programmed task the student can score up to 10 points or
up to 5 points for the task submitted within a week after the deadline.
- Deadline:
-
The deadline for each task is nearest Wednesday after its publication
(Wednesday in the next week).
Delays longer than a week are not acceptable.
The only exceptions are: illness confirmed by a doctor or official
matters confirmed by the appropirate authorities.
- Presentation of solutions:
-
Programs have to be presented during lab sessions, personally
by the author (student).
It is unacceptable to pass the solutions by colleagues.
During the presentation the author should be prepared to answer
questions about: the method, specific langauge constructions,
technologies, etc. used in the proposed solution.
- Programs:
-
Presented programs have to be sent to me immediately after the lab sessions.
I will collect your programs to the end of semester.
- Evaluation:
-
To receive the credit for this course, grade 3 (sufficient),
the student has to collect minimum 50% of all the possible points;
for grade 5 (very good) it is necessary to collect 90% of all
the possible points; the rest of the intermediate grades are linearly
dependent on the above border requirements.
Exercises
-
17 Oct, 2013:
The number to words converter (pdf)
-
24 Oct, 2013:
Polynomials (pdf)
-
7 Nov, 2013:
Expression trees (pdf)
-
14 Nov, 2013:
The Reverse Polish Notation calculator (pdf)
-
28 Nov, 2013:
The simple integer calculator (pdf)
-
5 Dec, 2013:
Colored drawings (pdf)
-
19 Dec, 2013:
The binary search tree (pdf)
-
16 Jan, 2014:
Playgrounds in a city park (pdf)
-
23 Jan, 2014:
Cleaning streams (pdf)
-
30 Jan, 2014:
Tic Tac Toe (pdf) - an additional exercise
Ranking
Lectures
Table of Contents
- 3 October, 2013 (overview of Java)
-
Recommended reading:
-
The Java Programming Language (Arnold, Gosling, Holmes):
Chapter 1 - A Quick Tour.
-
Java: A Beginner’s Guide (Schildt):
Module 1 - Java Fundamentals.
-
Java: A Beginner’s Guide (Schildt):
Module 2 - Introducing Data Types and Operators.
-
Java: A Beginner’s Guide (Schildt):
Module 3 - Program Control Statements.
-
Core Java: Fundamentals (Horstmann, Cornell):
Chapter 4 - Fundamental Programming Structures in Java.
-
Getting Started
-
Object-Oriented Programming Concepts
-
Language Basics
-
Java Language Tutorial (by Jakob Jenkov)
The concept of Java:
- history of Java;
- JVM - Java virtual mashine;
- basic features of Java;
- standard packages;
- documentation;
- Java technology;
- development environment NetBeans 7.3.
Java programming language:
- the first program in Java;
- compiling - javac;
- loading and execution - java;
- literals, variables, operators, expressions, instructions, comments;
- primitive types and referenced types;
- creation new object (operator new) and removing unwanted objects (garbage-collector);
- wrapper classes for primitive types;
- the String class;
- conversion from string to number;
- arrays and multidimensional arrays;
- standard input and output;
- program arguments.
- Sample programs:
- FirstProg.java
- ProgArgs.java
- StringToNumber.java
- TriangArray.java
- 10 October, 2013 (classes and objects)
-
Recommended reading:
-
The Java Programming Language (Arnold, Gosling, Holmes):
Chapter 2 - Classes and Objects.
-
Java: A Beginner’s Guide (Schildt):
Module 4 - Introducing Classes, Objects, and Methods.
-
Core Java: Fundamentals (Horstmann, Cornell):
Chapter 4 - Objects and Classes.
-
Classes and Objects
-
Java Language Tutorial (by Jakob Jenkov)
Classes and objects:
- class as a new data type;
- class definition;
- class members: fields and methods;
- reference this;
- constructors and object initialization;
- methods and theirs arguments;
- overloading;
- methods with a variable number of arguments;
- final fields;
- static members;
- access controll.
- 17 October, 2013 (inheritance)
-
Recommended reading:
-
The Java Programming Language (Arnold, Gosling, Holmes):
Chapter 3 - Extending Classes.
-
Java: A Beginner’s Guide (Schildt):
Module 7 - Inheritance.
-
Core Java: Fundamentals (Horstmann, Cornell):
Chapter 5 - Inhereritance.
-
Interfaces and Inheritance
-
Java Language Tutorial (by Jakob Jenkov)
Extending classes:
- base class and extended class;
- inheritance declaration;
- a class can extends exactly one another class;
- the hierarchy of inheritance (class Object is on the top of the hierachy);
- constructor order dependencies: (1) invoke a superclass's constructor,
(2) initialize the fields using their initializers and any initialization blocks;
(3) execute the body of the constructor;
- a constructor in the extended class can directly invoke one of the superclass's
constructors using another kind of explicit constructor invocation: the superclass
constructor invocation, which uses the super construct;
- fields cannot be overridden - they can only be hidden;
- overriding a method means replacing the superclass's implementation of a method
with one of your own;
- upublicznianie składowych;
- accessing inherited members.
Polymorphism:
- type compatibility and conversion;
- you can test the class of an object by using the instanceof operator;
- polymorphic method invocation;
- final methods and classes;
- abstract classes and methods;
- the Object class and its methods toString and equals.
- 24 October, 2013 (interfaces, inner classes)
-
Recommended reading:
-
The Java Programming Language (Arnold, Gosling, Holmes):
Chapter 4 - Interfaces.
-
The Java Programming Language (Arnold, Gosling, Holmes):
Chapter 5 - Nested Classes and Interfaces.
-
Java: A Beginner’s Guide (Schildt):
Module 8 - Packages and Interfaces.
-
Core Java: Fundamentals (Horstmann, Cornell):
Chapter 6 - Interfaces and Inner Classes.
-
Interfaces and Inheritance
-
Java Language Tutorial (by Jakob Jenkov)
Interfaces:
- interfaces define types in an abstract form as a collection of methods
or other types that form the contract for that type;
- interface definition;
- an interface can declare named constants - these constants are defined as fields
but are implicitly public, static, and final;
- an interface can declare methods - these methods are implicitly public
and abstract because no implementation is;
- extending interfaces;
- implementing interfaces;
- adapters;
- interface Cloneable and cloning objects.
Inner classes:
- classes and interfaces can be declared inside other classes and interfaces;
- static nested types;
- non-static nested classes are called inner classes;
- anonymous inner classes.
- 7 November, 2013 (exceptions and assertions)
-
Recommended reading:
-
The Java Programming Language (Arnold, Gosling, Holmes):
Chapter 12 - Exceptions and Assertions.
-
Java: A Beginner’s Guide (Schildt):
Module 9 - Exception Handling.
-
Exceptions
-
Java Exception Handling (by Jakob Jenkov)
Exceptions:
- exceptions provide a mechanism to signal errors directly;
- the hierarchy of exceptions (the Throwable class);
- there are two kinds of exception types:
checked (those that must be declared in the throws-clause of a method or constructor)
and unchecked (those that need not be)
which inherit from Error or RuntimeException;
- throwing exceptions (the throw statement);
- catching exceptions (the try-catch statement);
- the finally clause of a try-catch statement
provides a mechanism for executing a section of code
whether or not an exception is thrown;
- a catch clause is somewhat like an embedded method
that has one parameter namely, the exception to be caught;
- the throws clause and method overriding;
- all exceptions you create should extend Exception,
making them checked exceptions;
- exception chaining.
Assertions:
- assertions are used to check invariants (conditions that should always be true);
- the assert statement and throwing the error AssertionError;
- turning assertions on and off.
- 14 November, 2013 (AWT, graphics, events)
-
Recommended reading:
-
Java AWT Reference
- 21 November, 2013 (Swing - GUI components)
-
Recommended reading:
-
Creating a GUI With JFC/Swing
- 28 November, 2013 (Swing - windows architecture)
-
Recommended reading:
-
Creating a GUI With JFC/Swing
- 5 December, 2013 (generics)
-
Recommended reading:
-
Generics (by Gilard Bracha)
-
Generics (Updated)
-
Java Generics Tutorial (by Jakob Jenkov)
- 12 December, 2013 (collections, enumerations)
-
Recommended reading:
-
Collections
-
Java Collections Tutorial (by Jakob Jenkov)
Collections:
- a collection - simply an object that groups multiple elements into a single unit;
- the hierarchy of collections (the Collection and Map interfaces);
- iterators;
- sorted collections (the SortedSet and SortedMap interfaces);
- comparators;
- implementations of collections;
- old collections;
- algorithms performed on collections (the Collections and Arraysclasses).
Enumerations:
- the definition of enum type;
- how to use an enum type;
- you can define fields, constructors, and methods inside an enum type.
- 19 December, 2013 (threads)
-
Recommended reading:
-
Concurrency
-
Java Concurrency / Multithreading Tutorial (by Jakob Jenkov)
-
java.util.concurrent Tutorial (by Jakob Jenkov)
-
Java concurrency (multi-threading) - tutorial (by Lars Vogel)
-
Introduction to Java threads (by Donald G. Drake)
-
Java Threads Tutorial
- 9 January, 2014 (streams)
-
Recommended reading:
-
Basic I/O
-
Java IO Tutorial (by Jakob Jenkov)
- 16 January, 2014 (applets)
-
Recommended reading:
-
Java Applets
-
Java Applet Tutorial (www.realapplets.com)
-
Java Applet Tutorial (www.javakode.com)
-
Java - Applet Basics (www.tutorialspoint.com)