JFo Section 3 Quiz 2 - L3-L5
1. An Object cannot have String objects as properties.
benar
Palsu (*)
Correct
(1/1) Point
2. char is the primitive textual data type in Java.
benar (*)
Palsu
Correct
(1/1) Point
3. What is the output?
public static void main(String args[]) {
String greet1 = "Hello";
String greet2 = "World";
String message2 = greet1 +" " +greet2 +" " +2016 +"!";
System.out.println(message2);
}
"Hello World 2016"
Hello World
Hello World 2016 ! (*)
"Hello" "World" "2016" "!"
Correct
(1/1) Point
4. Which two statements compile?
(Pilih semua jawaban yang benar)
char size = ”m”;
char size = ’m’; (*)
String size = ‘M’;
String size = “M”; (*)
Incorrect. Refer to Section 3 Lesson 3.
(0/1) Point
5. Char data types cannot handle multiple characters.
benar (*)
Palsu
Correct
6. Which two statements compile?
(Pilih semua jawaban yang benar)
String name = ‘Java’;
String name = new String ( ‘Java’);
String name = “J”; (*)
String name = “Java”; (*)
Incorrect. Refer to Section 3 Lesson 3.
(0/1) Point
7. Which is a valid way to parse a String as an int?
nt intVar1 = (int)"100";
int intVar1 = Integer.parseInt("100"); (*)
int intVar1 = Integer.parseInt("One Hundred");
int intVar1 = "100";
Correct
(1/1) Point
8. Which two statements are true about type casting?
(Pilih semua jawaban yang benar)
Type casting retains the size of the value or the original data type.
Type casting lowers the range of possible values. (*)
Type casting changes the type of the value stored. (*)
Type casting cannot be performed on equations.
Correct
(1/1) Point
9. What is parsing?
Converting numeric data to text
Reading text from numeric data
Converting text to numeric data (*)
Converting numeric data to a specified numeric data type
Incorrect. Refer to Section 3 Lesson 4.
(0/1) Point
10. When the result of an expression is assigned to a temporary memory location, what is the size of memory allocated?
The size of the largest data type used in the expression. (*)
The size of the smallest data type used in the expression.
The size of the any data type used in the expression.
A default size is allocated.
Incorrect. Refer to Section 3 Lesson 4.
11. What is the correct way to cast a long to an int?
int longToInt = 20L;
int longToInt = (int)20L; (*)
int longToInt = int 20L;
int longToInt = 20L(int);
Incorrect. Refer to Section 3 Lesson 4.
(0/1) Point
12. A short data type can be promoted to which of the following types?
(Pilih semua jawaban yang benar)
boolean
byte
int (*)
double (*)
long (*)
Incorrect. Refer to Section 3 Lesson 4.
(0/1) Point
13. The Scanner class accepts input in which form?
Callables
Future
Tokens (*)
Integer
Correct
(1/1) Point
14. The Scanner class considers space as the default delimiter while reading the input.
benar (*)
Palsu
Correct
(1/1) Point
15. Which two statements are true about the Scanner class?
(Pilih semua jawaban yang benar)
A Scanner object doesn’t have fields and methods.
Scanners cannot read text files.
A Scanner’s delimiter can be changed. (*)
A Scanner object opens a stream for collecting input. (*)
Correct
PERCOBAAN KE 2
1. A character preceded by backslash is called an escape sequence.
benar (*)
Palsu
Correct
(1/1) Point
2. Given the expression:
String message = "Hello World";
Which is the String Literal?
String message = "Hello World";
message
String message
Hello World (*)
Correct
(1/1) Point
3. Which two statements compile?
(Pilih semua jawaban yang benar)
String size = ‘M’;
char size = ”m”;
String size = “M”; (*)
char size = ’m’; (*)
Correct
(1/1) Point
4. The print() method prints to the console and automatically creates a line.
benar
Palsu (*)
Incorrect. Refer to Section 3 Lesson 3.
(0/1) Point
5. A String can be created by combining multiple String Literals.
benar (*)
Palsu
Correct
6. An Object cannot have String objects as properties.
benar
Palsu (*)
Correct
(1/1) Point
7. System.in readies Scanner to collect input from the console.
benar (*)
Palsu
Correct
(1/1) Point
8. The Scanner class accepts input in which form?
Future
Integer
Tokens (*)
Callables
Correct
(1/1) Point
9. These two code fragments perform the same task.
// Fragment 1
String inputString = JOptionPane.showInputDialog("??");
int input = Integer.parseInt(inputString);
input++;
// Fragment 2
int input = Integer.parseInt(JOptionPane.showInputDialog("??")) + 1;
benar (*)
Palsu
Correct
(1/1) Point
10. A double with the value of 20.5 is cast to an int. What is the value of the int?
21
25
20.5
20 (*)
Incorrect. Refer to Section 3 Lesson 4.
11. The Java compiler automatically promotes byte, short, and chars data type values to int data type.
benar (*)
Palsu
Correct
(1/1) Point
12. Which two statements are correct about the usage of an underscore?
(Pilih semua jawaban yang benar)
Underscores change the value of the number.
Underscores help make large numbers more readable. (*)
Underscores do not affect the value of the variable. (*)
Underscores help the compiler interpret large numbers.
Correct
(1/1) Point
13. Which two statements are true about type casting?
(Pilih semua jawaban yang benar)
Type casting retains the size of the value or the original data type.
Type casting changes the type of the value stored. (*)
Type casting cannot be performed on equations.
Type casting lowers the range of possible values. (*)
Correct
(1/1) Point
14. Which is a valid way to parse a String as an int?
nt intVar1 = (int)"100";
int intVar1 = Integer.parseInt("One Hundred");
int intVar1 = Integer.parseInt("100"); (*)
int intVar1 = "100";
Correct
(1/1) Point
15. What is parsing?
Converting numeric data to text
Converting numeric data to a specified numeric data type
Reading text from numeric data
Converting text to numeric data (*)
Correct
Posting Komentar untuk "JFo Section 3 Quiz 2 - L3-L5"