Looking for ANÁLISIS Y DISEÑO DE SOFTWARE 2024/25 test answers and solutions? Browse our comprehensive collection of verified answers for ANÁLISIS Y DISEÑO DE SOFTWARE 2024/25 at moodle.uam.es.
Get instant access to accurate answers and detailed explanations for your course questions. Our community-driven platform helps students succeed!
Dadas las siguientes clases:
public class DataException extends Exception {
}
public class CorruptedDataException extends DataException {
}
public class MissingDataException extends DataException {
}
y asumiendo que el siguiente método está definido y accesible:
public void cleanData(String s)
throws MissingDataException, CorruptedDataException {
if (s == null) throw new MissingDataException();
if (s.contains("@")) throw new CorruptedDataException();
}
indica cómo se deben rellenar los espacios subrayados (numerados entre corchetes) para que el siguiente código sea correcto y al ejecutarse imprima “Line 1” y “Line 2”:
public static void main(String[] args) ________[1]_________ {
try {
cleanData( null );
cleanData( "data" );
} _________[2]_________ {
System.out.println( "Line 1" );
} _________[3]_________ {
System.out.println( "Line 2" );
}
}
Dadas las siguientes clases:
public class DataException extends Exception {
}
public class CorruptedDataException extends DataException {
}
y asumiendo que el siguiente método está definido y accesible:
public void cleanData(String s) throws DataException {
if (s == null) throw new DataException();
if (s.contains("@")) throw new CorruptedDataException();
}
indica cómo se deben rellenar los espacios subrayados (numerados entre corchetes) para que el siguiente código sea correcto y al ejecutarse imprima solamente “Line 1”:
public static void main(String[] args) ________[1]_________ {
try {
cleanData( "f@5" );
} _________[2]_________ {
System.out.println( "Line 1" );
} _________[3]_________ {
System.out.println( "Line 2" );
}
}
¿Hay errores en el siguiente código?
class UnderageException extends RuntimeException {
public UnderageException(int age) {
// ...
}
// ...
}
public class CourseRegistry {
public void enroll(int age) {
if (age < 18 ) throw new UnderageException(age);
//...
}
}
¿Hay errores en el siguiente código?
abstract class DataException extends Exception {}class DataFormatException extends DataException {}
class DataWrangler { public boolean check(Data d) throws DataException { /*...*/ } public void ingest() { try { Data md = new Data(); this.check(md); } catch (DataException s) { s.printStackTrace(); } System.out.println(md); }}
¿Hay errores en el siguiente código?
abstract class DataException extends Exception {/*..*/}class DataFormatException extends DataException {/*..*/}class DataWrangler { public boolean check(Data d) throws DataException { if (!d.isWellFormed()) throw new DataFormatException(); return true; } public void ingest(Data md) { try { q.check(md); } catch (DataFormatException s) { /*...*/ } }}
Dada la siguiente clase:
public class DataException extends Exception {
public String toString() { return "Found data fault"; }
}
y asumiendo que el siguiente método está definido y accesible:
public void cleanData(String s) throws DataException {
if ((s == null ) || (
throw new DataException();
}
¿cuál será la salida del siguiente código?
try {
for (String data : Arrays.asList("data", "f@5", "last", null)) {
cleanData( data );
System.out.println(data);
}
}
System.out.println(ex);
}
Indica todos los errores que existen en las siguientes clases:
public class DataException extends Exception {
protected String error;
public DataException(String msg) { error = msg; }
}
public class CorruptedDataException extends DataException {
public String toString() { return super.toString() + ":" + error; }
}
y el siguiente método:
public void cleanData(String s) throws DataException {
if ((s.contains("@"))) throw new DataException();
}
¿Hay errores en el siguiente código? ¿Por qué?
abstract class DataException extends Exception {/*..*/}class DataFormatException extends DataException {/*..*/}
public class DataWrangler { public void clean(Data d) throws DataException { //... } public void ingest(Data md) { try { this.clean(md); } catch (DataException m) { /*..*/ } catch (DataFormatException s) { /*..*/} }}
¿Hay errores en el siguiente código?
class NumberTooLargeException extends Exception { /*..*/}public class Quizz1 { public void method(int a) throws NumberTooLargeException { if (a>1000) throw NumberTooLargeException; }}
¿Cuáles de las siguientes afirmaciones sobre excepciones son ciertas?
Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!