- 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: equals() & hashCode()
This Java quiz goes deep into equals() and hashCode(), a favorite interview topic. You will predict how objects behave in a HashSet, catch an equals that overloads instead of overrides, and meet the Integer cache and records.
Domanda di esempio
Domanda 1 di 10Which hashCode() for a class with int fields x and y follows the contract but makes a HashMap with many keys very slow?
Mostra la risposta
C. return 42; A constant hash is legal, since equal objects still get equal hash codes, but every key lands in the same bucket and lookups degrade to scanning. Good hash codes spread different objects out.
Cosa copre questo quiz
- Reference equality vs
equals() - The equals/hashCode contract
- Why HashSet and HashMap need both methods
- Mutable keys and overloaded
equals - The
Integercache and records
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.