Luis Garcia
Test por , creado hace más de 1 año

Este es un test de prueba para los estudientes que quieren provar sus conocimientos para presentar el examen de certificación de JAVA

129
0
0
Luis Garcia
Creado por Luis Garcia hace alrededor de 7 años
Cerrar

Test de prueba para Examen de certificación

Pregunta 1 de 40

1

Which of these statements are true. Select the two correct answers.

Selecciona una o más de las siguientes respuestas posibles:

  • For each try block there must be at least one catch block defined.

  • A try block may be followed by any number of finally blocks.

  • A try block must be followed by at least one finally or catch block.

  • If both catch and finally blocks are defined, catch block must precede the finally block.

Explicación

Pregunta 2 de 40

1

Name the keyword that makes a variable belong to a class, rather than being defined for each instance of the class. Select the one correct answer.

Selecciona una de las siguientes respuestas posibles:

  • static

  • final

  • abstract

  • native

  • volatile

  • transient

Explicación

Pregunta 3 de 40

1

Which of the following are correct. Select the one correct answer.

Selecciona una de las siguientes respuestas posibles:

  • An import statement, if defined, must always be the first non-comment statement of the file.

  • Private members are accessible to all classes in the same package.

  • An abstract class can be declared as final.

  • Local variables cannot be declared as static

Explicación

Pregunta 4 de 40

1

. What is the result of compiling and running the following program.

public class Test {
public static void main (String[] args){
String str1 = "abc";
String str2 = "def";
String str3 = str1.concat(str2);

str1.concat(str2);
System.out.println(str1);
}
}

Selecciona una de las siguientes respuestas posibles:

  • abc

  • def

  • abcabc

  • abcdef

  • defabc

  • abcdefdef

Explicación

Pregunta 5 de 40

1

Assume that class A extends class B, which extends class C. Also all the three classes implement the method test(). How can a method in a class A invoke the test() method defined in class C (without creating a new instance of class C). Select the one correct answer.

Selecciona una de las siguientes respuestas posibles:

  • test();

  • super.test();

  • super.super.test();

  • ::test();

  • C.test();

  • It is not possible to invoke test() method defined in C from a method in A.

Explicación

Pregunta 6 de 40

1

Which keyword when applied on a method indicates that only one thread should execute the method at a time. Select the one correct answer.

Selecciona una de las siguientes respuestas posibles:

  • transient

  • volatile

  • synchronized

  • native

  • static

  • final

Explicación

Pregunta 7 de 40

1

In which all cases does an exception gets generated. Select the two correct answers.
int i = 0, j = 1;

Selecciona una o más de las siguientes respuestas posibles:

  • if((i == 0) || (j/i == 1))

  • if((i == 0) | (j/i == 1))

  • if((i != 0) && (j/i == 1))

  • if((i != 0) & (j/i == 1))

Explicación

Pregunta 8 de 40

1

If a base class has a method defined as void method() { }
Which of the following are legal prototypes in a derived class of this class.
Select the two correct answers.

Selecciona una o más de las siguientes respuestas posibles:

  • void method() { }

  • int method() { return 0;}

  • void method(int i) { }

  • private void method() { }

Explicación

Pregunta 9 de 40

1

Assuming the declaration String s = new String(“xyz”);
Which of the following statements would compile. Select the one correct answer.

Selecciona una de las siguientes respuestas posibles:

  • s = 2 * s;

  • int i = s[0];

  • s = s + s;

  • s = s >> 2;

  • None of the above.

Explicación

Pregunta 10 de 40

1

Which of the following are legal identifier names in Java. Select the two correct answers.

Selecciona una o más de las siguientes respuestas posibles:

  • 1. %abcd

  • 2. $abcd

  • 3. 1abcd

  • 4. package

  • 5. _a_long_name

Explicación

Pregunta 11 de 40

1

What gets printed when the following code is compiled and run. Select the one correct answer.
public class test {
public static void main(String args[]) {
int i = 1;
do {
i--;
} while (i > 2);
System.out.println(i);
}
}

Selecciona una de las siguientes respuestas posibles:

  • 0

  • 1

  • 2

  • -1

Explicación

Pregunta 12 de 40

1

Which of the following are legal array declarations. Select the three correct answers.

Selecciona una o más de las siguientes respuestas posibles:

  • int i[5][];

  • int i[][];

  • int []i[];

  • int [5][5];

  • int[][]a;

Explicación

Pregunta 13 de 40

1

What all gets printed when the following gets compiled and run. Select the two correct answers.
public class test {
public static void main(String args[]) {
String s1 = "abc";
String s2 = "abc";
if(s1 == s2)
System.out.println(1);
else
System.out.println(2);
if(s1.equals(s2))
System.out.println(3);
else
System.out.println(4);
}
}

Selecciona una o más de las siguientes respuestas posibles:

  • 1

  • 2

  • 3

  • 4

Explicación

Pregunta 14 de 40

1

What all gets printed when the following gets compiled and run. Select the three correct answers.
public class test {
public static void main(String args[]) {
int i=1, j=1;
try {
i++;
j--;
if(i/j > 1)
i++;
}
catch(ArithmeticException e) {
System.out.println(0);
}
catch(ArrayIndexOutOfBoundsException e) {
System.out.println(1);
}
catch(Exception e) {
System.out.println(2);
}
finally {
System.out.println(3);
}
System.out.println(4);
}
}

Selecciona una o más de las siguientes respuestas posibles:

  • 0,1,2

  • 1,2,3

  • 0,3,4

  • 3,2,4

Explicación

Pregunta 15 de 40

1

What all gets printed when the following program is compiled and run. Select the one correct answer.
public class test {
public static void main(String args[]) {
int i=0, j=2;
do {
i=++i;
j--;
} while(j>0);
System.out.println(i);
}
}

Selecciona una de las siguientes respuestas posibles:

  • 1

  • The program does not compile because of statement “i=++i;”

  • 0

  • 2

Explicación

Pregunta 16 de 40

1

What all gets printed when the following program is compiled and run. Select the two correct answers.
public class test {
public static void main(String args[]) {
int i, j=1;
i = (j>1)?2:1;
switch(i) {
case 0: System.out.println(0); break;
case 1: System.out.println(1);
case 2: System.out.println(2); break;
case 3: System.out.println(3); break;
}
}
}

Selecciona una de las siguientes respuestas posibles:

  • 1,3

  • 2,1

  • 1,2

  • 3,2

Explicación

Pregunta 17 de 40

1

Which of the following is true. Select the two correct answers.

Selecciona una o más de las siguientes respuestas posibles:

  • A class that is abstract may not be instantiated.

  • The final keyword indicates that the body of a method is to be found elsewhere. The code is written in non-Java language, typically in C/C++.

  • A static variable indicates there is only one copy of that variable.

  • A method defined as private indicates that it is accessible to all other classes in the same package.

Explicación

Pregunta 18 de 40

1

. Which of the following is correct? Select the correct answer.

Selecciona una de las siguientes respuestas posibles:

  • The native keyword does not indicates that the method is implemented in another language like C/C++

  • The only statements that can appear before an import statement in a Java file are comments.

  • The method definitions inside interfaces are public and abstract. They cannot be private or protected.

  • A class constructor may have public or protected keyword before them, nothing else.

Explicación

Pregunta 19 de 40

1

What gets printed when the following code is compiled and run with the following command: java test 2
Select the one correct answer.
public class test {
public static void main(String args[]) {
Integer intObj=Integer.valueOf(args[args.length-1]);
int i = intObj.intValue();
if(args.length > 1)
System.out.println(i);
if(args.length > 0)
System.out.println(i - 1);
else
System.out.println(i - 2);
}
}

Selecciona una de las siguientes respuestas posibles:

  • test

  • test -1

  • 1

  • 0

  • 2

Explicación

Pregunta 20 de 40

1

What is the default priority of a newly created thread.

Selecciona una de las siguientes respuestas posibles:

  • MIN_PRIORITY (which is defined as 1 in the Thread class.)

  • NORM_PRIORITY (which is defined as 5 in the Thread class.)

  • A thread inherits the priority of its parent thread.

  • MAX_PRIORITY (which is defined as 10 in the Thread class.)

Explicación

Pregunta 21 de 40

1

What should be done to invoke the run() method on a thread for an object derived from the Thread class. Select the one correct answer.

Selecciona una de las siguientes respuestas posibles:

  • The run() method should be directly invoked on the Object.

  • The start() method should be directly invoked on the Object.

  • The creation of the object using the new operator would create a new thread and invoke its run() method.

  • The init() method should be directly invoked on the Object.

Explicación

Pregunta 22 de 40

1

Select the one most appropriate answer. What is the purpose of method parseInt defined in Integer class.

Selecciona una de las siguientes respuestas posibles:

  • The method converts an integer to a String.

  • The method is used to convert String to an integer, assuming that the String represents an integer.

  • The method is used to convert String to Integer class, assuming that the String represents an integer.

  • The method converts the Integer object to a String.

Explicación

Pregunta 23 de 40

1

In implementing two classes Employee and Manager, such that each Manager is an Employee, what should be the relationship between these classes. Select the one correct answer.

Selecciona una de las siguientes respuestas posibles:

  • Manager class should include the Employee class as a data member.

  • Manager should be the base class of Employee class.

  • Employee should be the base class of Manager class.

Explicación

Pregunta 24 de 40

1

What gets printed when the following program is compiled and run. Select the one correct answer.
public class incr {
public static void main(String args[]) {
int i , j;
i = j = 3;
int n = 2 * ++i;
int m = 2 * j++;
System.out.println(i + " " + j + " " + n + " " + m);
}
}

Selecciona una de las siguientes respuestas posibles:

  • 4 4 8 8

  • 4 4 8 6

  • 4 4 6 6

  • 4 3 8 6

  • 4 4 6 8

Explicación

Pregunta 25 de 40

1

The class Hashtable is used to implement which collection interface. Select the one correct answer.

Selecciona una de las siguientes respuestas posibles:

  • set

  • Map

  • Table

  • SortedSet

Explicación

Pregunta 26 de 40

1

Which of these are legal identifiers. Select the three correct answers.

Selecciona una o más de las siguientes respuestas posibles:

  • number_1

  • number_a

  • $1234

  • -volatile

Explicación

Pregunta 27 de 40

1

Which of these are not legal identifiers. Select the two correct answers.

Selecciona una o más de las siguientes respuestas posibles:

  • 1alpha

  • _abcd

  • xy+abc

  • transient

  • account-num

  • very_long_name

Explicación

Pregunta 28 de 40

1

How many bytes are used to represent the primitive data type int in Java. Select the one correct answer.

Selecciona una de las siguientes respuestas posibles:

  • 4

  • 8

  • 2

  • 1

Explicación

Pregunta 29 de 40

1

What would happen when the following is compiled and executed. Select the one correct answer.
public class Compare {
public static void main(String args[]) {
int x = 10, y;
if(x < 10) y = 1;
if(x>= 10) y = 2;
System.out.println("y is " + y);
}
}

Selecciona una de las siguientes respuestas posibles:

  • The program compiles and prints y is 0 when executed.

  • The program compiles and prints y is 1 when executed.

  • The program does not compile complaining about y not being initialized.

  • The program compiles and prints y is 2 when executed.

  • The program throws a runtime exception.

Explicación

Pregunta 30 de 40

1

Which of the following are legal Java programs. Select the four correct answers.

Selecciona una o más de las siguientes respuestas posibles:

  • // The comments come before the package
    package pkg;
    import java.awt.*;
    class C{}

  • package pkg;
    import java.awt.*;
    class C{}

  • package pkg1;
    package pkg2;
    import java.awt.*;
    class C{}

  • package pkg;
    import java.awt.*;

  • import java.awt.*;
    package pkg;
    class C {}

  • import java.awt.*;
    class C{}

Explicación

Pregunta 31 de 40

1

What all gets printed on the standard output when the class below is compiled and executed by entering “java test lets see what happens”. Select the two correct answers.
public class test {
public static void main(String args[]) {
System.out.println(args[0]+" "+args.length);
}
}

Selecciona una o más de las siguientes respuestas posibles:

  • java

  • test

  • lets

  • 4

  • 5

  • 3

Explicación

Pregunta 32 de 40

1

What happens when the following program is compiled and run. Select the one correct answer.
public class example {
int i[] = {0};
public static void main(String args[]) {
int i[] = {1};
change_i(i);
System.out.println(i[0]);
}
public static void change_i(int i[]) {
int j[] = {2};
i = j;
}
}

Selecciona una de las siguientes respuestas posibles:

  • The program does not compile.

  • The program prints 0

  • The program prints 1

  • The program prints 4

  • The program prints 2

Explicación

Pregunta 33 de 40

1

Which of the following are keywords in Java. Select the two correct answers.

Selecciona una o más de las siguientes respuestas posibles:

  • friend

  • NULL

  • implement

  • synchronized

  • throws

Explicación

Pregunta 34 de 40

1

Which of these are Java keywords. Select the five correct answers

Selecciona una o más de las siguientes respuestas posibles:

  • TRUE

  • volatile

  • transient

  • native

  • interface

  • then

  • new

Explicación

Pregunta 35 de 40

1

What is the minimum value of char type. Select the one correct answer.

Selecciona una de las siguientes respuestas posibles:

  • -215

  • 0

  • -215-1

  • -28

Explicación

Pregunta 36 de 40

1

What is the legal range of values for a variable declared as a byte. Select the one correct answer.

Selecciona una de las siguientes respuestas posibles:

  • 0 to 256

  • 0 to 255

  • -128 to 127

  • -128 to 128

  • -127 to 128

  • -215 to 215 – 1

Explicación

Pregunta 37 de 40

1

What would happen when the following is compiled and executed. Select the one correct answer
class example {
int x;
int y;
String name;
public static void main(String args[]) {
example pnt = new example();
System.out.println("pnt is " + pnt.name + " " + pnt.x + " " + pnt.y);
}
}

Selecciona una de las siguientes respuestas posibles:

  • The program does not compile because x, y and name are not initialized.

  • The program throws a runtime exception as x, y, and name are used before initialization

  • The program prints pnt is 0 0.

  • The program prints pnt is null 0 0.

  • The program prints pnt is NULL false false

Explicación

Pregunta 38 de 40

1

What would be the results of compiling and running the following class. Select the one correct answer.
class test {
public static void main() {
System.out.println("test");
}
}

Selecciona una de las siguientes respuestas posibles:

  • The program does not compile as there is no main method defined.

  • The program compiles and runs generating an output of “test”

  • The program compiles and runs but does not generate any output.

  • The program compiles but does not run.

Explicación

Pregunta 39 de 40

1

. What happens when the following program is compiled and executed with the command – java test. Select the one correct answer.
class test {
public static void main(String args[]) {
if(args.length > 0)
System.out.println(args.length);
}
}

Selecciona una de las siguientes respuestas posibles:

  • The program compiles and runs but does not print anything.

  • The program compiles and runs and prints 2

  • The program compiles and runs and prints 0

  • The program compiles and runs and prints 1

  • The program does not compile

Explicación

Pregunta 40 de 40

1

What is the result of compiling and running this program? Select the one correct answer.

public class test {
public static void main(String args[]) {
int i, j;
int k = 0;
j = 2;
k = j = i = 1;
System.out.println(k);
}
}

Selecciona una de las siguientes respuestas posibles:

  • The program does not compile because of the statement k = j = i = 1;

  • The program does not compile as k is being read without being initialized.

  • The program compiles and runs printing 0.

  • The program compiles and runs printing 2.

  • The program compiles and runs printing 1.

Explicación