You are on page 1of 19

12/5/2019 Examen final - Semana 8: INV/PRIMER BLOQUE-CERTIFICACION DE NIVEL TECNOLOGICO-[GRUPO1]

Examen final - Semana 8

Fecha límite 14 de mayo en 23:55 Puntos 80 Preguntas 20


Disponible 11 de mayo en 0:00-14 de mayo en 23:55 4 días Tiempo límite 90 minutos
Intentos permitidos 2

Instrucciones

https://poli.instructure.com/courses/8227/quizzes/31638 1/19
12/5/2019 Examen final - Semana 8: INV/PRIMER BLOQUE-CERTIFICACION DE NIVEL TECNOLOGICO-[GRUPO1]

Volver a realizar la evaluación

Historial de intentos

Intento Tiempo Puntaje

https://poli.instructure.com/courses/8227/quizzes/31638 2/19
12/5/2019 Examen final - Semana 8: INV/PRIMER BLOQUE-CERTIFICACION DE NIVEL TECNOLOGICO-[GRUPO1]

Intento Tiempo Puntaje


ÚLTIMO Intento 1 71 minutos 61.33 de 80

 Las respuestas correctas estarán disponibles del 15 de mayo en 0:00 al 15 de mayo en 23:55.

Calificación para este intento: 61.33 de 80


Presentado 12 de mayo en 22:54
Este intento tuvo una duración de 71 minutos.

Pregunta 1 4 / 4 ptos.

SE TIENE:

1. public class Prueba {

2. public static void main(String[] args) {

3. int aux = 5;

4. if(aux>10)

5. if(aux<15)

6. System.out.print(" [Exitoso el if] ");

7. else

8. System.out.print(" [Falla el if] ");

9. System.out.print(" [Fin] ");

10. }

11. }

AL EJECUTAR, SE IMPRIME:

A. [Exitoso el if] [Falla el if] [Fin]

F. No se imprime nada.

C. [Exitoso el if]

D. [Falla el if] [Fin]

https://poli.instructure.com/courses/8227/quizzes/31638 3/19
12/5/2019 Examen final - Semana 8: INV/PRIMER BLOQUE-CERTIFICACION DE NIVEL TECNOLOGICO-[GRUPO1]

E. [Fin]

B. [Exitoso el if][Fin]

Incorrecto Pregunta 2 0 / 4 ptos.

Which of the following exceptions are not subclasses of


java.lang.RuntimeException? Choose all that apply.

ParseException

NullPointerException

ArithmeticException

ClassNotFoundException

FileNotFoundException

SystemException

IndexOutOfBoundsException

UndeclaredThrowableException

NegativeArraySizeException

https://poli.instructure.com/courses/8227/quizzes/31638 4/19
12/5/2019 Examen final - Semana 8: INV/PRIMER BLOQUE-CERTIFICACION DE NIVEL TECNOLOGICO-[GRUPO1]

Incorrecto Pregunta 3 0 / 4 ptos.

Dado el siguiente código:

class Padre {

private void metodo(String atb) {

System.out.println(atb);

public class Hija extends Padre {

public int metodo(String atb) {

return Integer.parseInt(atb);

public static void main(String[] args) {

Hija obj = new Hija();

System.out.println(obj.metodo("34")+1);

¿Cuál es el resultado al ejecutar?

E. El programa compila pero se lanza una excepción en tiempo de


ejecución.

D. La compilación falla por un overriding ilegal.

A. Se imprime: 34

C. Se imprime: 35

https://poli.instructure.com/courses/8227/quizzes/31638 5/19
12/5/2019 Examen final - Semana 8: INV/PRIMER BLOQUE-CERTIFICACION DE NIVEL TECNOLOGICO-[GRUPO1]

B. Se imprime: 34 + 1

Incorrecto Pregunta 4 0 / 4 ptos.

Which of the following exceptions are subclasses of


java.lang.RuntimeException? Choose all that apply.

IllegalArgumentException

IOException

NullPointerException

SQLException

ArithmeticException

ParseException

SystemException

VirtualMachineError

IndexOutOfBoundsException

https://poli.instructure.com/courses/8227/quizzes/31638 6/19
12/5/2019 Examen final - Semana 8: INV/PRIMER BLOQUE-CERTIFICACION DE NIVEL TECNOLOGICO-[GRUPO1]

FileNotFoundException

Pregunta 5 4 / 4 ptos.

¿UN MÉTODO PUEDE SER PRIVADO Y ABSTRACTO SIMULTÁNEAMENTE?

D. Es perfectamente legal.

A. Solamente si el método también es estático.

C. Únicamente al definirse dentro de una interface.

B. No es posible

Pregunta 6 4 / 4 ptos.

Para proveer un buen encapsulamiento, en una clase se debe

Declarar todos los atributos públicos, y proveer un grupo de métodos


estáticos de acceso.

Declarar todos los atributos estáticos, y proveer un grupo de métodos


finales de acceso.

Declarar todos los atributos privados, y proveer un grupo de métodos


públicos de acceso.

https://poli.instructure.com/courses/8227/quizzes/31638 7/19
12/5/2019 Examen final - Semana 8: INV/PRIMER BLOQUE-CERTIFICACION DE NIVEL TECNOLOGICO-[GRUPO1]

Declarar todos los atributos finales, y proveer un grupo de métodos


privados de acceso.

Pregunta 7 4 / 4 ptos.

¿Cuál es el resultado de ejecutar el siguiente código?

public class DosHilos {

public static class Hilo1 extends Thread {

public void run() {

System.out.print("A");

System.out.print("B");

public static class Hilo2 extends Thread {

public void run() {

System.out.print("1");

System.out.print("2");

public static void main(String[] args) {

new Hilo1().run();

new Hilo2().run();

https://poli.instructure.com/courses/8227/quizzes/31638 8/19
12/5/2019 Examen final - Semana 8: INV/PRIMER BLOQUE-CERTIFICACION DE NIVEL TECNOLOGICO-[GRUPO1]

D. El programa compila y se ejecuta pero no es posible predecir su


resultado.

A. Error de compilación

C. Se imprime AB12

B. Se imprime A1B2

Pregunta 8 4 / 4 ptos.

¿Cuál es el resultado de ejecutar el siguiente código?

public class Ejemplo {

public static void main(String[] args) {

Integer i1 = 129;

Integer i2 = 129;

if(i1 == i2) System.out.println("igualdad uno");

if(i1.equals(i2)) System.out.println("igualdad dos");

C. Se imprime únicamente el mensaje: igualdad uno

E. Se imprimen los mensajes: igualdad uno igualdad dos

D. Se imprime únicamente el mensaje: igualdad dos

B. El código lanza una excepción en tiempo de ejecución

A. El código no compila

https://poli.instructure.com/courses/8227/quizzes/31638 9/19
12/5/2019 Examen final - Semana 8: INV/PRIMER BLOQUE-CERTIFICACION DE NIVEL TECNOLOGICO-[GRUPO1]

Pregunta 9 4 / 4 ptos.

1. Se tiene el siguiente código:

import java.io.*;

import java.util.regex.*;

public class Ejemplo {

public static void main(String[] args) throws IOException {

BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));

String regex = "P[aeiou]o\s*\d*";

Pattern pattern = Pattern.compile(regex);

System.out.println("Ingrese cadena a evaluar: ");

Matcher matcher = pattern.matcher(buf.readLine());

if (matcher.find()) {

String s = String.format("La cadena \"%s\" coincide",

matcher.group());

System.out.println(s);

else {

System.out.println("La cadena no coincide");

¿Cuáles de las siguientes cadenas ingresadas por el usuario cumplen con


la condición del if? (Seleccione 4)

B. Poo

A. Pio 341235

https://poli.instructure.com/courses/8227/quizzes/31638 10/19
12/5/2019 Examen final - Semana 8: INV/PRIMER BLOQUE-CERTIFICACION DE NIVEL TECNOLOGICO-[GRUPO1]

F. Pua 2

C. Paeiouos*d*

E. Pio VI

D. Paos

Pregunta 10 4 / 4 ptos.

SE TIENE:

1. public class Prueba {

2. static int var = 6;

3. public static void main(String[] args) {

4. String cad = "";

5. for (int i = 0; i<3; i++){

6. var++;

7. switch(var){

8. case 7: cad += "7 ";

9. case 8: cad += "8 ";

10. case 9: { cad+= "9 "; break; }

11. default: cad += "none ";

12. case 18: cad += "18 ";

13. }

14. }

15. System.out.println(cad);

16. }

17. static{var++;}

https://poli.instructure.com/courses/8227/quizzes/31638 11/19
12/5/2019 Examen final - Semana 8: INV/PRIMER BLOQUE-CERTIFICACION DE NIVEL TECNOLOGICO-[GRUPO1]

18. }

¿QUÉ SE IMPRIME EN CONSOLA AL EJECUTAR?

G. El programa no se puede ejecutar por fallos de compilación.

A. 8 9 none

C. 8 9 9 none

F. 7 8 9 8 9 9 none 18

E. 7 8 9 9 none 18

B. 7 8 9 none

D. 8 9 9 none 18

Parcial Pregunta 11 1.33 / 4 ptos.

¿CUÁLES DE LAS SIGUIENTES DECLARACIONES SON VÁLIDAS PARA UNA


VARIABLE TIPO "CHAR"? (SELECCIONE 3)

C. char var = '\ufaba';

E. char var = '\u10100';

F. char var = 34;

A. char var = '\'';

B. char var = 'ceba';

D. char var = "x";

G. char var = (char) "x";

https://poli.instructure.com/courses/8227/quizzes/31638 12/19
12/5/2019 Examen final - Semana 8: INV/PRIMER BLOQUE-CERTIFICACION DE NIVEL TECNOLOGICO-[GRUPO1]

Incorrecto Pregunta 12 0 / 4 ptos.

Which of the following statements are correct about exceptions?. Choose


all that apply.

There is not way to avoid execution of finally block.

Error and its subclasses are treated like unchecked exceptions.

All try blocks must have at least one catch block.

RuntimeExceptions are subject to the Catch or Specify requirement.

Throwable objects are instances of any subclass of the Throwable class.

Pregunta 13 4 / 4 ptos.

Se tiene:

class Base {

public void metodo(){ System.out.println("Metodo Padre"); }

class Sub extends Base {

public void metodo(){ System.out.println("Metodo Hija"); }

public class Prueba{

public static void main(String[] args) {

Base obj = new Sub();

https://poli.instructure.com/courses/8227/quizzes/31638 13/19
12/5/2019 Examen final - Semana 8: INV/PRIMER BLOQUE-CERTIFICACION DE NIVEL TECNOLOGICO-[GRUPO1]

llamaMetodo(obj);

public static void llamaMetodo(Base b){

b.metodo();

¿Qué se obtiene al ejecutar el programa?

D. Se lanza una excepción en tiempo de ejecución

A. Se imprime: Metodo Padre

B. Se imprime: Metodo Hija

C. Error de compilación

Pregunta 14 4 / 4 ptos.

SE TIENE EL SIGUIENTE PROGRAMA:

1. public class Prueba {

2. public static void main(String[] args) {

3. int x = 7;

4. assert (++x > 9);

5. assert (++x > 16) : "Hola mundo!";

6. assert (x > 20) : x = 12;

7. assert (x == 32) : metodo();

8. assert (x == 36) : new Prueba();

9. }

10. static void metodo() { }


https://poli.instructure.com/courses/8227/quizzes/31638 14/19
12/5/2019 Examen final - Semana 8: INV/PRIMER BLOQUE-CERTIFICACION DE NIVEL TECNOLOGICO-[GRUPO1]

11. }

¿CUÁLES DE LAS SIGUIENTES AFIRMACIONES SON VERDADERAS?


(SELECCIONE TODAS LAS QUE APLICAN)

D. La compilación falla en la línea 6.

F. La compilación falla en la línea 8.

E. La compilación falla en la línea 7.

A. El código compila.

B. La compilación falla en la línea 4.

C. La compilación falla en la línea 5.

Pregunta 15 4 / 4 ptos.

EN EL SIGUIENTE CÓDIGO SE PUEDE OBSERVAR UN CLARO EJEMPLO DE:

1. public class Pregunta{


2. public int sumar (int x, int y){
3. return x + y;
4. }
5. public void sumar (int x, int y){
6. System.out.println("Suma = " + (x + y));
7. }
8. }

C. Descuido del programador (El código no compila)

A. Sobrescritura de métodos (Overriding)

B. Sobrecarga de métodos (Overloading)

https://poli.instructure.com/courses/8227/quizzes/31638 15/19
12/5/2019 Examen final - Semana 8: INV/PRIMER BLOQUE-CERTIFICACION DE NIVEL TECNOLOGICO-[GRUPO1]

Pregunta 16 4 / 4 ptos.

¿QUÉ LÍNEAS, INSERTADAS INDEPENDIENTE EN EL PUNTO MARCADO,


REPRESENTAN UNA SOBRESCRITURA DEL MÉTODO Y, POR TANTO,
COMPILAN SIN ERROR?
1. class Super{
2. void metodo() throws IllegalArgumentException{
3. }
4. }
5. public class Hija extends Super{
6. //inserte aqui el metodo sobrescrito
7. }

B. void metodo() throws IllegalArgumentException,FileNotFoundException


{}

D. void metodo() throws IllegalArgumentException,RuntimeException { }

C. void metodo() throws RuntimeException { }

E. private void metodo() { }

A. public void metodo() throws IllegalArgumentException { }

Pregunta 17 4 / 4 ptos.

Dado el siguiente código:

1. public class Prueba {

2. public static void main(String[] args) {

3. System.out.println("Valor: " + (3 + 7) + 5);

4. }

https://poli.instructure.com/courses/8227/quizzes/31638 16/19
12/5/2019 Examen final - Semana 8: INV/PRIMER BLOQUE-CERTIFICACION DE NIVEL TECNOLOGICO-[GRUPO1]

5. }

¿Qué se imprime en consola al ejecutar? (seleccione una respuesta)

E. El programa no se puede ejecutar por errores de compilación

C. Valor: 105

D. Valor: (3 + 7)5

A. Valor: 15

B. Valor: 375

Pregunta 18 4 / 4 ptos.

Se tiene:

public class Prueba {

2. public static void main(String[] args) {

3. int arr[] = {0,4,5,10,2,8};

4. int tamaño = arr.length;

5. int posicion = posMayor(arr, tamaño);

6. System.out.print("El mayor de los "+tamaño+" elementos es: ");

7. System.out.print(arr[posicion]);

8. }

9. public static int posMayor(int []arr, int tam) {

10. int mayor = 0;

11. for(int i = 0; i<tam;i++){

12. mayor = arr[i]>arr[mayor]? i:mayor;

13. arr[i] = 0;

https://poli.instructure.com/courses/8227/quizzes/31638 17/19
12/5/2019 Examen final - Semana 8: INV/PRIMER BLOQUE-CERTIFICACION DE NIVEL TECNOLOGICO-[GRUPO1]

14. }

15. tam = 0;

16. return mayor;

17. }

18. }

¿Qué ocurre al ejecutar?

D. Se imprime: El mayor de los 0 elementos es: 0

B. Se imprime: El mayor de los 6 elementos es: 10

A. Se imprime: El mayor de los 6 elementos es: 0

C. Se imprime: El mayor de los 6 elementos es: 5

Pregunta 19 4 / 4 ptos.

UNA DE LAS SIGUIENTES AFIRMACIONES NO ES CIERTA, SELECCIONE


CUÁL:

D. Aun cuando no se generan excepciones en el bloque try, el bloque


finally se ejecutará.

B. No se puede definir dos bloques finally distintos para un mismo bloque


try

C. Si al producirse una excepción dentro de un bloque try, ninguno de sus


bloques catch la captura, entonces el bloque finally no se ejecutará.

A. Si no se escribe un bloque catch para un try, es obligatorio escribir un


bloque finally.

https://poli.instructure.com/courses/8227/quizzes/31638 18/19
12/5/2019 Examen final - Semana 8: INV/PRIMER BLOQUE-CERTIFICACION DE NIVEL TECNOLOGICO-[GRUPO1]

Pregunta 20 4 / 4 ptos.

SE TIENEN LAS SIGUIENTES DECLARACIONES:

23. double []arr[], arr2;


24. int arr3[][], arr4;

¿CUÁLES DE LAS SIGUIENTES SENTENCIAS SERÍAN LEGALES EN LA LÍNEA 25, ES


DECIR, LUEGO DE LAS DECLARACIONES? (SELECCIONE 3)

B. arr2 = new double[5];

F. arr4 = 0x19;

D. arr2 = new double[3][7];

A. arr = new double[8][3];

C. arr4 = new int[6][7];

E. arr2 = 4.5;

Calificación de la evaluación: 61.33 de 80

https://poli.instructure.com/courses/8227/quizzes/31638 19/19

You might also like