Practice
Use each exercise to test one idea.
Every task has a permanent ID and belongs to one lesson. Work in order while following the course, or use this catalogue to return to a topic that needs more practice.
235 exercises5550 points98 hours29 build The Registry
Run the checks in VS Code.
The Layers of Logic extension fetches the task, starter code, and readable checks. Compilation and testing happen on your machine, and your solution is not uploaded.
Some design and explanation tasks still require your own judgement. They are marked honestly instead of being forced through an unreliable automatic score.
Get the extension1.1Why Java ExistsPhase I
ex-1-1-aTrace the JourneyWarm up10 min10 ptsex-1-1-bFind Your Own PlatformWarm up10 min10 ptsex-1-1-cWill It Run?Real work15 min20 ptsex-1-1-dThe 1995 MemoReal work20 min20 pts
1.2JVM, JRE, JDK, and Your First ProgramPhase I
ex-1-2-aProve You Have a JDKWarm up15 min10 ptsex-1-2-bYour First Program, the Slow WayWarm up15 min10 ptsex-1-2-cLook at the BytecodeReal work20 min20 ptsex-1-2-dBreak It On PurposeReal work20 min20 ptsex-1-2-eCompare Tiered Execution With Interpreter-Only ModeHard30 min30 pts
2.1Variables, Types, Literals, KeywordsPhase II
ex-2-1-aAll Eight, PrintedWarm up15 min10 ptsex-2-1-bWatch an int OverflowReal work20 min20 ptsex-2-1-cSix Broken DeclarationsReal work20 min20 ptsex-2-1-dThe Registry BeginsReal work25 min25 ptsRegistryex-2-1-eWork Out the Ranges YourselfHard30 min30 pts
2.2How Numbers Live in MemoryPhase II
ex-2-2-aTwo's Complement By HandWarm up20 min15 ptsex-2-2-bInspect Exact Float ValuesReal work20 min20 ptsex-2-2-cTake a Float ApartHard35 min30 ptsex-2-2-dThe Money BugReal work25 min25 ptsRegistry
2.3Type Conversion, Promotion, CastingPhase II
ex-2-3-aPredict Then RunWarm up20 min15 ptsex-2-3-bTrace Narrowing at the Bit LevelReal work25 min20 ptsex-2-3-cConvert Before DivisionReal work20 min20 ptsex-2-3-dWidening Can RoundHard30 min30 pts
3.1OperatorsPhase III
ex-3-1-aRemainder with Negative OperandsWarm up15 min15 ptsex-3-1-bThe Hidden CastReal work20 min20 ptsex-3-1-cProve the Short CircuitReal work20 min20 ptsex-3-1-dTwo Right ShiftsReal work25 min25 ptsex-3-1-eRegistry Flags in One intHard35 min30 ptsRegistry
3.2ConditionalsPhase III
ex-3-2-aString Identity and ContentWarm up20 min15 ptsex-3-2-bFallthrough, Found and FixedReal work20 min20 ptsex-3-2-cComparing Decimals SafelyReal work20 min20 ptsex-3-2-dRegistry Status RulesHard35 min30 ptsRegistry
3.3Loops and Jump StatementsPhase III
ex-3-3-aSame Job, Three LoopsWarm up20 min15 ptsex-3-3-bFour Loops That Never StopReal work25 min20 ptsex-3-3-cEscaping Two Loops at OnceReal work25 min25 ptsex-3-3-dRegistry Roll CallHard35 min30 ptsRegistry
4.1ArraysPhase IV
ex-4-1-aFill It, Walk It, Total ItWarm up20 min15 ptsex-4-1-bOne Array, Two NamesReal work20 min20 ptsex-4-1-cReverse It In PlaceReal work25 min25 ptsex-4-1-dA Grid With Uneven RowsReal work25 min25 ptsex-4-1-eThe Registry Gets a RosterHard35 min30 ptsRegistry
4.2How Arrays WorkPhase IV
ex-4-2-aModel an Array OffsetReal work25 min20 ptsex-4-2-bTest a Locality HypothesisHard35 min30 ptsex-4-2-cBuild a Growable Array ModelHard40 min35 ptsRegistry
5.1Methods, Calls, Recursion, and OverloadingPhase V
ex-5-1-aExtract Three Loops Into One MethodWarm up20 min15 ptsex-5-1-bDraw the StackReal work25 min20 ptsex-5-1-cRecursion, and Where It Runs OutReal work30 min25 ptsex-5-1-dWhich Overload WinsHard30 min30 ptsex-5-1-eThe Registry Grows MethodsReal work30 min25 ptsRegistry
6.1Classes, Objects, and `new`Phase VI
ex-6-1-aFrom Parallel Arrays to ObjectsReal work30 min25 ptsRegistryex-6-1-bDraw What new DoesWarm up20 min15 ptsex-6-1-cMove the Methods InReal work25 min20 ptsex-6-1-dMeasure the OverheadHard30 min30 pts
6.2Constructors, Chaining, `this`Phase VI
ex-6-2-aLose the Default ConstructorWarm up15 min15 ptsex-6-2-bThe Assignment That Does NothingReal work20 min20 ptsex-6-2-cChain Them ProperlyReal work30 min25 ptsRegistryex-6-2-dWhat Runs FirstHard25 min25 pts
6.3Objects in Memory: Size, Copying, PassingPhase VI
ex-6-3-aProve Java Is Call By ValueReal work25 min25 ptsex-6-3-bShallow, Then DeepReal work30 min25 ptsex-6-3-cCount Bytes Under One Layout ModelHard30 min30 ptsex-6-3-dClose Both Reference LeaksHard30 min30 ptsRegistry
6.4`static` and `final`Phase VI
ex-6-4-aOne Copy or ManyWarm up20 min15 ptsex-6-4-bRead Your Own Command LineWarm up20 min15 ptsex-6-4-cFinal Does Not Mean FrozenReal work25 min25 ptsex-6-4-dA Registry That Counts ItselfReal work30 min25 ptsRegistry
7.1Encapsulation, Inheritance, Packages, and `super`Phase VII
ex-7-1-aClose the Fields, Keep the RulesReal work25 min20 ptsex-7-1-bFollow the Constructor ChainReal work25 min25 ptsex-7-1-cIs-A or Has-AReal work25 min25 ptsex-7-1-dThe Registry Gets a FamilyHard40 min35 ptsRegistry
7.2Abstraction, Polymorphism, Abstract Classes, and InterfacesPhase VII
ex-7-2-aDelete Every instanceofReal work30 min25 ptsex-7-2-bSee the Two invokesHard30 min30 ptsex-7-2-cAbstract Class or InterfaceReal work30 min25 ptsex-7-2-dThe Override That Was NotReal work20 min20 pts
7.3Wrapper Types, Autoboxing, and POJOsPhase VII
ex-7-3-aThe Boxed-Identity Trap at 127 and 128Warm up20 min15 ptsex-7-3-bremove(1) Does Not Do What You ThinkReal work20 min20 ptsex-7-3-cMeasure the Boxing TaxReal work25 min25 ptsex-7-3-dThe NullPointerException With No DotReal work25 min25 ptsRegistry
7.4Static Nested, Inner, Local, and Anonymous ClassesPhase VII
ex-7-4-aStatic Nested or InnerReal work25 min20 ptsex-7-4-bThe Leak That Looks TinyHard30 min30 ptsex-7-4-cAnonymous Class, Then LambdaReal work30 min25 ptsex-7-4-dWhy Effectively FinalHard25 min25 pts
8.1Java I/O: Streams, Scanner, BufferedReaderPhase VIII
ex-8-1-aUnwrap the Field KitWarm up20 min15 ptsex-8-1-bMeasure the System CallsHard30 min30 ptsex-8-1-cThe Scanner Skips a QuestionReal work20 min20 ptsex-8-1-dLoad the Registry From a FileReal work35 min30 ptsRegistry
8.2Immutable ClassesPhase VIII
ex-8-2-aBreak It, Then Seal ItReal work30 min25 ptsex-8-2-bChange Means a New ObjectReal work25 min25 ptsex-8-2-cThe Record Is Only Shallowly ImmutableHard30 min30 ptsex-8-2-dAn Immutable RegistryHard40 min35 ptsRegistry
8.3The Object Class: `equals`, `hashCode`, `toString`Phase VIII
ex-8-3-aThree Things That Should WorkWarm up20 min15 ptsex-8-3-bWrite the Pair CorrectlyReal work30 min25 ptsex-8-3-cThe Four CombinationsReal work30 min30 ptsex-8-3-dMake a HashMap Lose Your DataHard30 min35 ptsex-8-3-eRegistry IdentityReal work35 min30 ptsRegistry
8.4EnumsPhase VIII
ex-8-4-aLet the Compiler Find the Missing CaseWarm up20 min15 ptsex-8-4-bEnums Carry DataReal work30 min25 ptsRegistryex-8-4-cNever Store ordinal()Real work25 min25 ptsex-8-4-dBehaviour Per ConstantHard30 min30 pts
8.5Interfaces Deep DivePhase VIII
ex-8-5-aAdd a Method Without Breaking AnyoneReal work25 min20 ptsex-8-5-bThe Diamond, ReopenedReal work25 min25 ptsex-8-5-cFour Ways, Same ObjectReal work30 min30 ptsex-8-5-dA Registry Built on InterfacesHard40 min35 ptsRegistry
9.1Strings: The Pool and ImmutabilityPhase IX
ex-9-1-aFind the Pool BoundaryWarm up20 min15 ptsex-9-1-bMethods That Change NothingWarm up15 min15 ptsex-9-1-cThe Input That Breaks ==Real work20 min20 ptsex-9-1-dBuild Your Own Immutable TextHard35 min30 ptsRegistry
9.2String Methods and StringBuilderPhase IX
ex-9-2-aMeasure the 71xReal work25 min20 ptsex-9-2-bisEmpty, isBlank, and Real InputWarm up20 min15 ptsex-9-2-cSplit Has a Sharp EdgeReal work25 min25 ptsex-9-2-dRegistry Report BuilderReal work30 min25 ptsRegistry
9.3GenericsPhase IX
ex-9-3-aWatch the Cast FailWarm up20 min15 ptsex-9-3-bA Pair That Holds Two TypesReal work25 min25 ptsex-9-3-cBound It So You Can Use ItReal work25 min25 ptsex-9-3-dProve Erasure YourselfHard30 min30 pts
9.4Wildcards: `extends` and `super`Phase IX
ex-9-4-aBreak It If Java Let YouReal work20 min20 ptsex-9-4-bRead With extendsReal work25 min25 ptsex-9-4-cWrite With superReal work25 min25 ptsex-9-4-dPick the Right SignatureHard30 min30 ptsRegistry
10.1The Collections FrameworkPhase X
ex-10-1-aProve the Trade Is UnavoidableReal work25 min20 ptsex-10-1-bSwap the ImplementationWarm up20 min15 ptsex-10-1-cMap Is Not a CollectionReal work20 min20 ptsex-10-1-dRegistry, Rebuilt on CollectionsReal work35 min30 ptsRegistry
10.2Iterable and the IteratorPhase X
ex-10-2-aMeasure the 806 MillisecondsReal work25 min20 ptsex-10-2-bThe Exception That Sometimes Does Not FireReal work25 min25 ptsex-10-2-cMake Your Own Class Work With For-EachReal work30 min25 ptsRegistryex-10-2-dWalk Everything With One MethodReal work20 min20 pts
10.3The Collection InterfacePhase X
ex-10-3-aThe remove Overload, AgainReal work20 min20 ptsex-10-3-bThe Bulk Methods Replace LoopsWarm up20 min15 ptsex-10-3-cThe Boolean add Actually Means SomethingWarm up20 min15 ptsex-10-3-dMethods That Exist and ThrowReal work20 min20 pts
10.4List: ArrayList, LinkedList, Vector, StackPhase X
ex-10-4-aTest the FolkloreReal work30 min25 ptsex-10-4-bBreak a Stack From the BottomReal work25 min25 ptsex-10-4-csubList Is a WindowReal work20 min20 ptsex-10-4-dChoose For a Real WorkloadHard30 min30 ptsRegistry
10.5Set and Map: Inside HashMapPhase X
ex-10-5-aBuild a Hash Set From ScratchHard40 min35 ptsex-10-5-bMeasure a Bad hashCodeReal work25 min25 ptsex-10-5-cWatch the Spreading WorkReal work25 min20 ptsex-10-5-dThe Vanishing Entry, For RealHard30 min30 ptsRegistryex-10-5-eHashSet, LinkedHashSet, TreeSetReal work25 min20 pts
10.6Map Methods, EnumMap, and the Rest of the FamilyPhase X
ex-10-6-aOne Line Instead of FiveWarm up20 min15 ptsex-10-6-bWhat EnumMap Actually Buys YouReal work25 min20 ptsex-10-6-cWhen == Is the Right AnswerReal work25 min25 ptsex-10-6-dTreeMap Answers Questions HashMap CannotReal work25 min25 ptsRegistry
10.7Queue, Deque, and PriorityQueuePhase X
ex-10-7-aFour Names, Two OperationsWarm up20 min15 ptsex-10-7-bA PriorityQueue Is Not SortedReal work25 min25 ptsex-10-7-cThe Heap Lives in an ArrayHard35 min30 ptsex-10-7-dThe Registry Triage QueueReal work30 min25 ptsRegistry
10.8Comparable, Comparator, and SortingPhase X
ex-10-8-aFour Things That Refuse to WorkWarm up20 min15 ptsex-10-8-bThe Subtraction That OverflowsReal work20 min20 ptsex-10-8-cBuild Comparators Without Writing OneReal work25 min25 ptsex-10-8-dWhen compareTo Disagrees With equalsHard30 min30 ptsex-10-8-eRegistry Reports, Sorted Every WayReal work30 min25 ptsRegistry
11.1Lambdas and Functional InterfacesPhase XI
ex-11-1-aThree Orders, One ClassWarm up20 min15 ptsex-11-1-bCount the Class FilesReal work20 min20 ptsex-11-1-cMake Something a Lambda Cannot BeReal work25 min25 ptsex-11-1-dThe Variable That Will Not Sit StillHard25 min25 pts
11.2Method References and the Four ShapesPhase XI
ex-11-2-aName the ShapeWarm up20 min15 ptsex-11-2-bThe One That Reads WrongReal work25 min25 ptsex-11-2-cTwo Names, Two AnswersReal work20 min20 ptsex-11-2-dMeasure the BoxingHard30 min30 pts
11.3Streams, and When the Work HappensPhase XI
ex-11-3-aProve Nothing RanWarm up15 min15 ptsex-11-3-bCount What the Filter SeesReal work20 min20 ptsex-11-3-cThe Same Job, Both WaysReal work25 min25 ptsex-11-3-dUse It TwiceReal work20 min20 pts
11.4The Operations, and What collect Really DoesPhase XI
ex-11-4-aSort Them YourselfWarm up20 min15 ptsex-11-4-bThe Duplicates That Would Not GoReal work25 min25 ptsex-11-4-cOne Line Instead of FifteenReal work30 min30 ptsex-11-4-dWhere You Put limit Changes EverythingHard25 min30 pts
11.5Optional, and the Habit It Is Trying to BreakPhase XI
ex-11-5-aWatch the Fallback RunReal work20 min20 ptsex-11-5-bFlatten the Four IfsReal work25 min25 ptsex-11-5-cEvery Way to Make It WrongReal work25 min25 ptsex-11-5-dOptionals Into StreamsHard25 min25 pts
11.6Parallel Streams and the Primitive OnesPhase XI
ex-11-6-aFind Where Parallel Starts WinningReal work30 min25 ptsex-11-6-bLose Sixty Thousand NumbersHard25 min30 ptsex-11-6-cBoxing, One More TimeReal work25 min25 ptsex-11-6-dSources That Refuse to SplitHard25 min30 pts
12.1Exceptions, Errors, and the Stack TracePhase XII
ex-12-1-aRead the Trace BackwardsWarm up20 min15 ptsex-12-1-bThe Return That Ate an ExceptionReal work25 min25 ptsex-12-1-cClose Them in the Right OrderReal work25 min25 ptsex-12-1-dErrors Are Not YoursHard25 min25 pts
12.2Checked, Unchecked, and Exceptions of Your OwnPhase XII
ex-12-2-aFind the Dividing LineWarm up20 min15 ptsex-12-2-bLose the Cause, Lose the TraceReal work25 min25 ptsex-12-2-cAn Exception Worth CatchingReal work30 min30 ptsex-12-2-dChecked Exceptions Meet LambdasHard30 min30 pts
13.1Where Everything Actually LivesPhase XIII
ex-13-1-aMeasure the Boxing, In MegabytesReal work25 min25 ptsex-13-1-bTwo Ways to Run OutReal work20 min20 ptsex-13-1-cWhere Does the Literal LiveReal work25 min25 ptsex-13-1-dA Thread Costs a MegabyteHard25 min30 pts
13.2What Makes an Object GarbagePhase XIII
ex-13-2-aCollect a RingReal work25 min25 ptsex-13-2-bWeak, Soft, and NeitherReal work25 min25 ptsex-13-2-cLeak On PurposeHard30 min30 ptsex-13-2-dWatch It CollectHard30 min30 pts
14.1What a Thread Actually IsPhase XIV
ex-14-1-aCount the Threads You Did Not StartWarm up15 min15 ptsex-14-1-brun() Is Not start()Warm up20 min20 ptsex-14-1-cTwo Stacks, One HeapReal work25 min25 ptsex-14-1-dWaiting Is Not WorkingReal work25 min25 pts
14.2Two Ways to Make One, and Six StatesPhase XIV
ex-14-2-aSpend Your Only SuperclassWarm up20 min15 ptsex-14-2-bCatch a Thread in Every StateReal work30 min30 ptsex-14-2-cA Worker Dies QuietlyReal work25 min25 ptsex-14-2-dJoin, or Read NothingReal work25 min25 pts
14.3Asking a Thread to StopPhase XIV
ex-14-3-aThe Loop That Never NoticesReal work20 min20 ptsex-14-3-bThe Empty Catch That Erased a RequestReal work25 min25 ptsex-14-3-cThe Shutdown That Actually WorksHard30 min30 ptsex-14-3-dTwo Methods, One Letter ApartReal work20 min20 pts
14.4Three Ways Two Threads Break One FieldPhase XIV
ex-14-4-aFive Runs, Five Wrong AnswersWarm up20 min20 ptsex-14-4-bThe Write Nobody SawReal work25 min25 ptsex-14-4-cWhat volatile Cannot DoReal work20 min25 ptsex-14-4-dRebuild the Parallel Stream FailureHard30 min30 pts
14.5The Lock Every Object Already HasPhase XIV
ex-14-5-aTwo Keys, No ProtectionReal work25 min25 ptsex-14-5-bDeadlock in Ten LinesReal work25 min25 ptsex-14-5-cLock Something Nobody Else Can ReachReal work25 min25 ptsex-14-5-dHold It for Less TimeHard30 min30 pts
14.6Waiting for Something to HappenPhase XIV
ex-14-6-aSleeping Inside a LockReal work20 min20 ptsex-14-6-bBreak It With an ifReal work25 min25 ptsex-14-6-cThe Notification That Arrived Too EarlyHard25 min30 ptsex-14-6-dThen Throw It All AwayReal work25 min25 pts
14.7Locks You Can Give Up OnPhase XIV
ex-14-7-aGive Up on a LockReal work25 min25 ptsex-14-7-bFind Where ReadWriteLock Starts WinningHard30 min30 ptsex-14-7-cWake Only the Right GroupHard30 min30 ptsex-14-7-dThe Unlock That Never RanReal work20 min20 pts
14.8Counting Without a LockPhase XIV
ex-14-8-aFix the Counter Four WaysReal work30 min30 ptsex-14-8-bWrite incrementAndGet YourselfReal work25 min25 ptsex-14-8-cAtomic on One Field Is Not EnoughHard25 min30 ptsex-14-8-dBuild a Lock-Free StackHard30 min30 pts
14.9The Value Came BackPhase XIV
ex-14-9-aChange It and Change It BackReal work25 min25 ptsex-14-9-bCorrupt Your Own StackHard30 min30 ptsex-14-9-cCount the Wasted WorkReal work25 min25 ptsex-14-9-dRead Somebody Else's Lock-Free CodeHard30 min25 pts
14.10Stop Making ThreadsPhase XIV
ex-14-10-aFifty Tasks, Two ThreadsWarm up20 min20 ptsex-14-10-bThe Exception in the EnvelopeReal work25 min25 ptsex-14-10-cTwo Billion Waiting TasksHard30 min30 ptsex-14-10-dDeadlock a Pool With One TaskHard25 min30 pts
14.11Futures That Do Not Block, and Threads That Are Nearly FreePhase XIV
ex-14-11-aTwo Thousand, Then a MillionReal work25 min25 ptsex-14-11-bStop Waiting for FuturesReal work30 min30 ptsex-14-11-cThe Value Left BehindHard25 min30 ptsex-14-11-dPin the CarrierHard30 min30 pts