Шукаєте відповіді та рішення тестів для ANÁLISIS Y DISEÑO DE SOFTWARE 2024/25? Перегляньте нашу велику колекцію перевірених відповідей для ANÁLISIS Y DISEÑO DE SOFTWARE 2024/25 в moodle.uam.es.
Отримайте миттєвий доступ до точних відповідей та детальних пояснень для питань вашого курсу. Наша платформа, створена спільнотою, допомагає студентам досягати успіху!
¿Hay errores de compilación o ejecución en el siguiente código?
import java.util.*;class Punto<T> { private T x, y; public Punto (T x, T y) { this.x = x; this.y = y; } public static void main(String[] args) { Set<Punto<Integer>> lp = new TreeSet<> ( Arrays.asList(new Punto<Integer>(3, 3), new Punto<Integer>(0, 0))); }}
¿Hay errores en la siguiente clase genérica?
class Point<?> { private ? x, y; public Point (? x, ? y) { this.x = x; this.y = y; }}
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) { /*..*/} }}
Отримайте необмежений доступ до відповідей на екзаменаційні питання - встановіть розширення Crowdly зараз!