Java Practice Problems


Java Logo

The best thing you can do if you’re learning to code is to write more code. Below you will find a set of Java practice problems that are available at ClassCube.

All of the problems will load into an online IDE where you can type in your code and test it with a click. We’ve made it as easy to use as possible.

If you’re a teacher, be sure to checkout our page on teaching with ClassCube and find out why ClassCube might just be the perfect tool for you and your students.

Arrays

Array Sum

Calculate the sum of all integer values in an array

Create and Fill Array

Create and fill an array of a specified size

Is Sum Even

Check if the sum of all integers in an array is an even number

Reverse Array

Given an array, return the reversed version

Basics

Chicken Class

Create a Java class totally from scratch

Files

Sum Lines

Calculate the sum of integers read from a file

Lists / ArrayLists

Force Evens

Fix an ArrayList so that it only contains even numbers

Remove Even Numbers

Given an ArrayList of Integers, remove all the odd values

Logic

Lucky 13

Check if two integers add up to 13 or if either is 13

Math

Circle Area

Calculate the area of a circle

Strings

Count the Vowels

Return the number of vowels in a given string

Count the Words

Count the number of individual words in a string

First n Characters

Return the first n characters from a string

Longest Prefix Length

Given two strings, return the length of the longest shared prefix

Longest String Prefix

Given two strings, return the longest prefix that they share

Rotate String

Given a String str and an int howFar, rotate and return str rotated howFar spaces to the left.