Script Valley
Java: Complete Language Course
Java Fundamentals/Assessment

Practice & Assessment

Test your understanding of Java Fundamentals

Multiple Choice Questions

5
1

What does the JVM use to run Java programs on different operating systems?

2

What is the result of the Java expression 17 / 5?

3

Which variable declaration causes a compile error in Java?

4

In a switch statement, what happens when a matching case has no break statement?

5

What does continue do inside a for loop?

Coding Challenges

1
1

FizzBuzz 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.

Easy

Mini Project

1

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.

Easy