• Home   /  
  • Archive by category "1"

Java Programming Assignments And Solutions

About these programming exercises

This site contains Java programming and computer science exercises with solutions. To see the solution for an exercises please follow the link to the Javadoc at the and of the exercise's text.

These exercises are designed for an introductional course into computer science with Java as the first programming language. Some of them have been former used as pratical assignments for my lecture. They cover basic algorithm design and the fundamental concepts of Java (without inheritance, abstract classes, and inner classes). These exercises are not suitable to learn about Java libraries and APIs like GUI developement with Swing, server side Java or other special Java technologies. To learn about Java technologies, have a look at the Java tutorials at Sun.

You can download all solutions to the Java programming exercises as a compressed zip archive. The source of the Java classes is UTF-8 encoded. Most Java classes can be compiled with Java 1.4, some need Java 1.5 or Java 1.6. Use the newest Java version if possible. You need JUnit to compile the Java test classes.

It is possible to use most of the programming exercises for other programming languages like C# or C++ as well.

Organization of the Java programming exercises

The exercises are given in chronological order and by topic. Furthermore, I estimated the degree of difficulty of each Java programming exercise.

  • 1, high degree of difficulty, difficult programming exercises
  • 2, medium degree of difficulty, suitable for programmers with some experience in Java and computer science
  • 3, low degree of difficulty, easy and simple programming exercise, suitable for Java programming beginners

List of all Java exercises

New exercises can be found at the start of the list. I am currently translating my german version of the Java exercises to English.

Java exercises of September 2007

Java exercises of August 2007

  • Compare chemical elements with the abstract data type Comparable (interfaces), 2
  • Implement the periodic table of the chemical elements by loading the elements values from a file (misc), 2
  • Design and implement chemical elements (objects), 2
  • Convert a given number of bytes into a representation with metric units (flow control), 3
  • Calculate the electrical resistance of a wire (data types and expressions), 3
  • Convert 16 bit Unicode into UTF-8 (data types and expressions), 1
  • Find the smalles distance between two neighbouring numbers in an array (arrays), 2
  • Find the digit sum of a sequence of digits (arrays), 3
  • Winning strategy for Roulette (flow control), 2

Java exercises of July 2007

  • Design and implement rational numbers (objects), 2
  • Find the day of the week of a given date (flow control), 2
  • Generate Sudokus (backtracking), 2
  • Design and implement a queue (interfaces), 1
  • Implement natural mergesort (sorting), 1
  • Implement Newton's method (searching), 2
  • Design and implement polynomials (objects), 2
  • Implement bottom-up mergesort (sorting), 1-2
  • Implement Shell sort (sorting), 1
  • Implement Euclids algorithm recursivly (recursion), 2
  • Find zeros of continueous functions (searching), 2
  • Design and implement a class for wind speed (objects), 2
  • Implement a simple calculator (recursion), 1
  • Check for anagrams (arrays), 2
  • Calculate (german) grades for an examination (flow control), 3
  • Sort three numbers (flow control), 3
  • Print out the multiplication table for 1 to 10 (flow control), 3
  • Give a boolean expression for the definition of a metropolis (data types and expressions), 3

Java exercises of June 2007

My recommendation is to solve problems that you're interested in, writing code that might be useful to you.

Java is a huge box. It's got a lot of computer science inside: graphics, scientific computing, relational databases, user interfaces for desktop and web, messaging and queuing, multi-threading, security, and more. Each area has their own "beginner problem". Which one do you mean?

How do you define "beginner problem"? Maybe you're having trouble because you aren't narrowing your search enough.

If your imagination is lacking, your best bet is to Google something like "java beginner practice problems" and investigate what you get back.

Or start with Sun's on-line Java tutorial and work you way all the way through it. You'll know a fair amount about Java when you're done.

answered May 23 '10 at 14:51

One thought on “Java Programming Assignments And Solutions

Leave a comment

L'indirizzo email non verrà pubblicato. I campi obbligatori sono contrassegnati *