Test: Section 2 Quiz
Test: Section 2 Quiz
Test: Section 2 Quiz
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 2 Quiz
(Answer all questions in this section)
1. When the program runs normally (when not in debug mode), which statement is true
about breakpoints? Mark for Review
(1) Points
Correct
Correct
3. Which of the following two features are supported by the NetBeans IDE.
Mark for Review
(1) Points
They can be used to check the current state of the program (*)
They abruptly ends the code execution.
They pause code execution. (*)
They help with debugging. (*)
They insert break statements.
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 2 Quiz
(Answer all questions in this section)
Correct
7. Which of the following are adequate definitions for components of the Spiral Model of
Development? Mark for Review
(1) Points
True (*)
False
Correct
True
False (*)
Correct
10. A software feature may allow the user to perform a specific task.
Mark for Review
(1) Points
True (*)
False
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 2 Quiz
(Answer all questions in this section)
empId
name
salary
displaySalary() (*)
Correct
12. There are several fields and methods in a Shirt class. Which of the following could be a
method in the Shirt class? Mark for Review
(1) Points
getShirtSize() (*)
color
size
price
Correct
13. In object oriented programming, there is an emphasis on which of the following two:
Mark for Review
(1) Points
Correct
Java C
C (*)
C++
Java
Correct
True (*)
False
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Hello
World
Hello
Hello World
World (*)
Correct
Correct
String x = Java;
String x= “Java”; (*)
String “x” = Java;
String “x” = “Java”;
Correct
a=2
This is my first program a is + a
This is my first program a is 2 (*)
This is my first program
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
True (*)
False
Correct
7. Which two data types are appropriate for their variable?
Mark for Review
(1) Points
Correct
const
final (*)
static
break
Correct
int (*)
float
String
short
Correct
byte
short
int
long (*)
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
11. Assuming x is an int, which of the following are ways to increment the value of x by 1?
Mark for Review
(1) Points
x = x +1; (*)
x = +1;
x+;
x++; (*)
x += 1; (*)
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
13. This declaration represents a long data type.
long a = 123L; Mark for Review
(1) Points
True (*)
False
Correct
Value of age: 20
Value of age: 8
Value of age: 10 (*)
Value of age: 20
Value of age: 28
Value of age: 38
Value of age: 20
Value of age: 208
Value of age: 20810
Value of age: 20
Value of age: 8
Value of age: 9
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
1. The Scanner class considers space as the default delimiter while reading the input.
Mark for Review
(1) Points
True (*)
False
Correct
Correct
Callables
Integer
Tokens (*)
Future
Correct
Correct
True (*)
False
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
True (*)
False
Correct
Correct
True
False (*)
Correct
True (*)
False
Correct
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Correct
12. Automatic promotion from smaller data type to a larger data type is not allowed in
Java. Mark for Review
(1) Points
True
False (*)
Correct
13. A double with the value of 20.5 is cast to an int. What is the value of the int?
Mark for Review
(1) Points
25
20 (*)
21
20.5
Correct
14. Which two statements are correct about the usage of an underscore?
Mark for Review
(1) Points
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Correct
2. Which of the following wild card character is used to import all the classes in a
particular package? Mark for Review
(1) Points
~
!
* (*)
;
Correct
java
awt.font
java.awt
java.awt.font (*)
True (*)
False
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 4 Quiz 1 - L1-L2
(Answer all questions in this section)
6. The JFrame and JOptionPane classes are in the javax.swing package. Which two will
import those classes? Mark for Review
(1) Points
import javax.swing;
import javax.swing.JOptionPane;
import javax.swing.JFrame; (*)
import javax.swing.J*;
import javax.swing.*; (*)
Correct
True (*)
False
Correct
True (*)
False
Correct
True (*)
False
Correct
10. Which of the following two operations are appropriate for the main method?
Mark for Review
(1) Points
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
11. Which is a valid way of calling the testMethod in the TestClass? Assume a testInstance
has been created. Mark for Review
(1) Points
public void testMethod(int x, double y){
System.out.println(x/y);
}
testInstance.testMethod(10);
testInstance.testMethod(3.5, 10);
testInstance.testMethod(10, 3.5); (*)
testInstance.testMethod(3.5);
testInstance.testMethod(10, 3.5, 0);
Correct
True (*)
False
Correct
13. Which of the following are the arguments in the following method?
Mark for Review
Employee emp = new Employee(); (1) Points
emp.calculateSalary(100000, 3.2, 15);
emp
calculateSalary(100000, 3.2, 15);
100000, 3.2, 15 (*)
emp.calculateSalary(100000, 3.2, 15);
Correct
14. Once an object is instantiated, how might its fields and methods be accessed in Java?
Mark for Review
(1) Points
Correct
2
0
3 (*)
1
Correct
Correct
2.718
The value varies.
0
3.141 (*)
Correct
3. The Math class methods can be called without creating an instance of a Math object.
Mark for Review
(1) Points
True (*)
False
Correct
True (*)
False
Correct
5. String objects are immutable.
Mark for Review
(1) Points
True (*)
False
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
True (*)
False
Correct
World
JavaWorld (*)
Java World
Java
Correct
Java World!
JAvA World! (*)
JAva World!
JavA World!
Correct
9. The indexOf() method returns the index value of a character in the string.
Mark for Review
(1) Points
True (*)
False
Correct
10. The String concat() method concatenates only String data types.
Mark for Review
(1) Points
True (*)
False
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
True
False (*)
Correct
12. You need to generate random integer values between 0 and 80 (inclusive). Which
statement should you use? Mark for Review
(1) Points
nextInt();
nextInt(80);
nextInt(0-79);
nextInt(81); (*)
True (*)
False
Correct
Random (*)
Number
Double
Integer
Correct
Nothing is returned.
Either a true or false. (*)
Returns the next value.
An integer value.
Correct
Previous Page 3 of 3 Summary
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 5 Quiz
(Answer all questions in this section)
1. In a boolean expression which uses the && operator, what would make this expression
evaluate to true? Mark for Review
(1) Points
boolean x = (firstCondition && secondCondition);
If both the first condition and second condition are true (*)
If the first condition is false, but the second condition is true
If both the first condition and second condition are false
If the first condition is true, but the second condition is false
Correct
2. In the OR (||) test, if the first expression on the left hand side is true then there is no
need to evaluate the second statement. Mark for Review
(1) Points
True (*)
False
Correct
I scored 1 point
I scored 10 points (*)
Compilation error
I scored 1 point 10 points
Correct
4. In the AND (&&) test, if the first expression on the left hand side is false, then there is
no need to evaluate the second statement. Mark for Review
(1) Points
True (*)
False
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 5 Quiz
(Answer all questions in this section)
6. Which two of the following data types can be used in a switch statement?
Mark for Review
(1) Points
(Choose all correct answers)
String (*)
float
int (*)
boolean
Correct
7. The switch statement is a more efficient way to write code when dealing with a large
range of unknown values. Mark for Review
(1) Points
True
False (*)
8. A break statement causes control to transfer to the end of the switch statement.
Mark for Review
(1) Points
True (*)
False
Correct
False
JavaProgramming
Java Programming
True (*)
Correct
10. The equal sign (=) is used to make an assignment, whereas the == sign merely
makes a comparison and returns a boolean. Mark for Review
(1) Points
True (*)
False
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 5 Quiz
(Answer all questions in this section)
11. A String comparison with == compares the Strings’ locations in memory and not the
content of the String. Mark for Review
(1) Points
True (*)
False
Correct
Bob is 43 (*)
Bob is 50
Bob is 43 Bob is 50
No output
Correct
13. Which are used in a boolean expression?
Mark for Review
(1) Points
Errors
Loops
Operators (*)
Variables (*)
Correct
14. What are the possible values of a boolean data type in Java?
Mark for Review
(1) Points
yes/no
true/false (*)
good/bad
0/1
Correct
15. Which operator is used to test if both sides of a boolean expression are equal?
Mark for Review
(1) Points
<=
== (*)
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 2
(Answer all questions in this section)
1. You’d like to see a movie with a few friends. You write an email to confirm plans.
Mark for Review
Hi Friends, (1) Points
There’s a new movie “Attack of the Duke!” premiering this Friday at Oracle Cinema at
4:30 PM. The cinema is at the corner of South Street and Walnut Ave. Subway would be
the best way to get there.
Would any of you be interested in going?
Watch “Attack of the Duke!” on Friday at Oracle Cinema at 4:30 PM. (*)
Travel via subway.
Double check the location by verifying you’re on South Street and Walnut Ave.
Reach the cinema by 4:00 PM.
Correct
Correct
3. If the requirement step of the Spiral Model of development is forgotten, which of the
following could occur? Mark for Review
(1) Points
True (*)
False
Correct
Start with two slashes (//). End when the line ends. (*)
Start with two slashes and a star (//*). End with a star-slash (*/).
Start with a slash- star (/*). End with slash-star (/*).
Start with two slashes (//). End with two slashes (//).
Start with a slash-star (/*). End with a star-slash (*/). (*)
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 2
(Answer all questions in this section)
Correct
name
salary
displaySalary() (*)
empId
Correct
True (*)
False
Correct
9. You have a beautiful garden at home. On Sunday, you start budding your rose plant to
make few more samples of rose plants to plant in the garden. Can you categorize how Mark for Review
this scenario could be represented by classes and instances? (1) Points
Rose plant is the object and samples are not instances of the plant because they
have not grown yet.
Rose plant is the class and the samples generated from the rose plant are
instances of that class. (*)
Samples of the rose plant are called classes and not the actual rose plant.
Samples are the class and the rose plant is the instances of samples.
Correct
Section 3
(Answer all questions in this section)
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 3
(Answer all questions in this section)
True (*)
False
Correct
12. In Java, char is a primitive data type, while String is an object data type.
Mark for Review
(1) Points
True (*)
False
Correct
13. Which two are recommended practices for naming final variables?
Mark for Review
(1) Points
Correct
14. Which keyword makes a variable’s value unchangeable?
Mark for Review
(1) Points
const
final (*)
static
break
Correct
True (*)
False
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 3
(Answer all questions in this section)
16. When the result of an expression is assigned to a temporary memory location, what is
the size of memory allocated? Mark for Review
(1) Points
Correct
Correct
18. Automatic promotion from smaller data type to a larger data type is not allowed in
Java. Mark for Review
(1) Points
True
False (*)
Correct
19. Identify the names of two variables used in the given code.
Mark for Review
public class Variables { (1) Points
public static void main(String args[]) {
String strVal = "Hello";
int intVal = 0;
System.out.println("Integer: " +intVal)
}
}
int
String
strVal (*)
Hello
intVal (*)
Correct
Hello
Hello
World
World (*)
Hello World
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 3
(Answer all questions in this section)
21. Java is a strongly typed language; therefore you must declare a data type for all
variables. Mark for Review
(1) Points
True (*)
False
Correct
22. Which two statements are true about the Scanner class?
Mark for Review
(1) Points
Correct
Tokens (*)
Callables
Future
Integer
Correct
True (*)
False
Correct
Section 4
(Answer all questions in this section)
Parameter values can never be used within the method code block.
Parameter values can be used within the method code block. (*)
Methods can be written with any number of parameters. (*)
Methods can never be written with more than four parameters.
Methods cannot be written with parameters.
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 4
(Answer all questions in this section)
26. void type methods don’t return any values
Mark for Review
(1) Points
True (*)
False
Correct
27. Which of the following scenarios would be ideal for writing a method?
Mark for Review
(1) Points
28. Which is a valid way of calling the testMethod in the TestClass? Assume a testInstance
has been created. Mark for Review
(1) Points
public void testMethod(int x, double y){
System.out.println(x/y);
}
testInstance.testMethod(3.5, 10);
testInstance.testMethod(10, 3.5); (*)
testInstance.testMethod(10);
testInstance.testMethod(3.5);
testInstance.testMethod(10, 3.5, 0);
Correct
29. The indexOf() method returns the index value of a character in the string.
Mark for Review
(1) Points
True (*)
False
Correct
30. The String class must be imported using java.lang.String;
Mark for Review
(1) Points
True
False (*)
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 6 Quiz
(Answer all questions in this section)
1. The purpose of adding comments is to increase the ability to understand the logic
easily. Mark for Review
(1) Points
True (*)
False
Correct
var1: 0, var2: 0
var1: 0, var2: 1
var1: 0, var2: 2
var1: 1, var2: 0
var1: 1, var2: 1
var1: 1, var2: 2
var1: 2, var2: 0
var1: 2, var2: 1
var1: 2, var2: 2
var1: 0, var2: 0
var1: 1, var2: 1
var1: 2, var2: 0
var1: 0, var2: 0
var1: 0, var2: 1
var1: 1, var2: 0
var1: 1, var2: 1
var1: 2, var2: 0
var1: 2, var2: 1
var1: 0, var2: 0
var1: 0, var2: 1
var1: 1, var2: 0
var1: 1, var2: 1
(*)
Correct
3. The only way to exit a loop is for the loop condition to evaluate to false.
Mark for Review
(1) Points
True
False (*)
Correct
do-while (*)
while
forEach
for
Correct
5. A do-while will always execute statements contained in the loop at least once.
Mark for Review
(1) Points
True (*)
False
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 6 Quiz
(Answer all questions in this section)
Correct
for (*)
while (*)
forEach
do-while
8. A while loop is often used with Scanner input as you don't know many times you'll
need to re-prompt the user if they type bad data. Mark for Review
(1) Points
True (*)
False
Correct
9. The while loop continually executes a block of statements while a particular condition
is false. Mark for Review
(1) Points
True
False (*)
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 6 Quiz
(Answer all questions in this section)
11. In the given syntax of for loop, which part represents the header section?
Mark for Review
for (initialization; condition; update) { (1) Points
// Code statement(s) }
for (initialization; condition; update) { Code statement(s) }
for (initialization; condition; update) { }
Code statement(s)
for (initialization; condition; update) (*)
Correct
True (*)
False
Correct
14. Looping continues as long as the boolean expression in the for loop is false.
Mark for Review
(1) Points
True
False (*)
Correct
15. Given:
Mark for Review
for(int i = 0; i > 10; i++){ } (1) Points
What type of variable is i?
Local (*)
Member
Static
Global
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
True (*)
False
Correct
1
3 (*)
0
2
Correct
Correct
True (*)
False
Correct
Class
null
Student (*)
String
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
6. Java automatically clears the memory once occupied by an object using garbage
collection. Mark for Review
(1) Points
True (*)
False
Correct
boolean
int
String (*)
double
Correct
True (*)
False
Correct
Correct
10. How would you instantiate the Employee class from a main method located in another
class? Mark for Review
(1) Points
public class Employee{
private String name;
private double salary;
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
11. In Java, the this keyword can be used to reference the current object’s fields and
methods. Mark for Review
(1) Points
True (*)
False
Correct
12. A constructor is a special method which is commonly used to set the initial values of
an object’s fields. Mark for Review
(1) Points
True (*)
False
Correct
13. You have created an Employee class with all required fields and methods. 10
employees join the company. Should you copy and paste the Employee class for all 10 Mark for Review
employees? (1) Points
True
False (*)
Correct
14. How can you retrieve a value from a method?
Mark for Review
(1) Points
Correct
15. Variables created within a method can be accessed outside that method.
Mark for Review
(1) Points
True
False (*)
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Correct
2. An object reference directs you from one object to another.
Mark for Review
(1) Points
True (*)
False
3. What is encapsulation?
Mark for Review
(1) Points
Correct
final
static
private (*)
public (*)
Correct
5. To make fields directly accessible to other classes, the class fields must be marked
public. Mark for Review
(1) Points
True (*)
False
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
True (*)
False
Correct
True (*)
False
Correct
True (*)
False
Correct
10. Method overloading can be a useful technique for defining methods with similar
functionality or calculations. Mark for Review
(1) Points
True (*)
False
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Correct
12. Static variables of a class can be accessed, even if the class has not been instantiated.
Mark for Review
(1) Points
True (*)
False
Correct
True (*)
False
Correct
14. An object must be instantiated before its non-static fields and methods can be
accessed. Mark for Review
(1) Points
True (*)
False
Correct
15. Given the following code, why does your IDE complain that “non-static variable name
cannot be referenced from a static context”? Mark for Review
(1) Points
public class Employee{
public static int employeeID;
public String name;
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 8 Quiz
(Answer all questions in this section)
Integer
float (*)
int (*)
String
String (*)
Boolean
Integer
Byte
Correct
You can use an ArrayList list to store Java primitive values (like int). (*)
An ArrayList grows as you add elements.
You can remove all of the elements of an ArrayList with a method.
An ArrayList shrinks as you remove elements.
Correct
Correct
5. The Java compiler does not check for an ArrayIndexOutOfBoundsException during the
compilation of a program containing arrays. Mark for Review
(1) Points
True (*)
False
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 8 Quiz
(Answer all questions in this section)
6. Given:
int x[]; Mark for Review
What is the value of x? (1) Points
null (*)
0
Some random number.
1
Correct
Correct
0 (*)
1
You can start with anything
It depends on the type of the array.
Correct
1
0
10 (*)
ArrayIndexOutOfBoundsException
Correct
1
Arithmetic Exception
1
Array index out of bounds (*)
1
2
Array index out of bounds
1
2
Array index out of bounds
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 8 Quiz
(Answer all questions in this section)
True (*)
False
Correct
Correct
13. Using the NetBeans debugger, you can set breakpoints and trace through a program
one line at a time. Mark for Review
(1) Points
True (*)
False
Correct
14. What are two disadvantages of adding print statements for debugging?
Mark for Review
(1) Points
Correct
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 9 Quiz
(Answer all questions in this section)
Correct
setOnMouseClicked() (*)
setOnMouseDragged()
setOnMouseMoved()
setOnMouseReleased()
Correct
3. JavaFX doesn’t provide you with UI elements, shapes and text. So you must always
create your own graphics. Mark for Review
(1) Points
True
False (*)
Correct
4. Lambda Expressions provide much more effective and cleaner syntax for working with
GUI applications and sorting lists. Mark for Review
(1) Points
True (*)
False
Correct
5. When you write code for MouseEvents, you are telling a Node to listen for a particular
event. Mark for Review
(1) Points
True (*)
False
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 9 Quiz
(Answer all questions in this section)
True (*)
False
Correct
Correct
8. The start() method is the entry point for all JavaFX applications.
Mark for Review
(1) Points
True (*)
False
Correct
True (*)
False
Correct
Object (*)
Button
ImageView
ScrollBar
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 9 Quiz
(Answer all questions in this section)
True (*)
False
Correct
Correct
13. Which method helps to set the width of a rectangle’s outline?
Mark for Review
(1) Points
setX(double d)
setStrokeWidth(double d) (*)
setLayoutX(double d)
setStroke(Paint paint)
Correct
14. How would you create a custom color that is pure cyan (equal parts green and blue)?
Mark for Review
(1) Points
Correct
15. Which color is not directly used when creating custom Color.rgb()?
Mark for Review
(1) Points
Yellow (*)
Red
Blue
Green
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 2 Quiz
(Answer all questions in this section)
1. When the program runs normally (when not in debug mode), which statement is true
about breakpoints? Mark for Review
(1) Points
Correct
Correct
Start with two slashes (//). End with two slashes (//).
Start with two slashes and a star (//*). End with a star-slash (*/).
Start with two slashes (//). End when the line ends. (*)
Start with a slash- star (/*). End with slash-star (/*).
Start with a slash-star (/*). End with a star-slash (*/). (*)
Correct
True (*)
False
Correct
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 2 Quiz
(Answer all questions in this section)
Correct
True
False (*)
Correct
True (*)
False
Correct
True (*)
False
Correct
10. Which of the following are adequate definitions for components of the Spiral Model of
Development? Mark for Review
(1) Points
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 2 Quiz
(Answer all questions in this section)
11. There are several fields and methods in a Shirt class. Which of the following could be a
method in the Shirt class? Mark for Review
(1) Points
color
getShirtSize() (*)
size
price
Correct
True (*)
False
Correct
empId
salary
displaySalary() (*)
name
Correct
14. You have a beautiful garden at home. On Sunday, you start budding your rose plant to
make few more samples of rose plants to plant in the garden. Can you categorize how Mark for Review
this scenario could be represented by classes and instances? (1) Points
Samples of the rose plant are called classes and not the actual rose plant.
Rose plant is the object and samples are not instances of the plant because they
have not grown yet.
Rose plant is the class and the samples generated from the rose plant are
instances of that class. (*)
Samples are the class and the rose plant is the instances of samples.
Correct
15. You design a Circle class with various fields and methods. Which of the following could
be fields in this class? Distinguish which of these are between the properties and Mark for Review
behavior. (1) Points
radius (*)
color (*)
calculateCircumference()
calculateArea()
calculateDiameter()
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Hello World
Hello
World (*)
Hello
World
Correct
2. 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
Correct
Correct
intVal (*)
String
Hello
int
strVal (*)
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Correct
Correct
byte
short
int
long (*)
Correct
True (*)
False
Correct
8
9 (*)
34
7
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)
Value of age: 20
Value of age: 8
Value of age: 10 (*)
Value of age: 20
Value of age: 28
Value of age: 38
Value of age: 20
Value of age: 208
Value of age: 20810
Value of age: 20
Value of age: 8
Value of age: 9
Correct
12. Assuming x is an int, which of the following are ways to increment the value of x by 1?
Mark for Review
(1) Points
x = x +1; (*)
x = +1;
x+;
x++; (*)
x += 1; (*)
Correct
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
14. Which two are recommended practices for naming final variables?
Mark for Review
(1) Points
Correct
+ (*)
– (*)
#
@
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 3 Quiz 2 - L3-L5
(Answer all questions in this section)
Correct
True (*)
False
Correct
8. The Scanner class considers space as the default delimiter while reading the input.
Mark for Review
(1) Points
True (*)
False
Correct
Callables
Tokens (*)
Future
Integer
Correct
10. A double with the value of 20.5 is cast to an int. What is the value of the int?
Mark for Review
(1) Points
25
20.5
20 (*)
21
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
True
False (*)
Correct
True
False (*)
Correct
True (*)
False
Correct
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Correct
NumberFormatException (*)
ArithmeticException
NullPointerException
ValueNotFoundException
Correct
Correct
14. When the result of an expression is assigned to a temporary memory location, what is
the size of memory allocated? Mark for Review
(1) Points
The size of the largest data type used in the expression. (*)
A default size is allocated.
The size of the any data type used in the expression.
The size of the smallest data type used in the expression.
Correct
15. A short data type can be promoted to which of the following types?
Mark for Review
(1) Points
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Correct
3. Which is a valid way of calling the testMethod in the TestClass? Assume a testInstance
has been created. Mark for Review
(1) Points
public void testMethod(int x, double y){
System.out.println(x/y);
}
testInstance.testMethod(10);
testInstance.testMethod(10, 3.5, 0);
testInstance.testMethod(10, 3.5); (*)
testInstance.testMethod(3.5, 10);
testInstance.testMethod(3.5);
Correct
True (*)
False
Correct
5. Which of the following two operations are appropriate for the main method?
Mark for Review
(1) Points
Correct
When you don’t want to repeat similar lines of code to describe an object’s
behavior. (*)
To group similar data types together
For every five to six lines of code.
When you don’t find similar lines of code to describe an object’s behavior.
Correct
True (*)
False
new (*)
System
void
instance
Correct
True (*)
False
Correct
10. Which two are valid import statements of the Scanner class?
Mark for Review
(1) Points
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
java.awt
java
awt.font
java.awt.font (*)
Correct
12. The JFrame and JOptionPane classes are in the javax.swing package. Which two will
import those classes? Mark for Review
(1) Points
Correct
Correct
14. The classes of the Java class library are organized into packages.
Mark for Review
(1) Points
True (*)
False
Correct
15. Which is a risk of using fully qualified class names when importing?
Mark for Review
(1) Points
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
1. You need to generate random integer values in the range 2 through 10. This code
fragment will produce the desired result. Mark for Review
(1) Points
Random r = new Random();
r.nextInt(9) + 2;
True (*)
False
Correct
Number
Double
Integer
Random (*)
Correct
4. You need to generate random integer values between 0 and 80 (inclusive). Which
statement should you use? Mark for Review
(1) Points
nextInt();
nextInt(81); (*)
nextInt(80);
nextInt(0-79);
Correct
5. A String is a sequence characters.
Mark for Review
(1) Points
True (*)
False
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
length() (*)
findLength ()
charAt()
compareTo()
Correct
7. The replaceFirst() method replaces only the first occurrence of matching character
pattern in a string. Mark for Review
(1) Points
True (*)
False
Correct
Correct
rld! (*)
rld
ld!
orld!
Correct
True
False (*)
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
11. The indexOf() method returns the index value of a character in the string.
Mark for Review
(1) Points
True (*)
False
Correct
True (*)
False
Correct
13. The Math class methods can be called without creating an instance of a Math object.
Mark for Review
(1) Points
True (*)
False
Correct
Correct
java.awt
java.net
java.io
java.lang (*)
Correct
Previous Page 3 of 3 Summary
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 5 Quiz
(Answer all questions in this section)
1. The equal sign (=) is used to make an assignment, whereas the == sign merely makes
a comparison and returns a boolean. Mark for Review
(1) Points
True (*)
False
Correct
for loop
do while loop
switch statement (*)
if statement (*)
if/else statement (*)
3. Which operator is used to test if both sides of a boolean expression are equal?
Mark for Review
(1) Points
<=
== (*)
=
>=
Correct
Correct
5. An if/else statement is used when you need to choose between two alternatives.
Mark for Review
(1) Points
True (*)
False
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 5 Quiz
(Answer all questions in this section)
JavaProgramming
Java Programming
True (*)
False
Correct
yes/no
0/1
true/false (*)
good/bad
Correct
8. The switch statement is a more efficient way to write code when dealing with a large
range of unknown values. Mark for Review
(1) Points
True
False (*)
Correct
Correct
10. A break statement causes control to transfer to the end of the switch statement.
Mark for Review
(1) Points
True (*)
False
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 5 Quiz
(Answer all questions in this section)
11. Which two statements are true about the default statement?
Mark for Review
(1) Points
Compilation error
I scored 10 points (*)
I scored 1 point 10 points
I scored 1 point
Correct
13. An employee is eligible for a bonus based on certain criteria.
Under what conditions does “Eligible for a bonus” print? Mark for Review
(1) Points
int rating;
int experience;
if (rating > 1 && experience == 5) {
System.out.println (“Eligible for a bonus”);
}
Correct
14. In the OR (||) test, if the first expression on the left hand side is true then there is no
need to evaluate the second statement. Mark for Review
(1) Points
True (*)
False
Correct
True (*)
False
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 6 Quiz
(Answer all questions in this section)
1. Which statement is true?
Mark for Review
(1) Points
2. A post-test loop evaluates its condition at the end of the loop instead of the beginning.
Mark for Review
(1) Points
True (*)
False
Correct
3. The while loop continually executes a block of statements while a particular condition is
false. Mark for Review
(1) Points
True
False (*)
Correct
4. After the loop is terminated, the statement immediately following the loop body is
executed. Mark for Review
(1) Points
True (*)
False
Correct
The statement in a while loop will execute zero or more times. (*)
If the condition of the loop is true initially, the statements are never executed.
The statements of a while loop will execute one or more times.
If the condition of a pre-test loop is false, the statements in the loop are never
executed. (*)
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 6 Quiz
(Answer all questions in this section)
1 5 25 125
1 5 25 125 175
5 25 125
No output. (*)
Correct
7. The purpose of adding comments is to increase the ability to understand the logic
easily. Mark for Review
(1) Points
True (*)
False
Correct
continue
catch
switch
break (*)
Correct
var1: 0, var2: 0
var1: 0, var2: 1
var1: 1, var2: 0
var1: 1, var2: 1
(*)
var1: 0, var2: 0
var1: 1, var2: 1
var1: 2, var2: 0
var1: 0, var2: 0
var1: 0, var2: 1
var1: 0, var2: 2
var1: 1, var2: 0
var1: 1, var2: 1
var1: 1, var2: 2
var1: 2, var2: 0
var1: 2, var2: 1
var1: 2, var2: 2
var1: 0, var2: 0
var1: 0, var2: 1
var1: 1, var2: 0
var1: 1, var2: 1
var1: 2, var2: 0
var1: 2, var2: 1
Correct
10. The for loop provides a complicated way to iterate over a range of values.
Mark for Review
(1) Points
True
False (*)
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 6 Quiz
(Answer all questions in this section)
Correct
12. Given:
Mark for Review
for(int i = 0; i > 10; i++){ } (1) Points
What type of variable is i?
Member
Local (*)
Global
Static
Correct
13. You need to calculate the squares of numbers from 1 to 5. Which of the items should
be present in your looping statement? Mark for Review
(1) Points
Condition Expression , Update Expression
Initialization Expression , Condition Expression , Update Expression (*)
Initialization Expression , Update Expression
Initialization Expression , Condition Expression
Correct
Correct
15. Loops are used in programs for repeated execution of one or more statements until a
terminating condition is reached. Mark for Review
(1) Points
True (*)
False
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
True (*)
False
Incorrect. Refer to Section 7 Lesson 1.
2. First, you decide the radius of each circle in the logo. Then using the same radius you
draw 5 circles of same size. All these circles will have properties like radius and color. All Mark for Review
circles share behaviors to calculate circumference and area. Can you identify which of (1) Points
the following is an object?
radius
fiveCircles
circle (*)
circumference
Correct
Use a return statement and define the method’s return type as non-void (*)
Define a variable as a field member of the method
Define the method return type as void
Pass a variable as an argument to the method.
Correct
4. Which two statements are true about objects of the same class?
Mark for Review
(1) Points
Each new instance of an object will have a different location in memory. (*)
Each object will have the same reference variable to the location in memory.
All objects are equal.
All objects of the same class have the same methods. (*)
1
0
2
3 (*)
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
True (*)
False
Correct
True (*)
False
Correct
new (*)
address
memory
store
Correct
9. Objects are accessed using reference variables.
Mark for Review
(1) Points
True (*)
False
Correct
True (*)
False
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
11. In Java, the this keyword can be used to reference the current object’s fields and
methods. Mark for Review
(1) Points
True (*)
False
Correct
Correct
13. When you write your own constructor, the default constructor is no longer available.
Mark for Review
(1) Points
True (*)
False
Correct
14. You create an Employee object with a String employeeName field. What is the default
value for employeeName? Mark for Review
(1) Points
null (*)
A space
“Name”
“default”
Correct
15. An object reference with a null value points to an empty location in memory.
Mark for Review
(1) Points
True (*)
False
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
True (*)
False
Correct
2. What is encapsulation?
Mark for Review
(1) Points
Correct
Correct
4. To make fields directly accessible to other classes, the class fields must be marked
public. Mark for Review
(1) Points
True (*)
False
Correct
final
public (*)
static
private (*)
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
True (*)
False
Correct
8. Given the following code, why does your IDE complain that “non-static variable name
cannot be referenced from a static context”? Mark for Review
(1) Points
public class Employee{
public static int employeeID;
public String name;
Correct
9. If you need to make a particular variable belong to a class rather than any individual
instance, what type of variable should you use? Mark for Review
(1) Points
A public variable.
A static variable. (*)
A local variable.
A private variable.
10. An object must be instantiated before its non-static fields and methods can be
accessed. Mark for Review
(1) Points
True (*)
False
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
True
False (*)
True (*)
False
Correct
13. Method overloading can be a useful technique for defining methods with similar
functionality or calculations. Mark for Review
(1) Points
True (*)
False
Correct
14. How would you complete this code so that one add method calls the other add
method? Mark for Review
(1) Points
public int add(int a, int b, int c) {
return(a+b+c);
}
public int add(int a, int b){
//Complete this line.
}
Correct
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 8 Quiz
(Answer all questions in this section)
Correct
Correct
3. What is the output?
Mark for Review
int[] array = {10, 20, 30}; (1) Points
int b = 0;
try{
System.out.println("1");
int c = (array[3] / b);
System.out.println("2");
}
catch(ArithmeticException ex){
System.out.println("Arithmetic Exception");
}
catch(ArrayIndexOutOfBoundsException ex){
System.out.println("Array index out of bounds");
}
1
Arithmetic Exception
1
Array index out of bounds (*)
1
2
Array index out of bounds
1
2
Array index out of bounds
Correct
True (*)
False
A semi-colon is missing.
A datatype is incorrect. (*)
A variable hasn’t been assigned a value.
A variable name is misspelled.
Correct
Page 1 of 3 Next Summary
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 8 Quiz
(Answer all questions in this section)
6. Wh
at
are Mark
two for
disa Revie
dva w
nta (1)
ges Point
of s
addi
ng
prin
t
stat
eme
nts
for
deb
uggi
ng?
(Ch
oos
e all
corr
ect
ans
wer
s)
Pri
nt
sta
te
m
en
ts
ca
nn
ot
pri
nt
th
e
val
ue
s
of
va
ria
ble
s.
To
o
m
an
y
pri
nt
sta
te
m
en
ts
lea
d
to
inf
or
m
ati
on
ov
erl
oa
d.
(*)
Pri
nt
sta
te
m
en
ts
ca
nn
ot
pri
nt
th
e
val
ue
s
of
an
ob
jec
t’s
fiel
ds.
It’
s
te
dio
us
to
re
m
ov
e
pri
nt
sta
te
m
en
ts.
(*)
C
or
re
ct
7. Wh
at is
the Mark
star for
ting Revie
inde w
x of (1)
an Point
arra s
y?
Yo
u
ca
n
st
art
wi
th
an
yt
hi
ng
0
(
*
)
It
de
pe
nd
s
on
th
e
ty
pe
of
th
e
ar
ra
y.
1
C
or
re
ct
8. You
can
acc Mark
ess for
the Revie
size w
of (1)
any Point
arra s
y by
usin
g
the
arra
y’s
“len
gth”
pro
pert
y.
T
ru
e
(
*
)
F
al
se
C
or
re
ct
9. Arra
ys
are Mark
like for
vari Revie
able w
s (1)
whi Point
ch
s
mus
t be
decl
are
d
prio
r to
use.
T
ru
e
(
*
)
F
al
se
C
or
re
ct
10. Give
n:
int Mark
x[]; for
Wh Revie
at is w
the (1)
valu Point
e of s
x?
n
ul
l
(
*
)
1
So
m
e
ra
nd
o
m
nu
m
be
r.
0
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 8 Quiz
(Answer all questions in this section)
Correct
10 (*)
ArrayIndexOutOfBoundsException
0
1
Correct
13. Which two are limitations of an array of primitives (ie: int[] x)?
Mark for Review
(1) Points
ListIterator
do- while loop (*)
for-each loop
iterator
True (*)
False
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 9 Quiz
(Answer all questions in this section)
Correct
Yellow (*)
Red
Green
Blue
Correct
True (*)
False
Correct
4. How would you create a custom color that is pure cyan (equal parts green and blue)?
Mark for Review
(1) Points
Correct
setX(double d)
setLayoutX(double d)
setStroke(Paint paint)
setStrokeWidth(double d) (*)
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 9 Quiz
(Answer all questions in this section)
setOnMouseReleased()
setOnMouseMoved()
setOnMouseClicked() (*)
setOnMouseDragged()
Correct
True (*)
False
Correct
True (*)
False
Correct
9. Lambda Expressions provide much more effective and cleaner syntax for working with
GUI applications and sorting lists. Mark for Review
(1) Points
True (*)
False
Correct
10. JavaFX doesn’t provide you with UI elements, shapes and text. So you must always
create your own graphics. Mark for Review
(1) Points
True
False (*)
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 9 Quiz
(Answer all questions in this section)
11. The start() method is the entry point for all JavaFX applications.
Mark for Review
(1) Points
True (*)
False
Correct
True (*)
False
Correct
13. Which type of Root Node allows Nodes to be placed anywhere?
Mark for Review
(1) Points
HBox
Group (*)
TilePane
StackPane
Button
ScrollBar
Object (*)
ImageView
Correct
15. How would you set the title of the Stage primaryStage?
Mark for Review
(1) Points
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 6
(Answer all questions in this section)
1. After the loop is terminated, the statement immediately following the loop body is
executed. Mark for Review
(1) Points
True (*)
False
Correct
True (*)
False
Correct
Correct
4. Given:
Mark for Review
for(int i = 0; i > 10; i++){ } (1) Points
What type of variable is i?
Global
Local (*)
Static
Member
Correct
5. Which two operators cannot be used as the conditional expression in a for loop?
Mark for Review
(1) Points
(Choose all correct answers)
!< (*)
!=
<
!> (*)
==
Correct
Summar
Page 1 of 10 Next
y
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 6
(Answer all questions in this section)
Correct
Correct
8. A continue statement is used to skip the remaining statements in the body of a loop
and continue with the next iteration of the loop. Mark for Review
(1) Points
True (*)
False
Correct
catch
break (*)
switch
continue
Correct
Section 7
(Answer all questions in this section)
Correct
Previous Page 2 of 10 Next Summary
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 7
(Answer all questions in this section)
True (*)
False
Correct
True (*)
False
Correct
Correct
Correct
final
private (*)
static
public (*)
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 7
(Answer all questions in this section)
16. You have created an Employee class with all required fields and methods. 10
employees join the company. Should you copy and paste the Employee class for all 10 Mark for Review
employees? (1) Points
True
False (*)
Correct
17. The structure of a class consists of properties and behaviors.
Mark for Review
(1) Points
True (*)
False
Correct
True (*)
False
Correct
True (*)
False
Correct
20. Given the following code, why does your IDE complain that “non-static variable name
cannot be referenced from a static context”? Mark for Review
(1) Points
public class Employee{
public static int employeeID;
public String name;
Correct
Previous Page 4 of 10 Next Summary
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 7
(Answer all questions in this section)
21. You create an Employee object with a String employeeName field. What is the default
value for employeeName? Mark for Review
(1) Points
null (*)
A space
“Name”
“default”
Correct
True (*)
False
Correct
23. How would you instantiate the Employee class from a main method located in another
class? Mark for Review
(1) Points
public class Employee{
private String name;
private double salary;
Correct
24. A constructor is a special method which is commonly used to set the initial values of
an object’s fields. Mark for Review
(1) Points
True (*)
False
Correct
25. What will happen when you try to access an object reference with a null value?
Mark for Review
(1) Points
NullPointerException. (*)
The value null is retrieved from the memory location.
An empty object is returned.
You will get a compilation error.
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 7
(Answer all questions in this section)
No memory is allocated
Heap memory
Stack memory (*)
PileDriver memory
Correct
27. Java automatically clears the memory once occupied by an object using garbage
collection. Mark for Review
(1) Points
True (*)
False
Correct
Student (*)
null
Class
String
Correct
Section 8
(Answer all questions in this section)
29. How could you declare an ArrayList so that it can store true or false values?
Mark for Review
(1) Points
Correct
True (*)
False
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 8
(Answer all questions in this section)
ListIterator
iterator
do- while loop (*)
for-each loop
Correct
True (*)
False
Correct
y = 3 + * 5;
x = ( 3 + 5;
int y;
y++; (*)
int x=2
Correct
34. What are two advantages of adding print statements for debugging?
Mark for Review
(1) Points
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 8
(Answer all questions in this section)
36. Using the NetBeans debugger, you can set breakpoints and trace through a program
one line at a time. Mark for Review
(1) Points
True (*)
False
Correct
37. What is an array?
Mark for Review
(1) Points
Correct
[]int size;
int[] size; (*)
int array size;
int size[]; (*)
Correct
39. An array allows you to create a single identifier that can be used to organize many
items of the same data type. Mark for Review
(1) Points
True (*)
False
Correct
40. The Java compiler does not check for an ArrayIndexOutOfBoundsException during the
compilation of a program containing arrays. Mark for Review
(1) Points
True (*)
False
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 8
(Answer all questions in this section)
1
Arithmetic Exception
1
Array index out of bounds (*)
1
2
Array index out of bounds
1
2
Array index out of bounds
Correct
True (*)
False
Correct
Section 9
(Answer all questions in this section)
True (*)
False
Correct
setOnMouseMoved()
setOnMouseClicked() (*)
setOnMouseReleased()
setOnMouseDragged()
Correct
45. JavaFX doesn’t provide you with UI elements, shapes and text. So you must always
create your own graphics. Mark for Review
(1) Points
True
False (*)
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 9
(Answer all questions in this section)
Correct
47. The start() method is the entry point for all JavaFX applications.
Mark for Review
(1) Points
True (*)
False
Correct
HBox
TilePane
StackPane
Group (*)
Correct
Correct
50. Which color is not directly used when creating custom Color.rgb()?
Mark for Review
(1) Points
Blue
Yellow (*)
Green
Red
Correct