Buscar

What is the purpose of the 'finally' block in the following code? 1. To handle exceptions that may occur during the execution of the code. 2. To c...

What is the purpose of the 'finally' block in the following code?

1. To handle exceptions that may occur during the execution of the code.
2. To close a connection to the database.
3. To open a connection to the database.
4. To insert a new row into the 'Categoria' table with data from a 'Categoria' object.
5. To retrieve data from a database table called 'Categoria'.
a) 1 and 2
b) 2 and 3
c) 2 and 5
d) 3 and 4

Essa pergunta também está no material:

Aula_09 11
19 pág.

Desenvolvimento de Sistemas Centro Universitário UnifacvestCentro Universitário Unifacvest

💡 1 Resposta

User badge image

Ed Verified user icon

A finalidade do bloco 'finally' no código apresentado é a alternativa (b) 2 e 3: fechar uma conexão com o banco de dados. O bloco 'finally' é usado para garantir que um bloco de código seja executado, independentemente de ocorrer uma exceção ou não. No caso apresentado, o bloco 'finally' é usado para fechar a conexão com o banco de dados, garantindo que a conexão seja sempre fechada, mesmo que ocorra uma exceção durante a execução do código.

0
Dislike0

✏️ Responder

SetasNegritoItálicoSublinhadoTachadoCitaçãoCódigoLista numeradaLista com marcadoresSubscritoSobrescritoDiminuir recuoAumentar recuoCor da fonteCor de fundoAlinhamentoLimparInserir linkImagemFórmula

Para escrever sua resposta aqui, entre ou crie uma conta

User badge image

Outros materiais