Java-Quiz: Primitives & Variables

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.

Leicht 10 Fragen ~5 Minuten Bestanden ab 80% Java 17

Modus wählen

Du spielst als Gast: Melde dich an, damit XP und Serie gespeichert werden.

Beispielfrage

Frage 1 von 10

What does this print?

public class Main {
    public static void main(String[] args) {
        int x = Integer.MAX_VALUE;
        x = x + 1;
        System.out.println(x);
    }
}
Lösung zeigen

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.

Darum geht es in diesem Quiz

  • The primitive types and their fixed sizes
  • Integer overflow and long literals
  • char as a number and double precision
  • Default values of fields vs uninitialized local variables
  • Type inference with var

Häufige Fragen

Brauche ich ein Konto?

Nein. Jeder kann spielen. Mit Anmeldung werden XP, Serie, Abzeichen und Verlauf gespeichert.

Kann ich es wiederholen?

Ja. Dein Bestwert bleibt erhalten, und Fragen und Antworten werden jedes Mal neu gemischt.