Skip Top Navigation Bar

Exploring Java with Practice Activities

Introduction to Algorithms Practice

While it might not be the most fun part of writing a program, planning out your algorithm(s) in advance can make the process go much more smoothly. Taking the time to identify objects that might need to be represented, the data that would be stored with those objects, and the way in which they would function in advance of writing the program helps you to think ahead to any unforeseen problems or issues. This is especially true the more complicated your programs might become.

In this introduction to algorithms practice set, you will practice writing your own algorithms for things that are part of everyday life and then move on to writing comprobable algorithms to a given algorithm.

Classifying Data

Computers input, store, process, and output data and they do this through programs. The data that is being used is categorized into different types it is stored properly.

In this activity, you will think about the type of data that is being described and determine whether it is primitive data or object data, identify the specific type of data, and provide a rational for your choice.

Determine if Data is Mutable or Immutable

Mutable data can change throughout the running of a program. Immutable data cannot change during the running of a program. It is important to recognize whether data would change or not so that the appropriate data type can be used it store the data.

In this activity, you will think about all the data that would need to be stored for the described object and determine what of that data would be mutable and what data would be immutable.

Declaring and Initializing Variables

Data and how it is stored really is a cornerstone of a program. In this activity, you will determine the data type, variable name, and initial value for described variables. You will also be given some incorrect statements to test in the Java Playgroud and fix them.

Experiment with Arithmetic Basics

Sometimes you just want a tool that you can try a little code out in and see what it does. As you tweak and change it, you learn more and more about what it means and how it works. Students can also benefit from this explorative way to learn programming.

When I used to teach students the arithmetic operators - +, -, *, /, and % - I would provide them with some code to try out. They were supposed to first predict the result of the code segment and then try it out on their computer. Most would get the addition and subtraction expressions correct, but when it came to integer division or modulus, the results weren't what they expected. This allowed them an opportunity to modify their code to see if they could figure out what the operator actually did or why it didn't behave as they originally expected.

The Java Playground is a great tool to use for this type of hands-on exploration. We've put together a short activity that leverages the Java Playground.

If, Ternary, and Switch Statements

Instructional Supports for Teachers

In this set of materials, you will find a set of 4 practice questions that ask students to write solutions as both if statements and ternary conditional operator expressions. Apply what you have learned by completing the corresponding mini-lab.

Exploring the Use of var with the Java Playground

The introduction of var is meant to reduce the syntax when the type of a variable can be inferred.

In this activity, we will explore the different ways var can and cannot be used. This activity will leverage the Java Playground to allow for real-time feedback on statements.