Exams and tests
Getting Ready for a Data Structures Course (CS2) in Java
Published on October 22, 20265 min read
You passed your first programming course, maybe only just. Now the data structures course is coming up, and you suspect that some of the basics never really stuck. That's normal, and you can fix it. In this post you'll find out which gaps cost you the most in CS2, how to spot them in ten minutes and how to close them in four weeks.
What a CS2 course usually covers
There is no single "CS2". Depending on your university or college, the course may be called Data Structures, Programming II, Object-Oriented Programming or simply have a course number. The content differs too. But if you compare course descriptions from different places, the same topics keep showing up:
- Object-oriented programming in depth: inheritance, polymorphism, abstract classes, interfaces.
- Generics and the collections framework: lists, sets, maps, iterators.
- Exceptions, enums, often file handling and unit tests with JUnit.
- Data structures and algorithms: stacks, queues, linked lists, trees, sorting, recursion.
What exactly is on your course is in the syllabus or course page. Check it before term starts and cross out the topics you won't need. Everything else in this post is deliberately general.
The gaps that hurt most in CS2
CS2 builds on CS1 without repeating it. These five basics are assumed from week one:
- Methods with parameters and a return value. If you mix up
returnandSystem.out.println, every data structure task will trip you up. - Arrays and loops over indexes. Sorting algorithms consist of little else.
- Classes, objects, constructors and
this. Without them you won't understand inheritance or a linked list. - References instead of values. Two variables can point to the same object. For objects,
==compares references andequalscompares content. - Recursion. Trees and many sorting algorithms are recursive. If you can't play through the call stack in your head, this is where you fall behind.
A ten-minute self-test
Before you read on, write down on paper what this program prints:
public class Main { static void grow(int[] values) { values[0] = 99; }
static void reset(int number) { number = 0; }
static int sum(int n) { if (n == 0) { return 0; } return n + sum(n - 1); }
public static void main(String[] args) { int[] values = {1, 2, 3}; int number = 7; grow(values); reset(number); String a = new String("Java"); String b = new String("Java"); System.out.println(values[0]); System.out.println(number); System.out.println(a == b); System.out.println(a.equals(b)); System.out.println(sum(4)); }}
Output99 7 false true 10
Here's how to score yourself:
- Got 99? You know that an array is passed as a reference. The method changes the original.
- Got 7? You know that an
intis copied. The change inresetstays local. - Got false and true? You know the difference between
==andequals. There's more on that in the chapter on Strings. - Got 10? You can trace recursion: 4 + 3 + 2 + 1 + 0.
Every wrong line points to a topic you should review before CS2. Output questions like these are also popular in exams. How to practise them systematically is in "What does the program print?": how to practise the exam question.
A four-week plan
Plan on 30 to 60 minutes a day, five days a week. That fits into a break between terms, even next to a part-time job.
Week 1: methods, arrays, strings
Review Methods and recursion and write two or three small methods every day: the maximum of an array, a word reversed, a check whether a number is prime. What matters is that you write each method yourself and try it with several inputs.
Week 2: classes and inheritance
Read Classes and objects and then Inheritance and interfaces. Build a small class hierarchy, for example Shape with Circle and Rectangle, and calculate areas through an interface. That way you see polymorphism in action before it comes up in lectures.
Week 3: collections, exceptions, generics
Work through Lists and maps, then Exceptions and enums. Count the words in a text with a Map<String, Integer>, for example. Then you already know generics from practice before you write generic classes of your own.
Week 4: first algorithms and data structures
Start with simple sorting and recursion and backtracking. Implement bubble sort and insertion sort yourself and walk through them on paper with an array of five numbers. If you still have time, take a look at stacks, queues and linked lists.
If you notice that the gaps are bigger, take a step back. Our post on the right order for learning Java topics shows what builds on what.
How to practise so it sticks
Reading alone isn't enough. These rules make the difference:
- Write it yourself. Following someone else's code feels like understanding. Only when you can write it without a template do you know it has stuck.
- Predict first, then run. Before each run, think about what should come out. If the result is different, you've learned something.
- Know the common mistakes. Each of our lesson articles ends with a "Common mistakes" section. Read it before you solve the tasks.
- Practise without autocomplete, too. Many programming exams are still written on paper, depending on your course. Tips for that are in Java exams on paper: practise writing code without an IDE.
How Jario helps with the step up
Jario is built for exactly this gap. The Java basics course goes from your first output to streams and generics in 12 chapters. You can jump straight into the chapter that gave you trouble in the self-test. After that, the Algorithms in Java course takes over: 8 chapters on searching, sorting, recursion, trees, heaps, hashing and graphs, which are typical CS2 topics.
You check every task against tests with "Check". If you get stuck, the AI tutor gives you hints in small steps without giving away the solution. It knows the task, your code and the test result. You can switch off autocomplete in the editor when you're practising for a paper exam. And because everything runs in the browser, you don't need a JDK set up.
In short
Take the self-test, note your gaps and work through them with the four-week plan. Once methods, classes, references and recursion are solid, CS2 is no longer a fresh start but the continuation of something you can already do. In Jario you can start right in your browser with the chapter you need most.
Related articles to learn
- Inheritance and interfacesJava inheritance explained simply: extends, super, @Override, abstract classes, interfaces and Comparable with examples. Plus common mistakes.Read article
- Lists and mapsLists and maps in Java explained simply: ArrayList, HashSet and HashMap with examples. Plus common mistakes like List<int> and remove on numbers.Read article
- Recursion and backtrackingRecursion and backtracking in Java explained simply: base case, call stack, permutations and Towers of Hanoi with examples and typical mistakes.Read article
More posts
- Exams and testsAP CSA in 3 weeksAP Computer Science A in 3 weeks: what the exam looks like, a week-by-week Java study plan, and how to write free-response code without an IDE.Read more
- Exams and testsAssignments without all-nightersWeekly programming assignments without all-nighters: how to spread one over the week, test your code before you submit and get help without plagiarism.Read more
- Exams and testsOracle Java certificationOracle Java SE 21 Developer exam 1Z0-830: format, topics, who it is for, how to prepare and whether it is worth it. Plus what changes with Java 25.Read more