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

Test sobre Segundo Set de Preguntas Java OCA Exam (1z0-803) , creado por webmasterMyJavaZone el 18/06/2014.

33899
3
0
webmasterMyJavaZone
Creado por webmasterMyJavaZone hace alrededor de 10 años
Cerrar

Segundo Set de Preguntas Java OCA Exam (1z0-803)

Pregunta 1 de 14

1

Which conditional statement would be best suited for determining the flow of code based on an int that may have a value between 1 and 10? The program must react differently for each value.

Selecciona una de las siguientes respuestas posibles:

  • if-else statement

  • if-else-if statement with multiple if-elses

  • multiple if statements

  • switch statement

Explicación

Pregunta 2 de 14

1

What Java code is used for declaring and initializing a null object?

Selecciona una de las siguientes respuestas posibles:

  • Object object = new Object();

  • Object object = new Object(null);

  • Object object = null;

  • Object object = null();

Explicación

Pregunta 3 de 14

1

Given the following code segment, what would be the output?

int value1 = 5;
int value2 = 7;
boolean bool1 = true;
boolean bool2 = false;
if (bool1 && (( value1 < value2 )|| bool2 ) && !(bool2)) {
System.out.println("Result set one");
}
else {
System.out.println("Result set two");
}

Selecciona una de las siguientes respuestas posibles:

  • Result set one

  • Result set two

Explicación

Pregunta 4 de 14

1

What is the output for the following Java code segment? The text in parentheses is meant to describe the whitespace and is not part of the output.

String fiveSpaces = " ";
String SCJA = "SCJA";
String lineToDisplay = "fiveSpaces + SCJA + fiveSpaces";
System.out.println(lineToDisplay.trim());

Selecciona una de las siguientes respuestas posibles:

  • SCJA (no trailing and leading spaces)

  • SCJA (five leading and trailing spaces)

  • SCJA (four leading and trailing spaces)

  • fiveSpaces + SCJA + fiveSpaces

Explicación

Pregunta 5 de 14

1

Given:

public class StringModifier {
public static void main (String[] args) {
String a = "Supercalifragilisticexpialidocious!";
String b = a.substring(x,y);
char [] c = {a.charAt(u), a.charAt(v)};
System.out.print(b + String.valueOf(c));
}
}

What integer declarations are needed to print the string fragile!?

Selecciona una de las siguientes respuestas posibles:

  • int x = 8; int y = 14; int u = 2; int v =33;

  • int x = 10; int y = 16; int u = 4; int v =35;

  • int x = 8; int y = 15; int u = 5; int v =32;

  • int x = 9; int y = 15; int u = 3; int v =34;

Explicación

Pregunta 6 de 14

1

You want to remove all leading and trailing whitespace from a string.Which method invocation will allow this to occur?

Selecciona una de las siguientes respuestas posibles:

  • stringName.trim();

  • stringName.trim(' ');

  • stringName.trim(" ");

  • stringName.trimWhiteSpace();

Explicación

Pregunta 7 de 14

1

From highest precedence to lowest, which list of operators is ordered properly?

Selecciona una de las siguientes respuestas posibles:

  • *, +, &&, =

  • *, &&, +, =

  • *, =, &&, +

  • +, *, &&, =

Explicación

Pregunta 8 de 14

1

Given the following code that uses the modulus operator, what will be printed? System.out.print((24 % 8) + (10 % 7) + (100 % 99) + (38 % 6));

Selecciona una de las siguientes respuestas posibles:

  • 5

  • 6

  • 0312

  • 0302

Explicación

Pregunta 9 de 14

1

Given the following code segment testing the equality of two strings, what will be printed?

1. String string = "Dollar bill";
2. string.replace("Dollar bill","Silver dollar");
3. if ("Dollar bill".equals(string)) {
4. System.out.println ("I have a dollar bill.");
5. } else {
6. System.out.println ("I have a silver dollar.");
7. }

Selecciona una de las siguientes respuestas posibles:

  • I have a dollar bill.

  • I have a silver dollar.

  • The code will not compile because of an error at line 2.

  • The code will not compile because of an error at line 3.

Explicación

Pregunta 10 de 14

1

Which append declaration does not exist in Java 7?

Selecciona una de las siguientes respuestas posibles:

  • public StringBuilder append (short s) {…}

  • public StringBuilder append (int i) {…}

  • public StringBuilder append (long l) {…}

  • public StringBuilder append (float f) {…}

  • public StringBuilder append (double d) {…}

Explicación

Pregunta 11 de 14

1

Given:

System.out.println("A" + 1 + (1 + 1) + 1);

What will print?

Selecciona una de las siguientes respuestas posibles:

  • A1111

  • A121

  • A13

  • A31

  • Compilation error

Explicación

Pregunta 12 de 14

1

Given:

StringBuilder s = new StringBuilder ("magic");
s.append("al").replace(1, 3, "us").matches("musical");
System.out.println(s);

What will be printed to standard out?

Selecciona una de las siguientes respuestas posibles:

  • magical

  • musical

  • true

  • The code will not compile.

Explicación

Pregunta 13 de 14

1

Given:

boolean value = true;
System.out.print( true || (value=false));
System.out.println(", " + value);

What is printed to standard out?

Selecciona una de las siguientes respuestas posibles:

  • true, true

  • true, false

  • false, true

  • false, false

Explicación

Pregunta 14 de 14

1

Given:

String value1 = "null";
String value2 = "null";
System.out.println(value1.equalsIgnoreCase(value2));

What result will be seen upon compilation and/or execution?

Selecciona una de las siguientes respuestas posibles:

  • A NullPointerException is thrown at runtime.

  • equalsIgnoreCase is not a valid method name and causes a compilation error.

  • "true" is printed to standard out.

  • "false" is printed to standard out.

Explicación