Quiz di Java: 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.

Facile 10 domande ~5 minuti Superato con il 80% Java 17

Scegli una modalità

Stai giocando come ospite: accedi per salvare XP e serie.

Domanda di esempio

Domanda 1 di 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);
    }
}
Mostra la risposta

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.

Cosa copre questo 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

Domande frequenti

Serve un account?

No. Chiunque può giocare. Accedi per salvare XP, serie, badge e cronologia.

Posso rifarlo?

Sì. Il tuo miglior punteggio resta salvato, e domande e risposte vengono mescolate ogni volta.