- Executors
-
Learn
Learn Python Runnable examples, NumPy, pandas, and more Learn AI / Machine LearningNeural networks, ML and LLMs from scratch Learn C & C++ Pointers, memory, STL, and modern C++ Learn C#C# basics, OOP, LINQ, async, and .NET exercises Learn MatplotlibLine, bar, scatter and pie charts with live visualizers Learn RustOwnership, traits, error handling, and threads Learn GoSlices, interfaces, goroutines, and channels Python Algorithms Search, sorting, recursion, and visualizers O(n) C & C++ Algorithms Compare algorithms implemented in C and C++ Coding for Kids Learn to code by playing!
- QuizzesNew
- ChallengesNew
- For TeachersNew
- Updates
- Buy me a coffee
Java Primitives & Variables Quiz
This Java quiz checks how well you know the eight primitive types and how variables behave. You will predict output involving overflow, char arithmetic, default values and var, and spot code that does not compile.
Sample question
Question 1 of 10What does this print?
public class Main {
public static void main(String[] args) {
int x = Integer.MAX_VALUE;
x = x + 1;
System.out.println(x);
}
}
Show the answer
B. -2147483648 An int is 32 bits, so adding 1 to Integer.MAX_VALUE silently wraps around to Integer.MIN_VALUE. Java does not throw on integer overflow.
What this quiz covers
- The primitive types and their fixed sizes
- Integer overflow and
longliterals charas a number anddoubleprecision- Default values of fields vs uninitialized local variables
- Type inference with
var
Questions people ask
Do I need an account?
No. Anyone can play. Sign in to keep your XP, streak, badges and history.
Can I retake it?
Yes. Your best score is kept, and the questions and answers are shuffled each time.