- Executores
-
Aprender
Aprender Python Exemplos executáveis, NumPy, pandas e mais Aprender IA / Machine LearningRedes neurais, ML e LLMs do zero Aprender C e C++ Ponteiros, memória, STL e C++ moderno Aprender C#Fundamentos, POO, LINQ, async e exercícios .NET Aprender MatplotlibGráficos de linha, barras, dispersão e pizza com visualizadores Aprender RustOwnership, traits, tratamento de erros e threads Aprender GoSlices, interfaces, goroutines e channels Algoritmos em Python Busca, ordenação, recursão e visualizações O(n) Algoritmos em C e C++ Compare implementações em C e C++ Programação para crianças Aprenda a programar brincando!
- QuizzesNovo
- DesafiosNovo
- Para professoresNovo
- Atualizações
- Me pague um café
Quiz de Java: try, catch & finally
This Java quiz walks through try, catch and finally, including the cases that surprise people, like a return inside finally. You will also trace try-with-resources and see when resources get closed.
Pergunta de exemplo
Pergunta 1 de 10What does this print?
public class Main {
static String test() {
try {
return "try";
} finally {
System.out.print("finally ");
}
}
public static void main(String[] args) {
System.out.println(test());
}
}
Mostrar a resposta
B. finally try The return value is computed first, then finally runs before the method actually returns. So finally is printed inside test(), and try is printed afterwards by main.
O que este quiz cobre
- The order of try, catch, finally and the code after them
finallyafterreturn, andreturninsidefinally- Returning a primitive vs an object from try
- Catch block order and exceptions thrown from catch
- Try-with-resources,
AutoCloseableand close order
Perguntas frequentes
Preciso de uma conta?
Não. Qualquer pessoa pode jogar. Entre para guardar seu XP, sequência, badges e histórico.
Posso refazer?
Pode. Sua melhor nota fica salva, e as perguntas e respostas são embaralhadas a cada vez.