Practice problems

Choose a topic, work through an example, and reveal a hint or worked answer when you’re ready.

Showing 21–40 of 145 problems

Py

Decorators and function wrapping

What value reaches its caller?

Advanced
Py

Context managers and resource cleanup

Does leaving the block still close the file?

Advanced
Py

Async tasks and cancellation

Can the timer waits overlap?

Advanced
Py

Profiling and memory use

Which area is the strongest first candidate for optimization?

Advanced
Jv

Your first Java program

What appears in the console?

Beginner
Jv

Variables and types

Print the number of full pairs and the remaining tickets as two lines. For 5 tickets, there are 2 pairs and 1 ticket left.

Beginner
Jv

Strings and text comparisons

Which comparison checks that their text matches?

Beginner
Jv

Reading and validating console input

What number does parseInt produce after trim?

Beginner
Jv

Conditions and loops

Add only the even numbers from 1 through the input limit, inclusive.

Beginner
Jv

Methods and return values

Add the areas of the listed rectangles. Each pair lists its width and height.

Beginner
Jv

Arrays and ArrayList

Read the last title in each list. If the list has no titles, return "Empty".

Beginner
Jv

Enums and fixed choices

Can a caller assign the unrelated string shipped directly to an enum variable?

Beginner
Jv

Classes and objects

Two counters start independently. Predict both values after calling increment twice on the first counter.

Intermediate
Jv

Constructors and encapsulation

Where should you reject an initial balance of -1?

Intermediate
Jv

Interfaces and polymorphism

What string does this implementation return?

Intermediate
Jv

Generics and type parameters

Why does the compiler flag this line?

Intermediate
Jv

Maps and sets

Which value does get("a") return?

Intermediate
Jv

Exceptions and resource handling

Why does the conversion fail?

Intermediate
Jv

Lambdas and stream pipelines

What values appear in the resulting list?

Intermediate
Jv

Records and value equality

What boolean is produced?

Intermediate