Programming with Java

From Juneday education
Jump to: navigation, search


Regards from the authors: Rikard Fröberg and Henrik Sandklef

Before reading this book

Intended audience

This book is (at least intended to be) suitable for an introductory programming course. It covers the basics of computing starting with basic computer technology followed by an introduction to imperative programming and moves on to introducing object oriented programming concepts such as objects, classes, interfaces, inheritance etc. The programming language used is Java and the course examples, exercises and assignments are written in a way suitable for programming in the command line. We don't require any prior knowledge in programming or working in the shell, but it is helpful to the reader to have a basic understanding of computers, operating systems and the file system.

This course has been used in various introductory university courses and courses at the Higher Vocational Education level (Swedish: Yrkeshögskola). The authors believe, however, that this book also would work well for courses at high school level, as well as for self-studies by anyone. The chapters in this book have all the lectures available in video format, making the book also useful for distance courses and self-studies.


This book assumes you have access to a computer with the following programs/tools installed:

We have written a script that installs some command line tools which might come in handy during the course. Follow the instruction on the page Software_used.

The focus will be on developing Java applications using the command line and an editor. It is possible to use an IDE for the exercises but the exercise instructions will focus on instructions for creating, compiling and running the exercises from the command line. For a discussion on why we have chosen not to use an IDE for this course, please see Why_not_IDE.

Recommendation - but not a formal requirement

While not a formal requirement, we recommend that the reader gets familiar with working in the shell (e.g. a terminal running bash) and also with the concept of text files and the three streams found in a typical POSIX system - Standard in, Standard out and Standard Error. These chapter from our Bash-introduction book is recommended, but not mandatory, reading:

As with most material found in our books, those chapters have video lectures and exercises.


Done and complete

  1. Computer introduction
  2. Computer introduction - Exercises
  3. Programming introduction
  4. Programming introduction - Exercises
  5. Setting up your environment
  6. Programming in Java
  7. Programming in Java - Exercises
  8. Our first Java program
  9. Our first Java program - Exercises
  10. Variables and types
  11. Variables and types - Exercises
  12. Expressions and operators
  13. Expressions and operators - Exercise
  14. Control flow
  15. Control flow - Exercises
    OLD/Obsolete: Objects in Java
  16. Chapter:Objects_-_Introduction
  17. Chapter:Objects_-_Introduction_-_Exercises
  18. Chapter:Objects_-_Relation_to_classes
  19. Chapter:Objects_-_Relation_to_classes_-_Exercises
  20. Chapter:Objects_-_Creating
  21. Chapter:Objects_-_Creating_-_Exercises
  22. Chapter:Objects_-_Using
  23. Chapter:Objects_-_Using_-_Exercises
  24. Chapter:Objects_-_Java_API_documentation
  25. Chapter:Objects_-_Java_API_documentation_-_Exercises
  26. Chapter:Objects_-_Questions_and_Answers
    OLD/OBSOLETE Chapter:Classes_I
    OLD/OBSOLETE Chapter: Classes_II
    OLD/OBSOLETE Chapter: Classes_III
  27. Chapter:Classes_-_Introduction
  28. Chapter:Classes_-_Introduction_-_Exercises
  29. Chapter:Classes_-_Declaration
  30. Chapter:Classes_-_Declaration_-_Exercises
  31. Chapter:Classes_-_Packages
  32. Chapter:Classes_-_Packages_-_Exercises
  33. Chapter:Classes_-_main
  34. Chapter:Classes_-_main_-_Exercises
  35. Chapter:Classes_-_Commenting_code
  36. Chapter:Classes_-_Commenting_code_-_Exercises
  37. Chapter:Classes_-_Declaring_variables
  38. Chapter:Classes_-_Declaring_variables_-_Exercises
  39. Chapter:Classes_-_Defining_constructors
  40. Chapter:Classes_-_Defining_constructors_-_Exercises
  41. Chapter:Classes_-_Defining_methods
  42. Chapter:Classes_-_Defining_methods_-_Exercises
  43. Chapter:Classes_-_Static_members
  44. Chapter:Classes_-_Static_members_-_Exercises
  45. Chapter:Classes_-_final_members
  46. Chapter:Classes_-_final_members_-_Exercises
  47. Chapter:Classes_-_Using_packages
  48. Chapter:Classes_-_Using_packages_-_Exercises
  49. Chapter:Classes_-_Testing_your_classes
  50. Chapter:Classes_-_Testing_your_classes_-_Exercises
  51. Chapter:Classes_-_Using_your_classes
  52. Chapter:Classes_-_Using_your_classes_-_Exercises
  53. Chapter:Classes_-_API_source_code
  54. Chapter:Classes_-_API_source_code_-_Exercises
  55. Chapter:Classes_-_Other_keywords
  56. Chapter:Classes_-_Other_keywords_-_Exercises
  57. Chapter:Classes_-_Strings_are_immutable
  58. Chapter:Classes_-_Strings_are_immutable_-_Exercises
    OLD/Obsolete Inheritance
  59. Chapter:Inheritance_-_What_is_it
  60. Chapter:Inheritance_-_What_is_it_-_Exercises
  61. Chapter:Inheritance_-_Every_class_extends_Object
  62. Chapter:Inheritance_-_Every_class_extends_Object_-_Exercises
  63. Chapter:Inheritance_-_Overriding_methods_in_Object
  64. Chapter:Inheritance_-_Overriding_methods_in_Object_-_Exercises
  65. Chapter:Inheritance_-_Extending_your_own_classes
  66. Chapter:Inheritance_-_Extending_your_own_classes_-_Exercises
  67. Chapter:Inheritance_-_Examples_from_Swing
  68. Chapter:Inheritance_-_Examples_from_Swing_-_Exercises
  69. Chapter:Inheritance_-_Some_rules_and_syntax
  70. Chapter:Inheritance_-_Some_rules_and_syntax_-_Exercises
  71. Chapter:Inheritance_-_Problems_with_inheritance
  72. Chapter:Inheritance_-_Problems_with_inheritance_-_Exercises
    OLD/OBSOLETE Interfaces Number of pages: 24 number of exercises: 23 Number of videos: 4
  73. Chapter:Interfaces_-_Introduction
  74. Chapter:Interfaces_-_Introduction_-_Exercises
  75. Chapter:Interfaces_-_Implementing_an_interface
  76. Chapter:Interfaces_-_Implementing_an_interface_-_Exercises
  77. Chapter:Interfaces_-_Writing_an_interface
  78. Chapter:Interfaces_-_Writing_an_interface_-_Exercises
  79. Chapter:Interfaces_-_Program_against_an_interface
  80. Chapter:Interfaces_-_Program_against_an_interface_-_Exercises
  81. Chapter:Interfaces_-_Creating_an_anonymous_class
  82. Chapter:Interfaces_-_Creating_an_anonymous_class_-_Exercises
  83. Chapter:Interfaces_-_Rules_and_syntax
  84. Chapter:Interfaces_-_Rules_and_syntax_-_Exercises
    OLD/OBSOLETE Exceptions
  85. Chapter:Exceptions_-_What_is_it
  86. Chapter:Exceptions_-_What_is_it_-_Exercises
  87. Chapter:Exceptions_-_Two_main_types
  88. Chapter:Exceptions_-_Two_main_types_-_Exercises
  89. Chapter:Exceptions_-_Code_examples
  90. Chapter:Exceptions_-_Code_examples_-_Exercises
  91. Chapter:Exceptions_-_Creating_your_own
  92. Chapter:Exceptions_-_Creating_your_own_-_Exercises
  93. Chapter:Exceptions_-_Rules_and_syntax
  94. Chapter:Exceptions_-_Rules_and_syntax_-_Exercises
  95. Assignment - Guessing game
  96. Assignment - Address book

Programming in Java in numbers

Currently, the book consists of 14 chapters, which when printed amount to 268 pages. Each chapter has more or less exercises/questions, in total 346 exercises/questions. In every chapter, we give links to further reading, a total of 46 external links so far. Every chapter has videos with lectures and examples. In total we have 86 videos (some videos are parts of the same topic, and some videos are stand-alone lectures, while other videos are examples of coding).

Chapter completeness (for teachers)

Chapter Meta section completed Text and examples Videos (number of) Slides Exercises
Computer introduction YES Short text 5 Eng, 5 Swe 5 slides YES
Programming introduction YES Short text 6 Eng, 2 Swe 2 slides YES
Setting up your environment YES Short text 7 Eng No slides (workshop/supervision) No (only workshop/supervision)
Programming in Java YES Short text (and Q&A) 3 Eng, 3 Swe 1 slides YES
Our first Java program YES Yes (also Q&A) 2 Eng, 2 Swe 1 slides YES
Variables and types YES Short text (and Q&A) 7 Eng, 7 Swe 6 slides YES
Expressions and operators YES YES (also Q&A) 2 Eng, 2 Swe 2 slides YES
Chapter:Control flow TODO YES (also Q&A) 5 Eng, 5 Swe 2 Slides YES
Chapter:Objects_-_Introduction Started/incomplete YES 15 Eng, 15 Swe 1 slides NO
Chapter:Objects_-_Relation_to_classes NO/TODO Very short 1 Eng, 1 Swe 1 slides NO
Chapter:Objects_-_Creating NO Very short 2 Eng, 2 Swe 1 slides YES
Chapter:Objects_-_Using NO/TODO YES 4 Eng, 4 Swe 4 slides YES
Chapter:Objects_-_Java_API_documentation NO/TODO Medium But see:
Objects Q&A
5 Eng, 5 Swe No slides!
Chapter:Objects_-_Questions_and_Answers No, this is a special chapter YES No, special chapter No, special chapter No, special chapter
Chapter:Classes_-_Introduction YES Short No videos No slides NO
Chapter:Classes_-_Declaration TODO Medium No videos! No slides! NO
Chapter:Classes_-_Packages TODO YES 1 Eng, 1 Swe 1 slides YES
Chapter:Classes_-_main TODO Very short No videos No slides YES
Chapter:Classes_-_Commenting_code TODO YES No videos! No slides! YES
Chapter:Classes_-_Declaring_variables TODO YES 2 Eng, 2 Swe 1 slides YES
Chapter:Classes_-_Defining_constructors TODO YES 2 Eng, 2 Swe 1 slides YES
Chapter:Classes_-_Defining_methods TODO Medium 2 Eng, 2 Swe 1 slides YES
Chapter:Classes_-_Static_members TODO YES 2 Eng, 2 Swe 2 slides YES
Chapter:Classes_-_final_members TODO Hardly any No videos! No slides! YES
Chapter:Classes_-_Using_packages TODO YES/Medium 1 Eng, 1 Swe 1 slides YES (a few)
Chapter:Classes_-_Testing_your_classes TODO YES (plus link to
bonus page on Assert)
No videos! No slides! YES (a few)
Chapter:Classes_-_Using_your_classes Yes Short/Medium No videos! No slides!
Also, no links
YES (on topic?)
Chapter:Classes_-_API_source_code TODO Hardly No videos! No slides! YES
Chapter:Classes_-_Other_keywords TODO Short No Videos! No slides! NO
Chapter:Classes_-_Strings_are_immutable TODO YES (quite long) 1 Eng, 1 Swe 1 slides YES (a few)
Chapter:Inheritance_-_What_is_it YES Short/Medium 1 Eng, 1 Swe 1 slides NO
Chapter:Inheritance_-_Every_class_extends_Object NO/TODO Short 4 Eng, 2 Swe 1 slides YES
Chapter:Inheritance_-_Overriding_methods_in_Object NO/TODO Hardly 5 Eng, 1 Swe 1 slides YES
Chapter:Inheritance_-_Extending_your_own_classes NO/TODO Hardly 1 Eng, 1 Swe 1 slides YES
Chapter:Inheritance_-_Examples_from_Swing NO/TODO Hardly 2 Eng, 2 Swe 1 slides NO
Chapter:Inheritance_-_Some_rules_and_syntax NO/TODO Hardly 2 Eng, 2 Swe 1 slides NO
Chapter:Inheritance_-_Problems_with_inheritance NO/TODO Short/medium 1 Eng, 1 Swe 1 slides Link to extra
Chapter:Interfaces_-_Introduction YES YES 1 Eng, 1 Swe 1 slides YES
Chapter:Interfaces_-_Implementing_an_interface TODO YES 3 Eng, 3 Swe 3 slides YES
Chapter:Interfaces_-_Writing_an_interface TODO YES 1 Eng, 1 Swe 1 slides YES(on topic?)
Chapter:Interfaces_-_Program_against_an_interface TODO YES No videos! No slides! NO
Chapter:Interfaces_-_Creating_an_anonymous_class TODO YES No videos! No slides! NO
Chapter:Interfaces_-_Rules_and_syntax TODO YES No videos! No slides! NO
Chapter:Exceptions_-_What_is_it YES YES 2 Eng, 2 Swe 1 slides YES (a few)
Chapter:Exceptions_-_Two_main_types TODO YES 2 Eng, 2 Swe 1 slides YES
Chapter:Exceptions_-_Code_examples TODO YES
(quite long)
4 Eng, 4 Swe 1 slides YES
Chapter:Exceptions_-_Creating_your_own TODO YES 2 Eng, 1 Swe 1 slides YES
Chapter:Exceptions_-_Rules_and_syntax TODO YES 1 Eng, 1 Swe 1 slides NO

Chapters - work in progress -details for delivery plan

This chapter has been split up into two chapters, each with one assignment. This is kept for historical references. * Chapter 14 - Wrapping it up (work in progress, est delivery date 2016-10-30)

  • This chapter will consist of three hand-ins/assignments - two of which are ready
    • Assignment #03 (work in progress, est delivery date 2016-10-28 (earliest))
    • #Written exam (work in progress, est. delivery date 2016-10-28)

Information about the exam

  • The exam in a typical course using this book, should be based on the exercises from every chapter. This makes it clear for the students both what to expect and that completing every exercise in every chapter pays off in that it prepares the student for the exam. It also helps the teacher making sure that there is a correspondence between the course and the exam, and that the students have practiced what they should know on the exam.

Book companion - Questions ans Answers

Extra/Bonus chapters/pages