Oraclenew
Oraclenew
Oraclenew
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 Mark for
statement is true about breakpoints?
Review
(1) Points
Correct
Review
(1) Points
Correct
3. Which of the following two features are supported by the NetBeans IDE. Mark for
Review
(1) Points
4. Which of the following three statements are true about breakpoint? 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.
5. Which of the following 2 statements are true about whitespace? Mark for
Review
(1) Points
Correct
Section 2 Quiz
(Answer all questions in this section)
6. Which two are the correct syntax for adding comments? Mark for
Review
(1) Points
Correct
7. Which of the following are adequate definitions for components of the Spiral Mark for
Model of Development?
Review
(1) Points
Review
(1) Points
True (*)
False
Correct
9. During the Design phase of software development, the programmer Mark for
implements features gathered during the Requirement phase.
Review
(1) Points
True
False (*)
Correct
10. A software feature may allow the user to perform a specific task. Mark for
Review
(1) Points
True (*)
False
Correct
Section 2 Quiz
(Answer all questions in this section)
11. In the code example below, identify any methods: Mark for
empId
name
salary
displaySalary() (*)
Correct
12. There are several fields and methods in a Shirt class. Which of the following Mark for
could be a method in the Shirt class?
Review
(1) Points
getShirtSize() (*)
color
size
price
Correct
13. In object oriented programming, there is an emphasis on which of the Mark for
following two:
Review
(1) Points
Correct
14. Which of the following language is called a procedural language? Mark for
Review
(1) Points
Java C
C (*)
C++
Java
Correct
15. An object may interact with another object by invoking methods. Mark for
Review
(1) Points
True (*)
False
Correct
Hello
World
Hello
Hello World
World (*)
Correct
Review
(1) Points
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
Review
(1) Points
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
(1) Points
True (*)
False
Correct
7. Which two data types are appropriate for their variable? Mark for
Review
(1) Points
Correct
Review
(1) Points
const
final (*)
static
break
Correct
9. Which data type is most commonly used to represent numeric data? Mark for
Review
(1) Points
int (*)
float
String
short
Correct
10. Which of the following data types is the largest? Mark for
Review
(1) Points
byte
short
int
long (*)
Correct
11. Assuming x is an int, which of the following are ways to increment the value Mark for
of x by 1?
Review
(1) Points
x = x +1; (*)
x = +1;
x+;
x++; (*)
x += 1; (*)
12. What is the output? public static void main(String args[]) { Mark for
int x = 100;
int y = x;
y++; Review
System.out.println("Value of x is " + x); (1) Points
System.out.println("Value of y is " + y);
}
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
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
15. What is the range of the byte data type? Mark for
Review
(1) Points
Correct
1. The Scanner class considers space as the default delimiter while reading the Mark for
input.
Review
(1) Points
True (*)
False
Correct
2. Which two statements are true about the Scanner class? Mark for
Review
(1) Points
Correct
Review
(1) Points
Callables
Integer
Tokens (*)
Future
Correct
4. Which is the correct declaration for a char data type? Mark for
Review
(1) Points
Correct
Review
(1) Points
True (*)
False
Correct
Review
(1) Points
True (*)
False
Correct
7. Which two statements compile? Mark for
Review
(1) Points
Correct
Review
(1) Points
True
False (*)
Correct
Review
(1) Points
True (*)
False
Correct
10. What is the correct way to cast a long to an int? Mark for
Review
(1) Points
11. Which two statements are true about type casting? Mark for
Review
(1) Points
Correct
12. Automatic promotion from smaller data type to a larger data type is not Mark for
allowed in Java.
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 Mark for
int?
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
(1) Points
Correct
1. Which two are valid import statements of the Scanner class? Mark for
Review
(1) Points
Correct
2. Which of the following wild card character is used to import all the classes in Mark for
a particular package?
Review
(1) Points
~
!
* (*)
;
Correct
java
awt.font
java.awt
java.awt.font (*)
4. Which is a risk of using fully qualified class names when importing? Mark for
Review
(1) Points
Review
(1) Points
True (*)
False
Correct
6. The JFrame and JOptionPane classes are in the javax.swing package. Which Mark for
two will import those classes?
Review
(1) Points
import javax.swing;
import javax.swing.JOptionPane;
import javax.swing.JFrame; (*)
import javax.swing.J*;
import javax.swing.*; (*)
Correct
import package.className;
Review
One is the package name and the other is the classname. (1) Points
True (*)
False
Correct
8. Methods allow all instance of a class to share same behaviors. Mark for
Review
(1) Points
True (*)
False
Correct
Review
(1) Points
True (*)
False
Correct
10. Which of the following two operations are appropriate for the main method? Mark for
Review
(1) Points
Correct
11. Which is a valid way of calling the testMethod in the TestClass? Assume a Mark for
testInstance has been created.
Correct
12. void type methods don’t return any values Mark for
Review
(1) Points
True (*)
False
Correct
13. Which of the following are the arguments in the following method? Mark for
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 Mark for
accessed in Java?
Review
(1) Points
Correct
15. How many arguments does the following method accept? Mark for
2
0
3 (*)
1
Correct
Review
(1) Points
Correct
Review
(1) Points
2.718
The value varies.
0
3.141 (*)
Correct
3. The Math class methods can be called without creating an instance of a Math Mark for
object.
Review
(1) Points
True (*)
False
Correct
4. All the methods in the Math class are static methods. Mark for
Review
(1) Points
True (*)
False
Correct
Review
(1) Points
True (*)
False
Correct
Review
(1) Points
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
11. The String class must be imported using java.lang.String; Mark for
Review
(1) Points
True
False (*)
Correct
12. You need to generate random integer values between 0 and 80 (inclusive). Mark for
Which statement should you use?
Review
(1) Points
nextInt();
nextInt(80);
nextInt(0-79);
nextInt(81); (*)
13. Using the Random class requires an import statement. Mark for
Review
(1) Points
True (*)
False
Correct
14. Which class is used to generate random numbers? Mark for
Review
(1) Points
Random (*)
Number
Double
Integer
Correct
15. Which values are returned by the method nextBoolean(); Mark for
Review
(1) Points
Nothing is returned.
Either a true or false. (*)
Returns the next value.
An integer value.
Correct
Section 5 Quiz
(Answer all questions in this section)
1. In a boolean expression which uses the && operator, what would make this Mark for
expression evaluate to true?
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 Mark for
there is no need to evaluate the second statement.
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 Mark for
there is no need to evaluate the second statement.
Review
(1) Points
True (*)
False
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
String (*)
float
int (*)
boolean
Correct
7. The switch statement is a more efficient way to write code when dealing Mark for
with a large range of unknown values.
Review
(1) Points
True
False (*)
8. A break statement causes control to transfer to the end of the switch Mark for
statement.
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 Mark for
merely makes a comparison and returns a boolean.
Review
(1) Points
True (*)
False
Correct
Section 5 Quiz
(Answer all questions in this section)
11. A String comparison with == compares the Strings’ locations in memory Mark for
and not the content of the String.
Review
(1) Points
True (*)
False
Correct
Bob is 43 (*)
Bob is 50
Bob is 43 Bob is 50
No output
Correct
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 Mark for
equal?
Review
(1) Points
<=
== (*)
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 Mark for
plans.
Hi Friends, Review
There’s a new movie “Attack of the Duke!” premiering this Friday at Oracle (1) Points
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.
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
2. What is the correct order of steps in the Spiral Model of Development? Mark for
Review
(1) Points
3. If the requirement step of the Spiral Model of development is forgotten, Mark for
which of the following could occur?
Review
(1) Points
Review
(1) Points
True (*)
False
Correct
5. Which two are the correct syntax for adding comments? Mark for
Review
(1) Points
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
6. Which of the following 2 statements are true about whitespace? Mark for
Review
(1) Points
Correct
name
salary
displaySalary() (*)
empId
Correct
True (*)
False
Correct
9. You have a beautiful garden at home. On Sunday, you start budding your Mark for
rose plant to make few more samples of rose plants to plant in the garden.
Can you categorize how this scenario could be represented by classes and
instances? Review
(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)
10. Which is the correct declaration for a char data type? Mark for
Review
(1) Points
Correct
Section 3
(Answer all questions in this section)
11. A String can be created by combining multiple String Literals. Mark for
Review
(1) Points
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
Review
(1) Points
const
final (*)
static
break
Correct
Review
(1) Points
True (*)
False
Correct
Section 3
(Answer all questions in this section)
16. When the result of an expression is assigned to a temporary memory Mark for
location, what is the size of memory allocated?
Review
(1) Points
Correct
Review
(1) Points
Correct
18. Automatic promotion from smaller data type to a larger data type is not Mark for
allowed in Java.
Review
(1) Points
True
False (*)
Correct
19. Identify the names of two variables used in the given code. Mark for
int
String
strVal (*)
Hello
intVal (*)
Correct
Hello
Hello
World
World (*)
Hello World
Correct
Section 3
(Answer all questions in this section)
21. Java is a strongly typed language; therefore you must declare a data type Mark for
for all variables.
Review
(1) Points
True (*)
False
Correct
22. Which two statements are true about the Scanner class? Mark for
Review
(1) Points
Correct
23. The Scanner class accepts input in which form? Mark for
Review
(1) Points
Tokens (*)
Callables
Future
Integer
Correct
24. It's best-practice to close the Scanner stream when finished Mark for
Review
(1) Points
True (*)
False
Correct
Section 4
(Answer all questions in this section)
Review
(1) Points
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
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
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.
When you don’t want to repeat similar lines of code to describe an
object’s behavior. (*)
28. Which is a valid way of calling the testMethod in the TestClass? Assume a Mark for
testInstance has been created.
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
Section 6 Quiz
(Answer all questions in this section)
1. The purpose of adding comments is to increase the ability to understand the Mark for
logic easily.
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
Review
(1) Points
do-while (*)
while
forEach
for
Correct
5. A do-while will always execute statements contained in the loop at least Mark for
once.
Review
(1) Points
True (*)
False
Correct
Section 6 Quiz
(Answer all questions in this section)
6. Which two statements are true about the while loop. Mark for
Review
(1) Points
Correct
Review
(1) Points
for (*)
while (*)
forEach
do-while
8. A while loop is often used with Scanner input as you don't know many times Mark for
you'll need to re-prompt the user if they type bad data.
Review
(1) Points
True (*)
False
Correct
9. The while loop continually executes a block of statements while a particular Mark for
condition is false.
Review
(1) Points
True
False (*)
Correct
10. Which two are valid syntax to create a for loop? Mark for
Review
(1) Points
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
Correct
Review
(1) Points
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
Local (*)
Member
Static
Global
Correct
Review
(1) Points
True (*)
False
Correct
2. In the following statements, how many employee objects are created? Mark for
1
3 (*)
0
2
Correct
3. Which type of memory is allocated for the code below? Mark for
int x = 1;
int y = 2; Review
x=y; (1) Points
Correct
4. Java developers don't need to know an object’s location in memory. Mark for
Review
(1) Points
True (*)
False
Correct
Class
null
Student (*)
String
Correct
6. Java automatically clears the memory once occupied by an object using Mark for
garbage collection.
Review
(1) Points
True (*)
False
Correct
Review
(1) Points
boolean
int
String (*)
double
Correct
Review
(1) Points
True (*)
False
Correct
9. Which statement is true about the default constructor of a class? Mark for
Review
(1) Points
Correct
10. How would you instantiate the Employee class from a main method located Mark for
in another class?
Correct
Previous Page 2 of 3 Next Summary
11. In Java, the this keyword can be used to reference the current object’s fields Mark for
and methods.
Review
(1) Points
True (*)
False
Correct
12. A constructor is a special method which is commonly used to set the initial Mark for
values of an object’s fields.
Review
(1) Points
True (*)
False
Correct
13. You have created an Employee class with all required fields and methods. Mark for
10 employees join the company. Should you copy and paste the Employee
class for all 10 employees?
Review
(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
1. Which two statements are true about private access modifier? Mark for
Review
(1) Points
Correct
2. An object reference directs you from one object to another. Mark for
Review
(1) Points
True (*)
False
Review
(1) Points
Correct
Review
(1) Points
final
static
private (*)
public (*)
Correct
5. To make fields directly accessible to other classes, the class fields must be Mark for
marked public.
Review
(1) Points
True (*)
False
Correct
Review
(1) Points
True (*)
False
Correct
Review
(1) Points
Review
(1) Points
True (*)
False
Correct
9. You can write more than one constructor in a class. Mark for
Review
(1) Points
True (*)
False
Correct
10. Method overloading can be a useful technique for defining methods with Mark for
similar functionality or calculations.
Review
(1) Points
True (*)
False
Correct
Review
(1) Points
Correct
12. Static variables of a class can be accessed, even if the class has not been Mark for
instantiated.
Review
(1) Points
True (*)
False
Correct
Review
(1) Points
True (*)
False
Correct
14. An object must be instantiated before its non-static fields and methods can Mark for
be accessed.
Review
(1) Points
True (*)
False
Correct
15. Given the following code, why does your IDE complain that “non-static Mark for
variable name cannot be referenced from a static context”?
Correct
Review
(1) Points
Integer
float (*)
int (*)
String
Review
(1) Points
String (*)
Boolean
Integer
Byte
Correct
Review
(1) Points
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
01234 (*)
012345
123
12345
Correct
5. The Java compiler does not check for an ArrayIndexOutOfBoundsException Mark for
during the compilation of a program containing arrays.
Review
(1) Points
True (*)
False
Correct
Section 8 Quiz
(Answer all questions in this section)
null (*)
0
Some random number.
1
Correct
Correct
Review
(1) Points
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
Section 8 Quiz
(Answer all questions in this section)
11. If the try block succeeds then no exception has occurred. Mark for
Review
(1) Points
True (*)
False
Correct
Review
(1) Points
Correct
13. Using the NetBeans debugger, you can set breakpoints and trace through a Mark for
program one line at a time.
Review
(1) Points
True (*)
False
Correct
14. What are two disadvantages of adding print statements for debugging? Mark for
Review
(1) Points
Correct
15. Identify where there is a potential bug in this code: Mark for
Correct
Section 9 Quiz
(Answer all questions in this section)
1. Audio can be played by referencing the Audio object directly. Mark for
Review
(1) Points
True (*)
False
Correct
Review
(1) Points
setOnMouseClicked() (*)
setOnMouseDragged()
setOnMouseMoved()
setOnMouseReleased()
Correct
3. JavaFX doesn’t provide you with UI elements, shapes and text. So you must Mark for
always create your own graphics.
Review
(1) Points
True
False (*)
Correct
4. Lambda Expressions provide much more effective and cleaner syntax for Mark for
working with GUI applications and sorting lists.
Review
(1) Points
True (*)
False
Correct
5. When you write code for MouseEvents, you are telling a Node to listen for a Mark for
particular event.
Review
(1) Points
True (*)
False
Correct
Section 9 Quiz
(Answer all questions in this section)
Review
(1) Points
True (*)
False
Correct
7. How would you set the title of the Stage primaryStage? Mark for
Review
(1) Points
Correct
8. The start() method is the entry point for all JavaFX applications. Mark for
Review
(1) Points
True (*)
False
Correct
True (*)
False
Correct
Review
(1) Points
Object (*)
Button
ImageView
ScrollBar
Correct
Section 9 Quiz
(Answer all questions in this section)
11. JavaFX Ensemble contains code examples of JavaFX features. Mark for
Review
(1) Points
True (*)
False
Correct
12. Which is the correct syntax to instantiate a JavaFX Rectangle? Mark for
Review
(1) Points
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 Mark for
and blue)?
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
Section 2 Quiz
(Answer all questions in this section)
1. When the program runs normally (when not in debug mode), which Mark for
statement is true about breakpoints?
Review
(1) Points
Correct
2. Which of the following 2 statements are true about whitespace? Mark for
Review
(1) Points
Correct
3. Which two are the correct syntax for adding comments? Mark for
Review
(1) Points
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
4. You can set any number of breakpoints for your program. Mark for
Review
(1) Points
True (*)
False
Correct
5. Which of the following three statements are true about breakpoint? Mark for
Review
(1) Points
Correct
Section 2 Quiz
(Answer all questions in this section)
Review
(1) Points
Correct
7. During the Design phase of software development, the programmer Mark for
implements features gathered during the Requirement phase.
Review
(1) Points
True
False (*)
Correct
8. A software feature may allow the user to perform a specific task. Mark for
Review
(1) Points
True (*)
False
Correct
Review
(1) Points
True (*)
False
Correct
10. Which of the following are adequate definitions for components of the Spiral Mark for
Model of Development?
Review
(1) Points
Correct
Section 2 Quiz
(Answer all questions in this section)
11. There are several fields and methods in a Shirt class. Which of the following Mark for
could be a method in the Shirt class?
Review
(1) Points
color
getShirtSize() (*)
size
price
Correct
12. In object oriented programming, an object comprises of properties and Mark for
behaviors where properties represented as fields of the object and behavior
is represented as method.
Review
(1) Points
True (*)
False
Correct
13. In the code example below, identify any methods: Mark for
empId
salary
displaySalary() (*)
name
Correct
14. You have a beautiful garden at home. On Sunday, you start budding your Mark for
rose plant to make few more samples of rose plants to plant in the garden.
Can you categorize how this scenario could be represented by classes and
instances? Review
(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 Mark for
following could be fields in this class? Distinguish which of these are
between the properties and behavior.
Review
(1) Points
radius (*)
color (*)
calculateCircumference()
calculateArea()
calculateDiameter()
Correct
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
3. Which of the following two statements are true about variables? Mark for
Review
(1) Points
Correct
Review
(1) Points
Correct
5. Identify the names of two variables used in the given code. Mark for
intVal (*)
String
Hello
int
strVal (*)
Correct
6. Which two data types are appropriate for their variable? Mark for
Review
(1) Points
Correct
Review
(1) Points
Correct
Review
(1) Points
byte
short
int
long (*)
Correct
Review
(1) Points
True (*)
False
Correct
10. What value is assigned to x? Mark for
int x = 25 - 5 * 4 / 2 - 10 + 4;
Review
(1) Points
8
9 (*)
34
7
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 Mark for
of x by 1?
Review
(1) Points
x = x +1; (*)
x = +1;
x+;
x++; (*)
x += 1; (*)
Correct
13. What is the output? public static void main(String args[]) { Mark for
int x = 100;
int y = x;
y++; Review
System.out.println("Value of x is " + x); (1) Points
System.out.println("Value of y is " + y);
}
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
6. Which two statements are true about String concatenation. Mark for
Review
(1) Points
Correct
7. System.in readies Scanner to collect input from the console. Mark for
Review
(1) Points
True (*)
False
Correct
8. The Scanner class considers space as the default delimiter while reading Mark for
the input.
Review
(1) Points
True (*)
False
Correct
Review
(1) Points
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 Mark for
int?
Review
(1) Points
25
20.5
20 (*)
21
Correct
Review
(1) Points
True
False (*)
Correct
2. Double quotes may be used with char literal values. Mark for
Review
(1) Points
True
False (*)
3. Which is the correct declaration for a char data type? Mark for
Review
(1) Points
Correct
Review
(1) Points
True (*)
False
Correct
Correct
Review
(1) Points
Correct
12. Which exception occurs because a String cannot be parsed as an int? Mark for
Review
(1) Points
NumberFormatException (*)
ArithmeticException
NullPointerException
ValueNotFoundException
Correct
13. What is the correct way to cast a long to an int? Mark for
Review
(1) Points
Correct
14. When the result of an expression is assigned to a temporary memory Mark for
location, what is the size of memory allocated?
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
double (*)
long (*)
int (*)
byte
boolean
Correct
Review
(1) Points
Correct
2. Which of the following are the arguments in the following method? Mark for
Correct
3. Which is a valid way of calling the testMethod in the TestClass? Assume a Mark for
testInstance has been created.
testInstance.testMethod(10);
testInstance.testMethod(10, 3.5, 0);
testInstance.testMethod(10, 3.5); (*)
testInstance.testMethod(3.5, 10);
testInstance.testMethod(3.5);
Correct
4. An argument is a value that's passed during a method call Mark for
Review
(1) Points
True (*)
False
Correct
5. Which of the following two operations are appropriate for the main method? Mark for
Review
(1) Points
Correct
6. Which of the following scenarios would be ideal for writing a method? Mark for
Review
(1) Points
Correct
7. Methods allow all instance of a class to share same behaviors. Mark for
Review
(1) Points
True (*)
False
Review
(1) Points
new (*)
System
void
instance
Correct
9. Import statements are placed above the class definition. Mark for
Review
(1) Points
True (*)
False
Correct
10. Which two are valid import statements of the Scanner class? Mark for
Review
(1) Points
java.awt
java
awt.font
java.awt.font (*)
Correct
12. The JFrame and JOptionPane classes are in the javax.swing package. Which Mark for
two will import those classes?
Review
(1) Points
Correct
Review
(1) Points
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
1. You need to generate random integer values in the range 2 through 10. This Mark for
code fragment will produce the desired result.
True (*)
False
Review
(1) Points
Correct
Review
(1) Points
Number
Double
Integer
Random (*)
Correct
4. You need to generate random integer values between 0 and 80 (inclusive). Mark for
Which statement should you use?
Review
(1) Points
nextInt();
nextInt(81); (*)
nextInt(80);
nextInt(0-79);
Correct
Review
(1) Points
True (*)
False
Correct
Review
(1) Points
length() (*)
findLength ()
charAt()
compareTo()
Correct
7. The replaceFirst() method replaces only the first occurrence of matching Mark for
character pattern in a string.
Review
(1) Points
True (*)
False
Correct
Java World! 8
Java World!8 (*)
Java World! + 8
Compilation error.
Correct
9. What is the output? Mark for
rld! (*)
rld
ld!
orld!
Correct
10. The String class must be imported using java.lang.String; Mark for
Review
(1) Points
True
False (*)
Correct
11. The indexOf() method returns the index value of a character in the string. Mark for
Review
(1) Points
True (*)
False
Correct
12. Every method of the Math class returns a numerical result. Mark for
Review
(1) Points
True (*)
False
Correct
13. The Math class methods can be called without creating an instance of a Mark for
Math object.
Review
(1) Points
True (*)
False
Correct
Review
(1) Points
Correct
15. What is the package name which contains Math class? Mark for
Review
(1) Points
java.awt
java.net
java.io
java.lang (*)
Correct
Section 5 Quiz
(Answer all questions in this section)
1. The equal sign (=) is used to make an assignment, whereas the == sign Mark for
merely makes a comparison and returns a boolean.
Review
(1) Points
True (*)
False
Correct
Review
(1) Points
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 Mark for
equal?
Review
(1) Points
<=
== (*)
=
>=
Correct
Review
(1) Points
Correct
5. An if/else statement is used when you need to choose between two Mark for
alternatives.
Review
(1) Points
True (*)
False
Correct
Section 5 Quiz
(Answer all questions in this section)
JavaProgramming
Java Programming
True (*)
False
Correct
7. What are the possible values of a boolean data type in Java? Mark for
Review
(1) Points
yes/no
0/1
true/false (*)
good/bad
Correct
8. The switch statement is a more efficient way to write code when dealing Mark for
with a large range of unknown values.
Review
(1) Points
True
False (*)
Correct
Correct
10. A break statement causes control to transfer to the end of the switch Mark for
statement.
Review
(1) Points
True (*)
False
Correct
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. Mark for
Under what conditions does “Eligible for a bonus” print?
Correct
14. In the OR (||) test, if the first expression on the left hand side is true then Mark for
there is no need to evaluate the second statement.
Review
(1) Points
True (*)
False
Correct
15. In Java, an if statement can be nested inside another if statement. Mark for
Review
(1) Points
True (*)
False
Correct
Section 6 Quiz
(Answer all questions in this section)
Review
(1) Points
2. A post-test loop evaluates its condition at the end of the loop instead of the Mark for
beginning.
Review
(1) Points
True (*)
False
Correct
3. The while loop continually executes a block of statements while a particular Mark for
condition is false.
Review
(1) Points
True
False (*)
Correct
4. After the loop is terminated, the statement immediately following the loop Mark for
body is executed.
Review
(1) Points
True (*)
False
Correct
5. Which two statements are true about the while loop. Mark for
Review
(1) Points
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
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 Mark for
the logic easily.
Review
(1) Points
True (*)
False
Correct
Review
(1) Points
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 (*)
Incorrect. Refer to Section 6 Lesson 1.
Section 6 Quiz
(Answer all questions in this section)
11. Which statement will produce the output: 2, 4, 6, 8, 10? Mark for
Review
(1) Points
Correct
Member
Local (*)
Global
Static
Correct
13. You need to calculate the squares of numbers from 1 to 5. Which of the Mark for
items should be present in your looping statement?
Review
(1) Points
Correct
Review
(1) Points
Correct
15. Loops are used in programs for repeated execution of one or more Mark for
statements until a terminating condition is reached.
Review
(1) Points
True (*)
False
Correct
Review
(1) Points
True (*)
False
radius
fiveCircles
circle (*)
circumference
Correct
Review
(1) Points
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
5. In the following statements, how many employee objects are created? Mark for
1
0
2
3 (*)
Correct
Review
(1) Points
True (*)
False
Correct
7. Java developers don't need to know an object’s location in memory. Mark for
Review
(1) Points
True (*)
False
Correct
8. Which keyword is used to allocate memory for a newly created object? Mark for
Review
(1) Points
new (*)
address
memory
store
Correct
9. Objects are accessed using reference variables. Mark for
Review
(1) Points
True (*)
False
Correct
10. If fields aren't initialized, they take on a default value. Mark for
Review
(1) Points
True (*)
False
Correct
11. In Java, the this keyword can be used to reference the current object’s fields Mark for
and methods.
Review
(1) Points
True (*)
False
Correct
12. Which statement is true about the default constructor of a class? Mark for
Review
(1) Points
Correct
13. When you write your own constructor, the default constructor is no longer Mark for
available.
Review
(1) Points
True (*)
False
Correct
14. You create an Employee object with a String employeeName field. What is Mark for
the default value for employeeName?
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
(1) Points
True (*)
False
Correct
Review
(1) Points
Correct
3. Which two statements are true about getter methods? Mark for
Review
(1) Points
Correct
4. To make fields directly accessible to other classes, the class fields must be Mark for
marked public.
Review
(1) Points
True (*)
False
Correct
Review
(1) Points
final
public (*)
static
private (*)
Correct
6. Access and visibility of a class should be limited as much as possible. Mark for
Review
(1) Points
True (*)
False
Correct
7. Which two statements are true about private access modifier? Mark for
Review
(1) Points
8. Given the following code, why does your IDE complain that “non-static Mark for
variable name cannot be referenced from a static context”?
Correct
9. If you need to make a particular variable belong to a class rather than any Mark for
individual instance, what type of variable should you use?
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 Mark for
be accessed.
Review
(1) Points
True (*)
False
Correct
11. The fields and methods of the Math class cannot be directly accessed as Mark for
they are static.
Review
(1) Points
True
False (*)
12. All overloaded methods share the same name. Mark for
Review
(1) Points
True (*)
False
Correct
13. Method overloading can be a useful technique for defining methods with Mark for
similar functionality or calculations.
Review
(1) Points
True (*)
False
Correct
14. How would you complete this code so that one add method calls the other Mark for
add method?
Correct
Review
(1) Points
Correct
Section 8 Quiz
(Answer all questions in this section)
Review
(1) Points
Correct
Review
(1) Points
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
4. Runtime errors can be caught by Java’s exception handling mechanism. Mark for
Review
(1) Points
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
Section 8 Quiz
(Answer all questions in this section)
(Choose all
correct answers)
Print
statements
cannot print
the values of
variables.
Too many
print
statements
lead to
information
overload. (*)
Print
statements
cannot print
the values of
an object’s
fields.
It’s tedious to
remove print
statements.
(*)
Correct
Correct
True (*)
False
Correct
True (*)
False
Correct
null (*)
1
Some random
number.
0
Correct
Test: Section 8 Quiz
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 (*)
ArrayIndexOutOfBoundsExcep
tion
0
1
Correct
Review
(1) Points
Review
(1) Points
ListIterator
do- while loop (*)
for-each loop
iterator
True (*)
False
Correct
Section 9 Quiz
(Answer all questions in this section)
Review
(1) Points
Correct
2. Which color is not directly used when creating custom Color.rgb()? Mark for
Review
(1) Points
Yellow (*)
Red
Green
Blue
Correct
Review
(1) Points
True (*)
False
Correct
4. How would you create a custom color that is pure cyan (equal parts green Mark for
and blue)?
Review
(1) Points
Correct
5. Which method helps to set the width of a rectangle’s outline? Mark for
Review
(1) Points
setX(double d)
setLayoutX(double d)
setStroke(Paint paint)
setStrokeWidth(double d) (*)
Correct
Section 9 Quiz
(Answer all questions in this section)
Review
(1) Points
setOnMouseReleased()
setOnMouseMoved()
setOnMouseClicked() (*)
setOnMouseDragged()
Correct
7. An Image is an object that describes the location of a graphics file. Mark for
Review
(1) Points
True (*)
False
Correct
8. Audio can be played by referencing the Audio object directly. Mark for
Review
(1) Points
True (*)
False
Correct
9. Lambda Expressions provide much more effective and cleaner syntax for Mark for
working with GUI applications and sorting lists.
Review
(1) Points
True (*)
False
Correct
10. JavaFX doesn’t provide you with UI elements, shapes and text. So you must Mark for
always create your own graphics.
Review
(1) Points
True
False (*)
Correct
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
12. A layout Pane dictates how Nodes must be positioned Mark for
Review
(1) Points
True (*)
False
Correct
13. Which type of Root Node allows Nodes to be placed anywhere? Mark for
Review
(1) Points
HBox
Group (*)
TilePane
StackPane
Review
(1) Points
Button
ScrollBar
Object (*)
ImageView
Correct
15. How would you set the title of the Stage primaryStage? Mark for
Review
(1) Points
Correct
Section 6
(Answer all questions in this section)
1. After the loop is terminated, the statement immediately following the loop Mark for
body is executed.
Review
(1) Points
True (*)
False
Correct
2. A pre-test loop evaluates the condition prior to execution of the loop. Mark for
Review
(1) Points
True (*)
False
Correct
Review
(1) Points
Correct
Global
Local (*)
Static
Member
Correct
5. Which two operators cannot be used as the conditional expression in a for Mark for
loop?
Review
(1) Points
!< (*)
!=
<
!> (*)
==
Correct
Section 6
(Answer all questions in this section)
Correct
7. Which two are valid syntax to create a for loop? Mark for
Review
(1) Points
Correct
8. A continue statement is used to skip the remaining statements in the body Mark for
of a loop and continue with the next iteration of the loop.
Review
(1) Points
True (*)
False
Correct
Review
(1) Points
catch
break (*)
switch
continue
Correct
Section 7
(Answer all questions in this section)
Correct
Section 7
(Answer all questions in this section)
11. Methods can call other methods in the same class. Mark for
Review
(1) Points
True (*)
False
Correct
12. You can write more than one constructor in a class. Mark for
Review
(1) Points
True (*)
False
Correct
Review
(1) Points
Correct
Review
(1) Points
Correct
Review
(1) Points
final
private (*)
static
public (*)
Correct
Section 7
(Answer all questions in this section)
16. You have created an Employee class with all required fields and methods. Mark for
10 employees join the company. Should you copy and paste the Employee
class for all 10 employees?
Review
(1) Points
True
False (*)
Correct
17. The structure of a class consists of properties and behaviors. Mark for
Review
(1) Points
True (*)
False
Correct
18. Class name should follow Camel casing rules. Mark for
Review
(1) Points
True (*)
False
Correct
Review
(1) Points
True (*)
False
Correct
20. Given the following code, why does your IDE complain that “non-static Mark for
variable name cannot be referenced from a static context”?
Correct
Section 7
(Answer all questions in this section)
21. You create an Employee object with a String employeeName field. What is Mark for
the default value for employeeName?
Review
(1) Points
null (*)
A space
“Name”
“default”
Correct
22. If fields aren't initialized, they take on a default value. Mark for
Review
(1) Points
True (*)
False
Correct
23. How would you instantiate the Employee class from a main method located Mark for
in another class?
Correct
24. A constructor is a special method which is commonly used to set the initial Mark for
values of an object’s fields.
Review
(1) Points
True (*)
False
Correct
25. What will happen when you try to access an object reference with a null Mark for
value?
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
Section 7
(Answer all questions in this section)
26. Which type of memory is allocated for the code below? Mark for
int x = 1;
int y = 2; Review
x=y; (1) Points
No memory is allocated
Heap memory
Stack memory (*)
PileDriver memory
Correct
27. Java automatically clears the memory once occupied by an object using Mark for
garbage collection.
Review
(1) Points
True (*)
False
Correct
28. In this statement, identify the type of the variable s. Mark for
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
Review
(1) Points
True (*)
False
Correct
Section 8
(Answer all questions in this section)
Review
(1) Points
ListIterator
iterator
do- while loop (*)
for-each loop
Correct
32. You can access elements in an ArrayList by their index. Mark for
Review
(1) Points
True (*)
False
Correct
Review
(1) Points
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
35. Identify where there is a potential bug in this code: Mark for
Correct
36. Using the NetBeans debugger, you can set breakpoints and trace through a Mark for
program one line at a time.
Review
(1) Points
True (*)
False
Correct
Review
(1) Points
Correct
Review
(1) Points
[]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 Mark for
many items of the same data type.
Review
(1) Points
True (*)
False
Correct
40. The Java compiler does not check for an ArrayIndexOutOfBoundsException Mark for
during the compilation of a program containing arrays.
Review
(1) Points
True (*)
False
Correct
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
42. If the try block succeeds then no exception has occurred. Mark for
Review
(1) Points
True (*)
False
Correct
Section 9
(Answer all questions in this section)
43. Audio can be played by referencing the Audio object directly. Mark for
Review
(1) Points
True (*)
False
Correct
44. Which method is used to for mouse click events? Mark for
Review
(1) Points
setOnMouseMoved()
setOnMouseClicked() (*)
setOnMouseReleased()
setOnMouseDragged()
Correct
45. JavaFX doesn’t provide you with UI elements, shapes and text. So you must Mark for
always create your own graphics.
Review
(1) Points
True
False (*)
Correct
Section 9
(Answer all questions in this section)
Review
(1) Points
Button
ImageView
ScrollBar
Object (*)
Correct
47. The start() method is the entry point for all JavaFX applications. Mark for
Review
(1) Points
True (*)
False
Correct
48. Which type of Root Node allows Nodes to be placed anywhere? Mark for
Review
(1) Points
HBox
TilePane
StackPane
Group (*)
Correct
49. Which is the correct syntax to instantiate a JavaFX Rectangle? Mark for
Review
(1) Points
Correct
50. Which color is not directly used when creating custom Color.rgb()? Mark for
Review
(1) Points
Blue
Yellow (*)
Green
Red
Correct