60% found this document useful (5 votes)
11K views

Test: Jfo Section 3 Quiz 1 - L1-L2

This document provides the results of a 15 question quiz on variables and data types in Java. It displays the questions, selected answers, and whether each answer was correct or incorrect. An asterisk indicates the correct answer for each question. The quiz covers topics like declaring and initializing variables, valid data types, variable scope and values, and mathematical and final variable practices.

Uploaded by

Dede M Iskandar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
60% found this document useful (5 votes)
11K views

Test: Jfo Section 3 Quiz 1 - L1-L2

This document provides the results of a 15 question quiz on variables and data types in Java. It displays the questions, selected answers, and whether each answer was correct or incorrect. An asterisk indicates the correct answer for each question. The quiz covers topics like declaring and initializing variables, valid data types, variable scope and values, and mathematical and final variable practices.

Uploaded by

Dede M Iskandar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Test: JFo Section 3 Quiz 1 - L1-L2

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 3 Quiz 1 - L1-L2

(Answer all questions in this section)


1. Identify the names of two variables used in the given code.

public class Variables {


  public static void main(String args[]) {
   String strVal = "Hello";
  int intVal = 0;
   System.out.println("Integer: " +intVal)
 }
}
Mark for Review

(1) Points
intVal (*)
Hello
int
strVal (*)
String
Correct

2. Which two data types are appropriate for their variable?


Mark for Review

(1) Points
String firstName = “Alex”; (*)
boolean age = 20;
double checkingAmount = 1500; (*)
int averageDollarAmount = 19.95;
Correct

3. Which is valid syntax to declare and initialize a String variable?


Mark for Review

(1) Points
String x = Java;
String “x” = Java;
String x= “Java”; (*)
String “x” = “Java”;
Correct

4. Identify the variable declared in the given code.

public class Welcome {


  public static void main(String args[]) {
   int a = 2;
   System.out.println("a is " + a);
 }
}
Mark for Review

(1) Points
a (*)
int
Welcome
2
Correct

5. Which of the following two statements are true about variables?


Mark for Review

(1) Points
Variables will be ignored by compiler.
They make code more flexible. (*)
The value assigned to a variable may never change.
The allow code to be edited more efficiently. (*)
Correct

Test: JFo Section 3 Quiz 1 - L1-L2


Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 3 Quiz 1 - L1-L2

(Answer all questions in this section)


6. What is the output?

public class Hello {


  public static void main(String args[]) {
    String str = ”Hello”;
    str = ”World”;
   System.out.println(str);
 }
}
Mark for Review

(1) Points
Hello World
World (*)
Hello
Hello
World
Correct

7. Which two are valid assignments of a?


Mark for Review

(1) Points
int a = 10; (*)
int a = “10”;
int a = 10
int a; a = 10; (*)
Correct

8. Which data type is most commonly used to represent numeric data?


Mark for Review

(1) Points
int (*)
float
String
short
Correct

9. Which two are mathematical operators?


Mark for Review

(1) Points
+ (*)
– (*)
#
@
Correct

10. Which two are recommended practices for naming final variables?
Mark for Review

(1) Points
Capitalize every letter (*)
Separate words with an underscore (*)
Capitalize first letter
Separate words with an space
Correct

Test: JFo Section 3 Quiz 1 - L1-L2


Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 3 Quiz 1 - L1-L2

(Answer all questions in this section)


11. This declaration represents a long data type.
long a = 123L;
Mark for Review

(1) Points
True (*)
False
Correct

12. How many bits are in a byte?


Mark for Review
(1) Points
2
4
6
7
8 (*)
Correct

13. Which keyword makes a variable’s value unchangeable?


Mark for Review

(1) Points
const
final (*)
static
break
Incorrect. Refer to Section 3 Lesson 2.

14. What is the range of the byte data type?


Mark for Review

(1) Points
–27 to 27–1 (*)
–215 to 215–1
–231 to 231–1
–263 to 263–1
Correct

15. What is the output? public static void main(String args[]) {


  int x = 100;
  int y = x;
  y++;
  System.out.println("Value of x is " + x);
  System.out.println("Value of y is " + y);
}
Mark for Review

(1) Points
Value of x is 0
Value of y is 1
Value of x is 100
Value of y is 1
Value of x is 100
Value of y is 1
Value of x is 100
Value of y is 101 (*)
Correct

You might also like