¡GoConqr estrena diseño! Cuéntanos qué te parece.

Test

Test de DSE

Jorge Enrique Macías Garza 11 preguntas

Hacer el test

Preguntas del test (11)

  1. 1Which of the following statements are true?
    1. AAn class is a blueprint for a object.
    2. BAn object and a class are exactly the same.
    3. CAn object is an instance of a class.
    4. DAn attribute cannot be a reference to another object.
  2. 2Given:
    class X {
    String str = "default";
    X(String s) {
    str = s;
    }
    void print() {
    System.out.println(str);
    }
    public static void main(String[] args) {
    new X("hello").print();
    }
    }
    What is the result?
    1. Ahello
    2. Bdefault
    3. CCompilation fails
    4. DThe program prints nothing
  3. 3Which two will compile, and can be run successfully using the command: java Fred1 hello walls. (Choose two)
    1. Aclass Fred1{
      public static void main (String args)
      { System.out.println(args[1]);}}
    2. Bclass Fred1{
      public static void main (String [] args)
      { System.out.println(args[2]);}}
    3. Cclass Fred1 {
      public static void main (String [] args)
      { System.out.println (args);}}
    4. Dclass Fred1 {
      public static void main (String [] args)
      { System.out.println (args [1]);}}
  4. 4Consider the following program:
    class Point2D {
    private int x, y;
    public Point2D(int x, int y) {
    x = x;
    }
    public String toString() {
    return "[" + x + ", " + y + "]";
    }
    public static void main(String[] args) {
    Point2D point = new Point2D(10, 20);
    System.out.println(point);
    }
    }
    Which one of the following options provides the output of this program when executed?
    1. Apoint
    2. BPoint
    3. C[0, 0]
    4. D[10, 0]
    5. E[10, 20]
  5. 5Which of the these are valid declarations of the main() method in the order to start the execution of a Java application?
    1. Astatic void main(String [] args){/* … */}
    2. Bpublic static int main(String [] args){/*… */}
    3. Cpublic static void main(String args){/*… */}
    4. Dfinal public static void main(String [] arguments){/*… */}
    5. Epublic int main(String [] args, int argc){/*… */}
    6. Fstatic public void main(String args []){/* … */}
  6. 6Given:
    public static void main(String[] args) {
    double a = 2 + 5 * 6 / 7.0 % 6 + 7 - 9;
    System.out.println(a);
    }
    What is the result?
    1. A-2.0
    2. B30.0
    3. C4.2857
    4. Dcompilation fails
  7. 7What will be result of attempting to compile this class?
    import java.util.*;
    package test;
    public class TestClass {
    public OtherClass oc = new OtherClass();
    }
    class OtherClass {
    int value;
    }
    1. AThe class will fail to compile, since the class OtherClass is used before it is defined.
    2. BThere is no problem with the code.
    3. CThe class will fail to compile, since the class OtherClass must be defined in a file called OtherClass.java
    4. DThe class will fail to compile.
    5. ENone of the above.
  8. 8Given:
    public class SuperLoop3 {
    public static void main(String[] args) {
    int suma = 0;
    for (int i = 0, j = 9, z = 1; i < 4 && j > 0; i++, --j, j--) {
    do {
    suma += i * j % z + 3;
    } while (z++ <= 1);
    }
    System.out.println("suma:: " + suma);
    }
    }
    What is the result?
    1. Asuma:: 22
    2. Bsuma:: 14
    3. Csuma:: 20
    4. Dcompilation fails
  9. 9Given:
    class Test {
    public static void main(String[] args) {
    int var = 3;
    switch (var) {
    case 1:
    try {
    throw new IllegalArgumentException();
    } catch (RuntimeException e) {
    e.printStackTrace();
    }
    default:
    try {
    throw new ArrayIndexOutOfBoundsException();
    } catch (RuntimeException e) {
    e.printStackTrace();
    }
    case 2:
    try {
    throw new ArithmeticException();
    } catch (RuntimeException e) {
    e.printStackTrace();
    }
    }
    }
    }
    What is the result?
    1. Ajava.lang.ArrayIndexOutOfBoundsException at com.bar.Test.main
      and
      java.lang.ArithmeticException at com.bar.Test.main at com.bar.Test.main
    2. Bjava.lang.ArrayIndexOutOfBoundsException at com.bar.Test.main
    3. Cjava.lang.ArithmeticException at com.bar.Test.main
    4. Dcompilation fails
  10. 10Given:
    public class Foo {
    public static void main(String[] args) {
    int a = 10;
    long b = 20;
    short c = 30;
    System.out.println(++a + b++ * c);
    }
    }
    1. A611
    2. B641
    3. C930
    4. D960

Información

Descripción
simulador para segundo parcial de DSE
Idioma
Español
Visitas
84
Valoración
Aún sin valoraciones
Valora este test
Valora este test

Escríbenos

¿Sobre qué es tu mensaje?

¿Qué te parece el nuevo diseño?

¿Te gusta?