- Esecutori
-
Impara
Impara Python Esempi eseguibili, NumPy, pandas e altro Impara l'IA / Machine LearningReti neurali, ML e LLM da zero Impara C e C++ Puntatori, memoria, STL e C++ moderno Impara C#Fondamenti, OOP, LINQ, async ed esercizi .NET Impara MatplotlibGrafici a linee, barre, dispersione e torta con visualizzatori Impara RustOwnership, trait, gestione degli errori e thread Impara GoSlice, interfacce, goroutine e canali Algoritmi Python Ricerca, ordinamento, ricorsione e visualizzazioni O(n) Algoritmi C e C++ Confronta le implementazioni in C e C++ Programmazione per bambini Impara a programmare giocando!
- QuizNuovo
- SfideNuovo
- Per docentiNuovo
- Aggiornamenti
- Offrimi un caffè
Quiz di Java: Type Casting
This Java type casting quiz covers widening and narrowing conversions between primitives and casts between objects. You will predict what casts truncate or overflow, spot code that needs an explicit cast and see when a cast fails at runtime.
Domanda di esempio
Domanda 1 di 10What does this print?
public class Main {
public static void main(String[] args) {
double d = 9.99;
int i = (int) d;
System.out.println(i);
}
}
Mostra la risposta
A. 9 Casting a double to int truncates toward zero, it never rounds. Use Math.round(d) if you want 10.
Cosa copre questo quiz
- Widening conversions vs narrowing casts
- Truncation and overflow when narrowing
- Overflow before widening in
intarithmetic - Rounding with
Math.round - Casting objects and
ClassCastException
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.