- 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: Method Overloading
This Java quiz tests how the compiler chooses between overloaded methods. You will work through the resolution order (exact match, widening, boxing, varargs), calls with null and char, and the overloads that do not compile.
Domanda di esempio
Domanda 1 di 10What does this print?
public class Main {
static void f(int x) { System.out.println("int"); }
static void f(long x) { System.out.println("long"); }
public static void main(String[] args) {
f(5);
}
}
Mostra la risposta
A. int The literal 5 is an int, so f(int) is an exact match and wins. f(long) would also work through widening, but an exact match is always preferred.
Cosa copre questo quiz
- Exact match and widening of primitives
- Widening beats boxing, boxing beats varargs
- The most specific method and
nullarguments - Overloads are picked from declared (static) types
- What does and does not count as an overload
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.