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

Test

OCAJP7 part 3 - from book

. 20 preguntas

Hacer el test

Preguntas del test (20)

  1. 1Only public and protected constructors are inherited from super class if the subclass is not in the same package.
    1. AVerdadero
    2. BFalso
  2. 2Which constructor is valid in class BlaBla
    1. ABlaBla(BlaBla a)
    2. Bprivate BlaBla()
    3. Cpublic final BlaBla(int i)
    4. Dpublic static BlaBla(char o)
  3. 3Given the following code, which of these constructors can be added to class B without
    causing a compile time error?
    class A{
    int i;
    public A(int x) { this.i = x; }
    }
    class B extends A{
    int j;
    public B(int x, int y) {
    super(x);
    this.j = y;
    }
    }
    1. AB( ) { }
    2. BB(int y ) { j = y; }
    3. CB(int y ) { super(y*2 ); j = y; }
    4. DB(int y ) { i = y; j = y*2; }
    5. EB(int z ) { this(z, z); }
  4. 4Consider the following array definitions:
    int[] array1, array2[];
    int[][] array3;
    int[] array4[], array5[];
    Which of the following are valid statements?
    1. Aarray2 = array3;
    2. Barray2 = array4;
    3. Carray1 = array2;
    4. Darray4 = array1;
    5. Earray5 = array3
  5. 5What will be the result of trying to compile and execute of the following program?
    public class TestClass{
    public static void main(String args[] ){
    int i = 0 ;
    int[] iA = {10, 20} ;
    iA[i] = i = 30 ;
    System.out.println(""+ iA[ 0 ] + " " + iA[ 1 ] + " "+i) ;
    }
    }
    1. AIt will throw ArrayIndexOutofBoundsException at Runtime.
    2. BCompile time Error.
    3. CIt will prints 10 20 30
    4. DIt will prints 30 20 30
    5. EIt will prints 0 20 30
  6. 6What will the following program print?
    class Test{
    public static void main(String[] args){
    int i = 4;
    int ia[][][] = new int[i][i = 3][i];
    System.out.println( ia.length + ", " + ia[0].length+", "+ ia[0][0].length);
    }
    }
    1. AIt will not compile.
    2. B3, 4, 3
    3. C3, 3, 3
    4. D4, 3, 4
    5. E4, 3, 3
  7. 7Consider the following program...
    class ArrayTest{
    public static void main(String[] args){
    int ia[][] = { {1, 2}, null };
    for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++)
    System.out.println(ia[i][j]);
    }
    }
    Which of the following statements are true?
    1. AIt will not compile.
    2. BIt will throw an ArrayIndexOutOfBoundsException at Runtime.
    3. CIt will throw a NullPointerException at Runtime.
    4. DIt will compile and run without throwing any exceptions.
    5. ENone of the above.
  8. 8Consider the following class...
    class Test{
    public static void main(String[ ] args){
    int[] a = { 1, 2, 3, 4 };
    int[] b = { 2, 3, 1, 0 };
    System.out.println( a [ (a = b)[3] ] );
    }
    }
    What will it print when compiled and run ?
    1. AIt will not compile.
    2. BIt will throw ArrayIndexOutOfBoundsException when run.
    3. CIt will print 1.
    4. DIt will print 3.
    5. EIt will print 4
    6. FIt will print 0
  9. 9Given the following program, which statements are true?
    // Filename: TestClass.java
    public class TestClass{
    public static void main(String args[]){
    A[] a, a1;
    B[] b;
    a = new A[10]; a1 = a;
    b = new B[20];
    a = b; // 1
    b = (B[]) a; // 2
    b = (B[]) a1; // 3
    }
    }
    class A { }
    class B extends A { }
    1. ACompile time error at line 3.
    2. BThe program will throw a java.lang.ClassCastException at the line labelled 2 when run.
    3. CThe program will throw a java.lang.ClassCastException at the line labelled 3 when run.
    4. DThe program will compile and run if the (B[ ] ) cast in the line 2 and the whole line 3 is removed.
  10. 10Which of these statements are true?
    1. AIf a RuntimeException is not caught, the method will terminate and normal
      execution of the thread will resume.
    2. BAn overriding method must declare that it throws the same exception classes as the
      method it overrides.
    3. CThe main method of a program can declare that it throws checked exceptions.
    4. DA method declaring that it throws a certain exception class may throw instances of
      any subclass of that exception class.
    5. Efinally blocks are executed if and only if an exception gets thrown while inside the
      corresponding try block.

Información

Descripción
Z książki.
Autor
. .
Idioma
English
Visitas
144
Etiquetas
javaocajp7
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?