Buscar

AVALIANDO APRENDIZADO 4

Prévia do material em texto

19/11/2020 Estácio: Alunos
https://simulado.estacio.br/alunos/?user_cod=2367400&matr_integracao=201903414271 1/4
 
 
Disc.: PROGRAMAÇÃO I 
Aluno(a): LUCAS MESQUITA MENDONÇA Matríc.: 201903414271
Acertos: 0,3 de 0,5 12/11/2020 (Finaliz.)
Acerto: 0,0 / 0,1
Analise o código abaixo e diga o que será exibido na tela?
 
public class TesteThrow {
 static int testeT(char c) throws Exception {
 if (c >= '0' & c <= '9') {
 return c - '0';
 }
 if (c >= 'A' & c <= 'F') {
 return c - 'A' + 10;
 }
 if (c >= 'a' & c <= 'f') {
 return c - 'a' + 10;
 }
 throw new Exception("caractere nao e hexadecimal!");
 }
 public static void main(String[] arg) throws Exception {
 int qa = testeT('!');
 System.out.println("Tudo ok! iniciou com:" + qa);
 }
}
 Exception in thread "main" java.lang.Exception: caractere nao e hexadecimal!
Tudo ok! i iniciou com:10
 Exception in thread "main" javaException: caractere nao e hexadecimal!
caractere nao e hexadecimal!
Tudo ok! i iniciou com:0
Respondido em 12/11/2020 09:29:14
 
 
Compare com a sua resposta:
Acerto: 0,1 / 0,1
Uma exceção é lançada usando-se que palavra chave?
else
 Questão1
 Questão2
https://simulado.estacio.br/alunos/inicio.asp
javascript:voltar();
19/11/2020 Estácio: Alunos
https://simulado.estacio.br/alunos/?user_cod=2367400&matr_integracao=201903414271 2/4
switch
for
if
 throw
Respondido em 12/11/2020 09:24:42
 
 
Compare com a sua resposta:
Acerto: 0,1 / 0,1
Analise o código abaixo e diga o que irá ser exibido para o usuario:
int i= Integer.parseInt("oito");
 System.out.println(i);
0
 Irá gerar um erro.
8
oito
8oito
Respondido em 12/11/2020 09:40:43
 
 
Compare com a sua resposta:
Acerto: 0,1 / 0,1
Na linguagem Java, a sintaxe correta de um bloco de controle de exceção é:
if (TipoExcecao) { // código a ser executado } else { // tratamento da exceção }
 try { // código a ser executado } catch (TipoExcecao nomeExcecao) { // tratamento da exceção }
switch (nomeExcecao){ default: // código a ser executado break; case TipoExcecao: // tratamento da exceção
break; }
try { // código a ser executado } except { // tratamento da exceção }
try { // código a ser executado } catch (nomeExcecao: TipoExcecao) { // tratamento da exceção }
Respondido em 12/11/2020 09:34:42
 
 
Compare com a sua resposta:
Acerto: 0,0 / 0,1
Analise os códigos abaixo e diga qual está fazendo adeclaraçãpo de throws de forma correta.
package prova;
import java.io.*;
class Prova { 
 public static void main(String args[]) throw IOException{
 FileInputStream fis = null;
 fis = new FileInputStream("C:\\Documentos\\minhaProva.txt"); 
 int i; 
 while(( i = fis.read() ) != -1) 
 { 
 System.out.print((char)i); 
 } 
 Questão3
 Questão4
 Questão5
19/11/2020 Estácio: Alunos
https://simulado.estacio.br/alunos/?user_cod=2367400&matr_integracao=201903414271 3/4
 fis.close(); 
 }
}
 package prova;
import java.io.*;
class Prova { 
 public static void main(String args[]) throws IOException{
 FileInputStream fis = null;
 fis = new FileInputStream("C:\\Documentos\\minhaProva.txt"); 
 int i; 
 while(( i = fis.read() ) != -1) 
 { 
 System.out.print((char)i); 
 } 
 fis.close(); 
 }
}
 package prova;
import java.io.*;
class Prova { 
 public static void main(String args[]) IOException{
 FileInputStream fis = null;
 fis = new FileInputStream("C:\\Documentos\\minhaProva.txt"); 
 int i; 
 while(( i = fis.read() ) != -1) 
 { 
 System.out.print((char)i); 
 } 
 fis.close(); 
 }
}
package prova;
import java.io.*;
class Prova { 
 public static void main(String args[]) Throws IOException{
 FileInputStream fis = null;
 fis = new FileInputStream("C:\\Documentos\\minhaProva.txt"); 
 int i; 
 while(( i = fis.read() ) != -1) 
 { 
 System.out.print((char)i); 
 } 
 fis.close(); 
 }
}
package prova;
import java.io.*;
class Prova { 
 public static void main(String args[]) throws{
 FileInputStream fis = null;
 fis = new FileInputStream("C:\\Documentos\\minhaProva.txt"); 
 int i; 
 while(( i = fis.read() ) != -1) 
 { 
 System.out.print((char)i); 
 } 
 fis.close(); 
 }
}
Respondido em 12/11/2020 09:34:02
 
 
Compare com a sua resposta:
javascript:abre_colabore('37893','213230847','4303306365');
19/11/2020 Estácio: Alunos
https://simulado.estacio.br/alunos/?user_cod=2367400&matr_integracao=201903414271 4/4

Continue navegando