Zusammenfassung der Ressource
Frage 1
Frage
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);
Antworten
-
1 0 1 0 0
-
0 0 0 0 0
-
1 0 1 1 -1
-
0 -1 0 1 -1
Frage 2
Frage
Which of the following string classes create mutable strings? (Choose all that apply.)
Antworten
-
String
-
StringBuffer
-
StringBuilder
Frage 3
Frage
Choose the simplest data structure to use to store multiple like variables that could then be accessed by an index.
Antworten
-
Primitive
-
Object
-
Array
-
Enumeration
Frage 4
Frage
Which of the statements are correct? (Choose all that apply.)
Antworten
-
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.
Frage 5
Frage
What literal values are acceptable to use with the boolean primitive?
Frage 6
Frage
Which code segments related to enumerations will result in a compiler error? (Choose all that apply.)
Antworten
-
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;
Frage 7
Frage
Consider the following declarations. Which declaration has an element name that does not conform to standard naming conventions?
Frage 8
Frage
Java 7 added the allowance of a special character to indentify places. Which declaration is correct?
Antworten
-
int investment = 1x000x000;
-
int investment = 1_000_000;
-
int investment = 1^000^000;
-
int investment = 1-000-000;
Frage 9
Frage
What are the wrapper classes for the primitives boolean, char, short, int, and double?
Antworten
-
Boolean, Char, Short , Int , Double
-
Boolean, Char, Short, Integer, Double
-
Boolean, Character, Short, Int, Double
-
Boolean, Character, Short, Integer, Double
Frage 10
Frage
Which of the following statements contain literal values?
Antworten
-
int maxHorsePower = 170;
-
float currentHorsePower = (float) maxHorsePower;
-
float idleHorsePower = ((float) currentHorsePower) / 10);
-
System.out.println("Current HP: " + currentHorsePower);
Frage 11
Frage
What is the correct way to initialize a variable declared as a Penguin as a new Penguin object?
Frage 12
Frage
Which of the following are primitive data types? (Choose all that apply.)
Antworten
-
int
-
boolean
-
char
-
Float
-
String
Frage 13
Frage
Which code example makes use of arrays without producing a compiler or runtime error?
Antworten
-
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";
}
}
Frage 14
Frage
Class variables, also known as static fields, have only one instance in existence. Following standing naming conventions, which answer represents a class variable?
Antworten
-
variableName
-
VariableName
-
ClassName:variableName
-
ClassName.variableName
Frage 15
Frage
What statement about local variables is true?
Antworten
-
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.