Pregunta 1
Pregunta
Given the following code segment, what would be the output?
int a = 0;
int b = 0;
int c = 0;
System.out.println(a++ + " " + --b + " " + c++ + " " + a + " " + b);
Respuesta
-
1 0 1 0 0
-
0 0 0 0 0
-
1 0 1 1 -1
-
0 -1 0 1 -1
Pregunta 2
Pregunta
Which of the following string classes create mutable strings? (Choose all that apply.)
Respuesta
-
String
-
StringBuffer
-
StringBuilder
Pregunta 3
Pregunta
Choose the simplest data structure to use to store multiple like variables that could then be accessed by an index.
Respuesta
-
Primitive
-
Object
-
Array
-
Enumeration
Pregunta 4
Pregunta
Which of the statements are correct? (Choose all that apply.)
Respuesta
-
3.0 is a valid literal for an int.
-
3.0 is a valid literal for a float.
-
3 is a valid literal for an int.
-
3 is a valid literal for a float.
-
3f is a valid literal for an int.
-
3f is a valid literal for a float.
Pregunta 5
Pregunta
What literal values are acceptable to use with the boolean primitive?
Pregunta 6
Pregunta
Which code segments related to enumerations will result in a compiler error? (Choose all that apply.)
Respuesta
-
enum Coin {PENNY, NICKEL, DIME, QUARTER}
Coin coin = Coin.NICKEL;
-
enum Coin {PENNY, NICKEL, DIME, QUARTER}
Coin coin;
coin = Coin.NICKEL;
-
enum Coin {PENNY, NICKEL, DIME, QUARTER}
Coin coin = NICKEL;
-
enum Coin {penny, nickel, dime, quarter}
Coin coin = Coin.NICKEL;
Pregunta 7
Pregunta
Consider the following declarations. Which declaration has an element name that does not conform to standard naming conventions?
Pregunta 8
Pregunta
Java 7 added the allowance of a special character to indentify places. Which declaration is correct?
Respuesta
-
int investment = 1x000x000;
-
int investment = 1_000_000;
-
int investment = 1^000^000;
-
int investment = 1-000-000;
Pregunta 9
Pregunta
What are the wrapper classes for the primitives boolean, char, short, int, and double?
Respuesta
-
Boolean, Char, Short , Int , Double
-
Boolean, Char, Short, Integer, Double
-
Boolean, Character, Short, Int, Double
-
Boolean, Character, Short, Integer, Double
Pregunta 10
Pregunta
Which of the following statements contain literal values?
Respuesta
-
int maxHorsePower = 170;
-
float currentHorsePower = (float) maxHorsePower;
-
float idleHorsePower = ((float) currentHorsePower) / 10);
-
System.out.println("Current HP: " + currentHorsePower);
Pregunta 11
Pregunta
What is the correct way to initialize a variable declared as a Penguin as a new Penguin object?
Pregunta 12
Pregunta
Which of the following are primitive data types? (Choose all that apply.)
Respuesta
-
int
-
boolean
-
char
-
Float
-
String
Pregunta 13
Pregunta
Which code example makes use of arrays without producing a compiler or runtime error?
Respuesta
-
public class Actor {
String[] characterName = new String[3];
{
characterName[0] = "Captain Video";
characterName[1] = "Quizmaster";
characterName[2] = "J.C. Money";
characterName[3] = "Jersey Joe";
}
}
-
public class Actor {
String[] characterName = new String[1..4]
{
characterName[0] = "Captain Video";
characterName[1] = "Quizmaster";
characterName[2] = "J.C. Money";
characterName[3] = "Jersey Joe";
}
}
-
public class Actor {
String characterName = new String[4];
{
characterName[0] = "Captain Video";
characterName[1] = "Quizmaster";
characterName[2] = "J.C. Money";
characterName[3] = "Jersey Joe";
}
}
-
public class Actor {
String [] characterName = new String[4];
{
characterName[0] = "Captain Video";
characterName[1] = "Quizmaster";
characterName[2] = "J.C. Money";
characterName[3] = "Jersey Joe";
}
}
Pregunta 14
Pregunta
Class variables, also known as static fields, have only one instance in existence. Following standing naming conventions, which answer represents a class variable?
Respuesta
-
variableName
-
VariableName
-
ClassName:variableName
-
ClassName.variableName
Pregunta 15
Pregunta
What statement about local variables is true?
Respuesta
-
Local variables are declared outside of methods and are initialized with a default value.
-
Local variables are declared inside of methods and are initialized with a default value.
-
Local variables are declared outside of methods and are not initialized with a default value.
-
Local variables are declared inside of methods and are not initialized with a default value.