- 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: HashSet
This Java quiz covers HashSet and its relatives LinkedHashSet and TreeSet. You will predict what add() returns, how sets treat your own classes and records, how set operations work and why changing an element inside a set breaks it.
Domanda di esempio
Domanda 1 di 10What does this print?
import java.util.HashSet;
import java.util.Set;
public class Main {
public static void main(String[] args) {
Set<String> s = new HashSet<>();
System.out.println(s.add("a") + " " + s.add("a") + " " + s.size());
}
}
Mostra la risposta
B. true false 1 add() returns true only when the element was not already in the set. The second a is a duplicate, so it returns false and the size stays 1.
Cosa copre questo quiz
add()returnsfalsefor duplicates- How
equals()andhashCode()define duplicates - Records as set elements
retainAll()and other set operationsHashSetvsLinkedHashSetvsTreeSet
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.