Practice & Assessment
Test your understanding of Java Fundamentals
Multiple Choice Questions
5What does the JVM use to run Java programs on different operating systems?
What is the result of the Java expression 17 / 5?
Which variable declaration causes a compile error in Java?
In a switch statement, what happens when a matching case has no break statement?
What does continue do inside a for loop?
Coding Challenges
1FizzBuzz with switch expression
Write a program that prints numbers 1 to 100. For multiples of 3 print 'Fizz', for multiples of 5 print 'Buzz', for multiples of both print 'FizzBuzz', otherwise print the number. Use a switch expression on the result of two modulus checks combined. Input: none (hardcoded range). Output: 100 lines to stdout. Constraint: no if-else allowed — use switch expression syntax. Estimated time: 15–20 minutes.
Mini Project
Number Guessing Game CLI
Build a command-line number guessing game. The program picks a random integer between 1 and 100 using Math.random(). The player enters guesses via Scanner. After each guess, print 'Too high', 'Too low', or 'Correct! You guessed it in N attempts.' Track attempt count with a variable. Loop until the player guesses correctly. Use a while loop for the game loop, if-else for feedback, and int/boolean primitives throughout. End with a play-again prompt that restarts or exits based on user input.
