Kotlinlearncs.online LogoJava

132 Java questions for you to practice.

Switch to Kotlin

Hello, world!

Hello, learncs.online!

System.out.println

Hello, world!

System.out.println

Variables and Types

Practice with Primitive Types

initializing variables
declaring variables

Practice with Primitive Types 2

initializing variables
declaring variables

Practice with Variable Declaration and Initialization 0

initializing variables
declaring variables

Operations on Variables

Area Calculation

arithmetic
initializing variables
declaring variables

Inspiration v. Perspiration

arithmetic
initializing variables
declaring variables

Conditional Expressions and Statements

Advertising Conditional

if-else statements
if statements
comparisons
System.out.println

Simple Conditional

if-else statements
if statements
comparisons
System.out.println

Largest of Three

if statements
comparisons
modifying variables
initializing variables
declaring variables
System.out.println

Compound Conditionals

Quiz Score Advice

if-else-if statements
if-else statements
if statements
comparisons
System.out.println

Arrays

Array Basics

accessing arrays
using arrays
modifying variables
initializing variables
declaring variables
System.out.println

Loops

Number Loop

for loops
comparisons
variable operations
modifying variables
initializing variables
declaring variables
System.out.println

Victory Loop

for loops
comparisons
variable operations
modifying variables
initializing variables
declaring variables
System.out.println

Array Count Odd Snippet

for loops
accessing arrays
if statements
comparisons
arithmetic
variable operations
modifying variables
initializing variables
declaring variables
System.out.println

Array Sum Even Snippet

for loops
accessing arrays
if statements
comparisons
variables assignment
arithmetic
variable operations
modifying variables
initializing variables
declaring variables
System.out.println

Functions

Add One Function

return
declaring methods
arithmetic

Is Odd

return
declaring methods
comparisons
arithmetic

Sum Is Odd

return
declaring methods
comparisons
arithmetic

Accounting Calculator

return
declaring methods
for loops
accessing arrays
comparisons
variables assignment
arithmetic
variable operations
modifying variables
initializing variables
declaring variables

Overloaded Multiply

return
declaring methods
arithmetic

Reverse Print

return
declaring methods
for loops
accessing arrays
comparisons
arithmetic
variable operations
modifying variables
initializing variables
declaring variables
System.out.println

Array Count Equal (One Dimensional)

return
declaring methods
for loops
accessing arrays
if statements
comparisons
variable operations
modifying variables
initializing variables
declaring variables

Catchup Quiz Grading

return
declaring methods
for loops
accessing arrays
if statements
comparisons
arithmetic
variable operations
modifying variables
initializing variables
declaring variables

Array Is Doubled

return
declaring methods
for loops
accessing arrays
if statements
comparisons
arithmetic
variable operations
modifying variables
initializing variables
declaring variables

Array All Pairs

return
declaring methods
for loops
accessing arrays
logical operators
if statements
comparisons
variables assignment
arithmetic
modifying variables
initializing variables
declaring variables

Array Is All Larger

return
declaring methods
for loops
accessing arrays
logical operators
if statements
comparisons
variable operations
modifying variables
initializing variables
declaring variables

Tic-Tac-Toe

return
declaring methods
for loops
accessing arrays
logical operators
if statements
comparisons
variable operations
modifying variables
initializing variables
declaring variables

More About Functions

Print Adult Or Not

nested conditionals
logical operators
if-else statements
if statements
comparisons
System.out.println

Print Larger, Sometimes

nested conditionals
if-else statements
if statements
comparisons
System.out.println

Game Tiebreaker Function

nested conditionals
return
declaring methods
if-else-if statements
if-else statements
if statements
comparisons

Game Tiebreaker Snippet

nested conditionals
if-else-if statements
if-else statements
if statements
comparisons
modifying variables

Practice with Functions

Array Range Sum

enhanced for loop
return
declaring methods
for loops
logical operators
if statements
comparisons
variables assignment
arithmetic
modifying variables
initializing variables
declaring variables

Strings

Email to NetID

dotted method calls
dot notation
Strings
assert statements
return
declaring methods
accessing arrays
using arrays
initializing variables
declaring variables

Reformat a Phone Number

dotted method calls
dot notation
Strings
return
declaring methods
accessing arrays
using arrays
arithmetic
initializing variables
declaring variables

Last Value From String

dotted method calls
dot notation
Strings
enhanced for loop
return
declaring methods
for loops
modifying variables
initializing variables
declaring variables

String Flip Halves

dotted method calls
dot notation
Strings
return
declaring methods
if-else statements
if statements
comparisons
arithmetic
initializing variables
declaring variables

String Reverse

dotted method calls
dot notation
Strings
return
declaring methods
for loops
accessing arrays
using arrays
comparisons
variables assignment
arithmetic
variable operations
modifying variables
initializing variables
declaring variables

Reformat Name and Age Records

dotted method calls
dot notation
Strings
enhanced for loop
return
declaring methods
for loops
accessing arrays
using arrays
if-else statements
if statements
comparisons
variables assignment
arithmetic
modifying variables
initializing variables
declaring variables

Mario Bricks

Strings
nested loops
return
declaring methods
for loops
if-else statements
if statements
comparisons
variables assignment
arithmetic
variable operations
modifying variables
initializing variables
declaring variables

Small Word Filter With Array

dotted method calls
dot notation
Strings
enhanced for loop
return
declaring methods
for loops
accessing arrays
using arrays
if statements
comparisons
variable operations
modifying variables
initializing variables
declaring variables

Algorithms and Strings

Print Number Summary

primitive type casting
dotted method calls
dot notation
Strings
enhanced for loop
declaring methods
continue
for loops
if-else statements
if statements
comparisons
variables assignment
arithmetic
variable operations
modifying variables
initializing variables
declaring variables
System.out.println

null

Array Count Greater Than 1D

working with null
assert statements
return
declaring methods
for loops
accessing arrays
if statements
comparisons
variable operations
modifying variables
initializing variables
declaring variables

Array Sum (Two Dimensional)

working with null
nested loops
return
declaring methods
for loops
accessing arrays
if statements
comparisons
variables assignment
variable operations
modifying variables
initializing variables
declaring variables

Rot 13 Encryption

working with null
dotted method calls
dot notation
Strings
return
declaring methods
for loops
accessing arrays
using arrays
if statements
comparisons
variables assignment
arithmetic
variable operations
modifying variables
initializing variables
declaring variables

2D Array Max Subarray Sum

working with null
nested loops
assert statements
return
declaring methods
for loops
accessing arrays
logical operators
if statements
comparisons
variables assignment
variable operations
modifying variables
initializing variables
declaring variables

Array Max (1D)

working with null
return
declaring methods
for loops
accessing arrays
if statements
comparisons
variable operations
modifying variables
initializing variables
declaring variables

String Rotate Right

working with null
dotted method calls
dot notation
Strings
return
declaring methods
for loops
accessing arrays
using arrays
logical operators
if statements
comparisons
arithmetic
variable operations
modifying variables
initializing variables
declaring variables

Multidimensional Arrays

Array Fill 3 Pattern

using multi-dimensional arrays
nested loops
return
declaring methods
for loops
accessing arrays
comparisons
arithmetic
variable operations
modifying variables
initializing variables
declaring variables

Lists and Type Parameters

Last In List

type parameters
dotted method calls
dot notation
return
declaring methods
arithmetic

Small Word Filter With List

type parameters
dotted method calls
dot notation
creating objects
Strings
enhanced for loop
return
declaring methods
for loops
using arrays
if statements
comparisons
initializing variables
declaring variables

Maps and Sets

Identify a Suspect

type parameters
dotted method calls
dot notation
creating objects
Strings
return
declaring methods
initializing variables
declaring variables

List to Set

type parameters
working with null
dotted method calls
dot notation
creating objects
Strings
enhanced for loop
assert statements
return
declaring methods
for loops
comparisons
initializing variables
declaring variables

Word Count With Map

type parameters
boxing classes
dotted method calls
dot notation
creating objects
Strings
enhanced for loop
return
declaring methods
for loops
using arrays
arithmetic
initializing variables
declaring variables

Word Lengths With Map

type parameters
boxing classes
working with null
dotted method calls
dot notation
creating objects
Strings
enhanced for loop
assert statements
return
declaring methods
for loops
using arrays
comparisons
initializing variables
declaring variables

Map Has Duplicate Values

type parameters
dotted method calls
dot notation
creating objects
Strings
enhanced for loop
return
declaring methods
for loops
if statements
initializing variables
declaring variables

Script Parser

type parameters
working with null
dotted method calls
dot notation
creating objects
Strings
enhanced for loop
assert statements
return
declaring methods
for loops
accessing arrays
using arrays
logical operators
if statements
comparisons
initializing variables
declaring variables

Section Lists to Map

type parameters
working with null
dotted method calls
dot notation
creating objects
Strings
enhanced for loop
nested loops
assert statements
return
declaring methods
for loops
accessing arrays
using arrays
comparisons
variable operations
modifying variables
initializing variables
declaring variables

String Duplicate Words Ignore Case

type parameters
working with null
dotted method calls
dot notation
creating objects
Strings
enhanced for loop
assert statements
return
declaring methods
for loops
using arrays
if statements
comparisons
initializing variables
declaring variables

Encapsulation

Counter Object

public and private
declaring classes
return
declaring methods
variable operations
modifying variables

Format Date Method

public and private
declaring classes
import statements
dotted method calls
dot notation
Strings
return
declaring methods

Object with Public Value

writing getters
working with null
dotted variable accesses
dot notation
assert statements
return
declaring methods
comparisons

Course Hash Code

final fields
public and private
constructors
declaring classes
import statements
dotted method calls
dot notation
Strings
return
declaring methods
modifying variables

Flop Flip Object

public and private
constructors
declaring classes
return
declaring methods
logical operators
modifying variables

Last 8

final fields
public and private
declaring classes
return
declaring methods
accessing arrays
arithmetic
modifying variables

Simple Object Field

public and private
writing setters
writing getters
declaring classes
return
declaring methods
modifying variables

Simple Object Field 2

public and private
writing setters
writing getters
declaring classes
Strings
return
declaring methods
modifying variables

Simple Object Method

public and private
writing setters
declaring classes
return
declaring methods
arithmetic
modifying variables

Simple Object Method 2

public and private
writing setters
declaring classes
return
declaring methods
arithmetic
modifying variables

Toggler Object

public and private
constructors
declaring classes
return
declaring methods
logical operators
modifying variables

Compare Date Strings

public and private
declaring classes
import statements
dotted method calls
dot notation
Strings
return
declaring methods
if-else-if statements
if-else statements
if statements
comparisons
initializing variables
declaring variables

Guessing Game

writing getters
working with null
dotted method calls
dot notation
assert statements
return
declaring methods
for loops
if statements
comparisons
variable operations
modifying variables
initializing variables
declaring variables

Course Getters and Setters

final fields
public and private
writing setters
writing getters
constructors
declaring classes
working with null
Strings
assert statements
return
declaring methods
comparisons
modifying variables

Last 4 In Order

final fields
public and private
declaring classes
return
declaring methods
for loops
accessing arrays
if-else statements
if statements
comparisons
arithmetic
variable operations
modifying variables
initializing variables
declaring variables

Restaurant Getters and Setters

final fields
public and private
writing setters
writing getters
constructors
declaring classes
working with null
Strings
assert statements
return
declaring methods
comparisons
modifying variables

Score Tracker

public and private
declaring classes
return
declaring methods
if-else-if statements
logical operators
if-else statements
if statements
comparisons
variables assignment
modifying variables

SimpleArrayList get and set

final fields
public and private
writing setters
writing getters
constructors
declaring classes
working with null
assert statements
return
declaring methods
accessing arrays
logical operators
comparisons
modifying variables

Count DNA Subsequence

public and private
working with null
dotted method calls
dot notation
Strings
return
declaring methods
for loops
logical operators
if statements
comparisons
variables assignment
arithmetic
variable operations
modifying variables
initializing variables
declaring variables

SimpleArrayList add

public and private
writing getters
constructors
declaring classes
working with null
assert statements
return
declaring methods
for loops
accessing arrays
using arrays
logical operators
if-else statements
if statements
comparisons
arithmetic
variable operations
modifying variables
initializing variables
declaring variables

Static

Static Adder

static methods
public and private
declaring classes
return
declaring methods
arithmetic

Test Array Sum

static methods
public and private
declaring classes
working with null
dotted method calls
dot notation
assert statements
declaring methods
comparisons

Mystery Method 1

static methods
public and private
declaring classes
working with null
dotted method calls
dot notation
Strings
assert statements
return
declaring methods
if-else statements
if statements
comparisons
arithmetic

Mystery Method 2

static methods
public and private
declaring classes
dotted method calls
dot notation
enhanced for loop
return
declaring methods
for loops
using arrays
if statements
comparisons
variable operations
modifying variables
initializing variables
declaring variables

Object Array Shallow Copy

static methods
public and private
declaring classes
working with null
return
declaring methods
for loops
accessing arrays
using arrays
if statements
comparisons
variable operations
modifying variables
initializing variables
declaring variables

Object v. Reference Equality

static methods
public and private
declaring classes
working with null
dotted method calls
dot notation
return
declaring methods
if-else-if statements
if-else statements
if statements
comparisons

OurComparable Max

static methods
public and private
declaring classes
working with null
dotted method calls
dot notation
assert statements
return
declaring methods
for loops
accessing arrays
logical operators
if statements
comparisons
variable operations
modifying variables
initializing variables
declaring variables

Quicksort Partition (First Value)

static methods
public and private
declaring classes
working with null
return
declaring methods
for loops
accessing arrays
logical operators
if statements
comparisons
variable operations
modifying variables
initializing variables
declaring variables

Return an Exception

static methods
public and private
declaring classes
creating objects
assert statements
return
declaring methods
if-else-if statements
logical operators
if-else statements
if statements
comparisons

List Unique Items

static methods
public and private
declaring classes
type parameters
import statements
dotted method calls
dot notation
nested loops
return
declaring methods
continue
break
for loops
if statements
comparisons
variable operations
modifying variables
initializing variables
declaring variables

Inheritance

Simple Person Inheritance

calling super
extending classes
final fields
public and private
writing getters
constructors
declaring classes
Strings
assert statements
return
declaring methods
comparisons
modifying variables

Polymorphism

Polymorphic Greeter

instanceof type checking
static methods
public and private
declaring classes
working with null
dotted method calls
dot notation
Strings
return
declaring methods
if-else-if statements
if statements
arithmetic

Polymorphic Orderer

instanceof type checking
static methods
public and private
declaring classes
working with null
dotted method calls
dot notation
Strings
return
declaring methods
if-else-if statements
if statements
arithmetic

Restaurant Equality

instanceof type checking
final fields
public and private
constructors
declaring classes
working with null
dotted variable accesses
dotted method calls
dot notation
Strings
assert statements
return
declaring methods
logical operators
if statements
comparisons
modifying variables

Course Equality

instanceof type checking
this keyword
final fields
public and private
constructors
declaring classes
working with null
dotted variable accesses
dotted method calls
dot notation
Strings
assert statements
return
declaring methods
logical operators
if statements
comparisons
modifying variables

Catching Exceptions

Multi Catcher

try-catch
static methods
public and private
declaring classes
dotted method calls
dot notation
return
declaring methods
while loops

Catching Exceptions

try-catch
static methods
public and private
declaring classes
dotted method calls
dot notation
return
declaring methods

Test Array Max

try-catch
static methods
public and private
declaring classes
working with null
dotted method calls
dot notation
assert statements
declaring methods
comparisons

Throwing Exceptions

Escape a Maze

throwing exceptions
static methods
public and private
declaring classes
working with null
dotted method calls
dot notation
creating objects
nested loops
return
declaring methods
while loops
logical operators
if statements
comparisons

OurComparable Is Sorted

throwing exceptions
static methods
public and private
declaring classes
type parameters
import statements
working with null
dotted method calls
dot notation
creating objects
return
declaring methods
for loops
logical operators
if statements
comparisons
arithmetic
variable operations
modifying variables
initializing variables
declaring variables

Pentagon Shape

throwing exceptions
instanceof type checking
calling super
extending classes
final fields
public and private
constructors
declaring classes
dotted variable accesses
dotted method calls
dot notation
creating objects
return
declaring methods
logical operators
if statements
comparisons
arithmetic
modifying variables

Restaurant Hash Code

throwing exceptions
final fields
public and private
constructors
declaring classes
import statements
working with null
dotted method calls
dot notation
creating objects
Strings
return
declaring methods
logical operators
if statements
comparisons
modifying variables

Guessing Game With Tries

throwing exceptions
final fields
public and private
writing getters
constructors
declaring classes
creating objects
return
declaring methods
logical operators
if-else statements
if statements
comparisons
variable operations
modifying variables

Isomorphic Strings With Map

throwing exceptions
static methods
public and private
declaring classes
type parameters
boxing classes
import statements
working with null
dotted method calls
dot notation
creating objects
Strings
nested conditionals
return
declaring methods
for loops
logical operators
if-else statements
if statements
comparisons
variable operations
modifying variables
initializing variables
declaring variables

Cities Are Connected

throwing exceptions
final fields
public and private
constructors
declaring classes
type parameters
import statements
working with null
dotted method calls
dot notation
creating objects
Strings
enhanced for loop
nested loops
return
declaring methods
for loops
accessing arrays
using arrays
if statements
comparisons
variable operations
modifying variables
initializing variables
declaring variables

PingPonger Class

throwing exceptions
public and private
constructors
declaring classes
dotted method calls
dot notation
creating objects
Strings
return
declaring methods
if-else-if statements
logical operators
if-else statements
if statements
modifying variables

Isomorphic Strings Without Map

throwing exceptions
static methods
public and private
declaring classes
working with null
dotted method calls
dot notation
creating objects
Strings
nested loops
nested conditionals
return
declaring methods
continue
for loops
accessing arrays
using arrays
logical operators
if-else statements
if statements
comparisons
arithmetic
variable operations
modifying variables
initializing variables
declaring variables

Restaurant Capacity Manager

checked exceptions
throwing exceptions
final fields
public and private
constructors
declaring classes
creating objects
return
declaring methods
if statements
comparisons
variables assignment
arithmetic
modifying variables

Using Interfaces

Insertion Sort

using the Comparable interface
throwing exceptions
static methods
public and private
declaring classes
working with null
dotted method calls
dot notation
creating objects
nested loops
return
declaring methods
break
for loops
accessing arrays
if-else statements
if statements
comparisons
arithmetic
variable operations
modifying variables
initializing variables
declaring variables

BinarySearcher Array

using the Comparable interface
throwing exceptions
static methods
public and private
declaring classes
working with null
dotted method calls
dot notation
creating objects
return
declaring methods
while loops
if-else-if statements
logical operators
if-else statements
if statements
comparisons
arithmetic
modifying variables
initializing variables
declaring variables

Implementing Interfaces

Last Odd Interface

implementing interfaces
public and private
declaring classes
return
declaring methods
comparisons
arithmetic
modifying variables

Running Total Interface

implementing interfaces
public and private
declaring classes
return
declaring methods
variables assignment
modifying variables

String Length Comparable Parameterized

implementing interfaces
using the Comparable interface
final fields
public and private
constructors
declaring classes
type parameters
working with null
dotted variable accesses
dotted method calls
dot notation
Strings
assert statements
return
declaring methods
if-else-if statements
if-else statements
if statements
comparisons
modifying variables

Both Greater Comparable

implementing interfaces
using the Comparable interface
final fields
public and private
constructors
declaring classes
type parameters
dotted variable accesses
dot notation
return
declaring methods
if-else-if statements
logical operators
if-else statements
if statements
comparisons
modifying variables

Anonymous Classes

Bracket an Anonymous Class

anonymous classes
static methods
public and private
declaring classes
creating objects
return
declaring methods

String Both Ways Anonymous Class

anonymous classes
throwing exceptions
static methods
public and private
declaring classes
working with null
dotted method calls
dot notation
creating objects
Strings
return
declaring methods
for loops
accessing arrays
using arrays
if statements
comparisons
arithmetic
variable operations
modifying variables
initializing variables
declaring variables

Lambda Expressions

Adder with Lambda

lambda expressions
static methods
public and private
declaring classes
return
declaring methods
arithmetic

Subtracter with Lambda

lambda expressions
static methods
public and private
declaring classes
return
declaring methods
arithmetic

Linked Lists

SimpleLinkedList set

inner classes
public and private
writing setters
writing getters
constructors
declaring classes
working with null
dotted variable accesses
dot notation
creating objects
assert statements
return
declaring methods
for loops
accessing arrays
logical operators
if statements
comparisons
arithmetic
variable operations
modifying variables
initializing variables
declaring variables

SimpleLinkedList add

inner classes
public and private
writing setters
writing getters
constructors
declaring classes
working with null
dotted variable accesses
dot notation
creating objects
assert statements
return
declaring methods
for loops
accessing arrays
logical operators
if-else statements
if statements
comparisons
variables assignment
arithmetic
variable operations
modifying variables
initializing variables
declaring variables

Recursion

Mergesort

throwing exceptions
extending classes
public and private
declaring classes
working with null
creating objects
return
declaring methods
if statements
comparisons
arithmetic

Recursive Factorial

throwing exceptions
static methods
public and private
declaring classes
creating objects
return
declaring methods
logical operators
if statements
comparisons
arithmetic

Recursive Range Sum

throwing exceptions
static methods
public and private
declaring classes
creating objects
return
declaring methods
logical operators
if statements
comparisons
arithmetic

Trees and Recursion

Binary Tree Size

static methods
public and private
declaring classes
type parameters
import statements
working with null
dotted method calls
dot notation
return
declaring methods
if statements
comparisons
arithmetic

BinaryTree Negative Sum

static methods
public and private
declaring classes
type parameters
boxing classes
import statements
working with null
dotted method calls
dot notation
return
declaring methods
if-else statements
if statements
comparisons
arithmetic

BinaryTree Count Equal Children

static methods
public and private
declaring classes
type parameters
import statements
working with null
dotted method calls
dot notation
return
declaring methods
logical operators
if statements
comparisons
arithmetic
modifying variables
initializing variables
declaring variables

BinaryTree to Map

throwing exceptions
static methods
public and private
declaring classes
type parameters
boxing classes
import statements
working with null
dotted method calls
dot notation
creating objects
return
declaring methods
if statements
comparisons
arithmetic
initializing variables
declaring variables

Binary Tree Count Equal to Child

static methods
public and private
declaring classes
import statements
working with null
dotted method calls
dot notation
return
declaring methods
logical operators
if statements
comparisons
arithmetic
modifying variables
initializing variables
declaring variables

BinaryTree Balanced

throwing exceptions
static methods
public and private
declaring classes
import statements
working with null
dotted method calls
dot notation
creating objects
return
declaring methods
logical operators
if statements
comparisons
arithmetic
initializing variables
declaring variables

Binary Tree Search Path

throwing exceptions
static methods
public and private
declaring classes
type parameters
import statements
working with null
dotted method calls
dot notation
creating objects
return
declaring methods
logical operators
if-else statements
if statements
comparisons
initializing variables
declaring variables

Graphs

Undirected Graph Size

throwing exceptions
static methods
public and private
declaring classes
type parameters
boxing classes
import statements
working with null
dotted method calls
dot notation
creating objects
enhanced for loop
return
declaring methods
for loops
logical operators
if statements
comparisons
initializing variables
declaring variables

Unweighted Graph Is Undirected

throwing exceptions
static methods
public and private
declaring classes
type parameters
import statements
working with null
dotted method calls
dot notation
creating objects
enhanced for loop
nested loops
return
declaring methods
for loops
logical operators
if statements
comparisons
declaring variables

Undirected Graph Neighborhood Count

throwing exceptions
static methods
public and private
declaring classes
type parameters
boxing classes
import statements
working with null
dotted method calls
dot notation
creating objects
enhanced for loop
return
declaring methods
for loops
logical operators
if statements
comparisons
arithmetic
variable operations
modifying variables
initializing variables
declaring variables