Sunteți pe pagina 1din 126

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

Any Breakpoint will stop program execution.


Breakpoints will stop program execution at the first breakpoint.
Breakpoints will not have any effect on program execution. (*)
Breakpoints will stop program execution at the last breakpoint.

Correct

2. Which of the following are considered Whitespace?


Mark for
Review
(1) Points

(Choose all correct answers)

Space between words. (*)


Blank lines in the code. (*)
Indentation before the code. (*)
Space between the [ ] braces.
Space in the print statements.

Correct

3. Which of the following two features are supported by the NetBeans IDE.
Mark for
Review
(1) Points

(Choose all correct answers)

NetBeans provides a shortcut to format whitespace. (*)


NetBeans automatically runs the program once all the braces in the code are
matched.
NetBeans highlights matching braces. (*)
Once NetBeans spots a problem, it won’t allow you to continue coding until the
progrblem is fixed.
Incorrect. Refer to Section 2 Lesson 2.

4. Which of the following three statements are true about breakpoint?


Mark for
Review
(1) Points

(Choose all correct answers)

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.

Incorrect. Refer to Section 2 Lesson 2.

5. Which of the following 2 statements are true about whitespace?


Mark for
Review
(1) Points

(Choose all correct answers)

Whitespace makes your code more readable. (*)


Whitespace eliminates typing mistakes while programming.
Whitespace reduces the performance of the program.
Whitespace increases execution time of your program.
Whitespace helps to keep your code organized. (*)

Correct

Page 1 of 3 Next Summary

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)

6. Which two are the correct syntax for adding comments?


Mark for
Review
(1) Points

(Choose all correct answers)


Start with a slash-star (/*). End with a star-slash (*/). (*)
Start with two slashes (//). End with two slashes (//).
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 (/*).

Correct

7. Which of the following are adequate definitions for components of the Spiral Model of
Development? Mark for
Review
(1) Points

(Choose all correct answers)

Design: Plan the approach (*)


Requirements: Start the development
Test: Run the code and verify results (*)
Develop: Collect all specified instructions

Incorrect. Refer to Section 2 Lesson 1.

8. The Spiral Model reflects an iterative development process.


Mark for
Review
(1) Points

True (*)
False

Correct

9. During the Design phase of software development, the programmer implements


features gathered during the Requirement phase. Mark for
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

Previous Page 2 of 3 Next Summary

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)

11. In the code example below, identify any methods:


Mark for
public class Employee { Review
public String name = " Duke"; (1) Points
public int empId = 12105;
public float salary;

public void displaySalary(){


System.out.println("Employee Salary: "+salary);
}
}

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

(Choose all correct answers)

Modeling objects. (*)


Object interaction without a prescribed order. (*)
Writing algorithms.
Creation of procedures.

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

Previous Page 3 of 3 Summary

Test: Section 3 Quiz 1 - L1-L2


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

Section 3 Quiz 1 - L1-L2


(Answer all questions in this section)

1. What is the output?


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

Hello
World
Hello
Hello World
World (*)

Correct

2. Which two are valid assignments of a?


Mark for
Review
(1) Points

(Choose all correct answers)

int a = 10; (*)


int a = “10”;
int a = 10
int a; a = 10; (*)

Correct

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


Mark for
Review
(1) Points

String x = Java;
String x= “Java”; (*)
String “x” = Java;
String “x” = “Java”;

Correct

4. Which two are valid?


Mark for
Review
(1) Points

(Choose all correct answers)


double doubleVar1; doubleVar2 = 3.1.
double doubleVar1, doubleVar2 = 3.1; (*)
double doubleVar1, double doubleVar2 = 3.1;
double doubleVar1 = 3.1; double doubleVar2 = 3.1; (*)

Incorrect. Refer to Section 3 Lesson 1.

5. What is the output?


Mark for
public class Welcome { Review
public static void main(String args[]) { (1) Points
System.out.println("This is my first program");
int a = 2;
System.out.println("a is" + a);
}
}

a=2
This is my first program a is + a
This is my first program a is 2 (*)
This is my first program

Correct

Page 1 of 3 Next Summary

Test: Section 3 Quiz 1 - L1-L2


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

Section 3 Quiz 1 - L1-L2


(Answer all questions in this section)

6. Assigning a value to the variable is called “initialization”.


Mark for
Review
(1) Points

True (*)
False

Correct

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


Mark for
Review
(1) Points
(Choose all correct answers)

boolean age = 20;


String firstName = “Alex”; (*)
int averageDollarAmount = 19.95;
double checkingAmount = 1500; (*)

Correct

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


Mark for
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
Previous Page 2 of 3 Next Summary

Test: Section 3 Quiz 1 - L1-L2


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

Section 3 Quiz 1 - L1-L2


(Answer all questions in this section)

11. Assuming x is an int, which of the following are ways to increment the value of x by 1?
Mark for
Review
(1) Points

(Choose all correct answers)

x = x +1; (*)
x = +1;
x+;
x++; (*)
x += 1; (*)

Incorrect. Refer to Section 3 Lesson 2.

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


int x = 100; Mark for
int y = x; Review
y++; (1) Points
System.out.println("Value of x is " + x);
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

13. This declaration represents a long data type.


long a = 123L; Mark for
Review
(1) Points

True (*)
False
Correct

14. What is the output?


Mark for
public class Person { Review
public static void main(String args[]) { (1) Points
int age = 20;
System.out.println("Value of age: " +age);
age = 5 + 3;
System.out.println("Value of age: " +age);
age = age + 1;
age++;
System.out.println("Value of age: " +age);
}
}

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

Incorrect. Refer to Section 3 Lesson 2.

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


Mark for
Review
(1) Points

–27 to 27–1 (*)


–215 to 215–1
–231 to 231–1
–263 to 263–1

Correct

Previous Page 3 of 3 Summary

Test: Section 3 Quiz 2 - L3-L5


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)
1. The Scanner class considers space as the default delimiter while reading the input.
Mark for
Review
(1) Points

True (*)
False

Correct

2. Which two statements are true about the Scanner class?


Mark for
Review
(1) Points

(Choose all correct answers)

A Scanner object doesn’t have fields and methods.


A Scanner object opens a stream for collecting input. (*)
A Scanner’s delimiter can be changed. (*)
Scanners cannot read text files.

Correct

3. The Scanner class accepts input in which form?


Mark for
Review
(1) Points

Callables
Integer
Tokens (*)
Future

Correct

4. Which is the correct declaration for a char data type?


Mark for
Review
(1) Points

char size = ’Medium’;


char size = ’M’; (*)
char size = “M”;
char size = “Medium”;
Correct

5. A String can be created by combining multiple String Literals.


Mark for
Review
(1) Points

True (*)
False

Correct

Page 1 of 3 Next Summary

Test: Section 3 Quiz 2 - L3-L5


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)

6. A character preceded by backslash is called an escape sequence.


Mark for
Review
(1) Points

True (*)
False

Correct

7. Which two statements compile?


Mark for
Review
(1) Points

(Choose all correct answers)

String name = “Java”; (*)


String name = ‘Java’;
String name = “J”; (*)
String name = new String ( ‘Java’);

Correct

8. An Object cannot have String objects as properties.


Mark for
Review
(1) Points

True
False (*)

Correct

9. char is the primitive textual data type in Java.


Mark for
Review
(1) Points

True (*)
False

Correct

10. What is the correct way to cast a long to an int?


Mark for
Review
(1) Points

int longToInt = 20L;


int longToInt = 20L(int);
int longToInt = int 20L;
int longToInt = (int)20L; (*)

Correct

Previous Page 2 of 3 Next Summary

Test: Section 3 Quiz 2 - L3-L5


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)

11. Which two statements are true about type casting?


Mark for
Review
(1) Points

(Choose all correct answers)

Type casting lowers the range of possible values. (*)


Type casting retains the size of the value or the original data type.
Type casting changes the type of the value stored. (*)
Type casting cannot be performed on equations.

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

(Choose all correct answers)

Underscores change the value of the number.


Underscores help the compiler interpret large numbers.
Underscores do not affect the value of the variable. (*)
Underscores help make large numbers more readable. (*)

Correct

15. Which is a valid way to parse a String as an int?


Mark for
Review
(1) Points
int intVar1 = Integer.parseInt("100"); (*)
int intVar1 = "100";
int intVar1 = Integer.parseInt("One Hundred");
nt intVar1 = (int)"100";

Correct

Previous Page 3 of 3 Summary

Test: Section 4 Quiz 1 - L1-L2


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)

1. Which two are valid import statements of the Scanner class?


Mark for
Review
(1) Points

(Choose all correct answers)

import java.util.Scanner; (*)


import java.util.*; (*)
import java.util;
import java.*;

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

3. Given the import statement:


import java.awt.font.TextLayout; Mark for
which is the package name? Review
(1) Points
java
awt.font
java.awt
java.awt.font (*)

Incorrect. Refer to Section 4 Lesson 2.

4. Which is a risk of using fully qualified class names when importing?


Mark for
Review
(1) Points

Memory usage is increased.


The compiler runs longer.
Performance of the code is reduced.
Code readability is reduced. (*)

Incorrect. Refer to Section 4 Lesson 2.

5. Import statements are placed above the class definition.


Mark for
Review
(1) Points

True (*)
False

Correct

Page 1 of 3 Next Summary

Test: Section 4 Quiz 1 - L1-L2


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

(Choose all correct answers)

import javax.swing;
import javax.swing.JOptionPane;
import javax.swing.JFrame; (*)
import javax.swing.J*;
import javax.swing.*; (*)

Correct

7. The import statement consists of two parts.


Mark for
import package.className; Review
(1) Points
One is the package name and the other is the classname.

True (*)
False

Correct

8. Methods allow all instance of a class to share same behaviors.


Mark for
Review
(1) Points

True (*)
False

Correct

9. An argument is a value that's passed during a method call


Mark for
Review
(1) Points

True (*)
False

Correct

10. Which of the following two operations are appropriate for the main method?
Mark for
Review
(1) Points

(Choose all correct answers)

Creating instances of objects (*)


Calling an instance object’s field and methods. (*)
Assigning memory to the variables
Calling local variables declared within a class’s method

Correct

Previous Page 2 of 3 Next Summary

Test: Section 4 Quiz 1 - L1-L2


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)

11. Which is a valid way of calling the testMethod in the TestClass? Assume a testInstance
has been created. Mark for
Review
public void testMethod(int x, double y){ (1) Points
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

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
Employee emp = new Employee(); Review
emp.calculateSalary(100000, 3.2, 15); (1) Points

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

Using the dot(.) operator (*)


Using the colon(:) operator
Using the comma(,) operator
Using the double-colon(::) operator

Correct

15. How many arguments does the following method accept?


Mark for
public void simpleInterest(double principal, int noofYears, double interestRate){ Review
System.out.println(“The interest rate is ” +interestRate ); (1) Points
}

2
0
3 (*)
1

Correct

Previous Page 3 of 3 Summary

Test: Section 4 Quiz 2 - L3-L5


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

Section 4 Quiz 2 - L3-L5


(Answer all questions in this section)

1. Which is NOT true?


Mark for
Review
(1) Points

Static methods must be of return void. (*)


Static methods can be invoked through an instance of a class
Static methods can be invoked through the class name.
A class can have multiple static methods.
Correct

2. What is the approximate value of PI?


Mark for
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 object.
Mark for
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

5. String objects are immutable.


Mark for
Review
(1) Points

True (*)
False

Correct

Page 1 of 3 Next Summary

Test: Section 4 Quiz 2 - L3-L5


Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 4 Quiz 2 - L3-L5
(Answer all questions in this section)

6. A String is a sequence characters.


Mark for
Review
(1) Points

True (*)
False

Correct

7. What is the output of the following code?


Mark for
public static void main(String args[]) { Review
String firstString = "Java"; (1) Points
firstString = firstString.concat("World");
System.out.println(firstString);
}

World
JavaWorld (*)
Java World
Java

Correct

8. What is the output?


Mark for
public static void main(String args[]) { Review
String greeting = "Java World!"; (1) Points
String w = greeting.replace("a", "A");
System.out.println(w);
}

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

Incorrect. Refer to Section 4 Lesson 3.

Previous Page 2 of 3 Next Summary

Test: Section 4 Quiz 2 - L3-L5


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

Section 4 Quiz 2 - L3-L5


(Answer all questions in this section)

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). Which
statement should you use? Mark for
Review
(1) Points

nextInt();
nextInt(80);
nextInt(0-79);
nextInt(81); (*)

Incorrect. Refer to Section 4 Lesson 4.


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

Previous Page 3 of 3 Summary

Test: Section 5 Quiz


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
boolean x = (firstCondition && secondCondition); (1) Points
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

3. What is the result?


Mark for
public static void main(String[] args) { Review
int point = 10; (1) Points
String s = (point == 1 ? "point" : "points");
System.out.println("I scored " +point +" " +s );
}

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

Incorrect. Refer to Section 5 Lesson 2.

5. What is the output?


Mark for
char grade = 'A'; Review
switch (grade) { (1) Points
case 'A':
System.out.println("Congratulations!"); case 'B':
System.out.println("Good work");
case 'C':
System.out.println("Average");
case 'D':
System.out.println("Barely passing");
case 'F':
System.out.println("Failed");
}

Congratulations! Good Work Average Barely Passing Failed (*)


Failed
A
Congratulations!

Incorrect. Refer to Section 5 Lesson 3.

Page 1 of 3 Next Summary

Test: Section 5 Quiz


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 (*)

Incorrect. Refer to Section 5 Lesson 3.


8. A break statement causes control to transfer to the end of the switch statement.
Mark for
Review
(1) Points

True (*)
False

Correct

9. What is the output?


Mark for
public static void main(String[] args) { Review
String name = "Java"; (1) Points
String language = "Programming";
String fullName = name + language;
boolean test = fullName.equals(name + language);
System.out.println(test);
}

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

Previous Page 2 of 3 Next Summary

Test: Section 5 Quiz


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

12. What is the output?


Mark for Review
public static void main(String[] args) { (1) Points
int age = 43;
if (age == 43){
System.out.print("Bob is 43 ");
}
if (age == 50){
System.out.print("Bob is 50 ");
}
}

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

(Choose all correct answers)

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

<=
== (*)

Test: Java Foundations Midterm Exam


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
Hi Friends, Review
There’s a new movie “Attack of the Duke!” premiering this Friday at Oracle Cinema at (1) Points
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?

Which of the following are requirements for this plan?

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

Design, Develop , Requirements, Test


Requirements, Design, Test, Develop
Design, Requirements, Develop, Test
Requirements, Design, Develop, Test (*)

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

Code becomes messy.


Solutions seem elusive.
Required software features are missing from the program. (*)
The Program gives inaccurate results.

Incorrect. Refer to Section 2 Lesson 1.

4. Code within curly braces is called a “Block of code”.


Mark for
Review
(1) Points

True (*)
False

Correct

5. Which two are the correct syntax for adding comments?


Mark for
Review
(1) Points

(Choose all correct answers)

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

Page 1 of 10 Next Summary

Test: Java Foundations Midterm Exam


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

Section 2
(Answer all questions in this section)

6. Which of the following 2 statements are true about whitespace?


Mark for
Review
(1) Points
(Choose all correct answers)

Whitespace reduces the performance of the program.


Whitespace eliminates typing mistakes while programming.
Whitespace increases execution time of your program.
Whitespace helps to keep your code organized. (*)
Whitespace makes your code more readable. (*)

Correct

7. In the code example below, identify any methods:


Mark for
public class Employee { Review
public String name = " Duke"; (1) Points
public int empId = 12105;
public float salary;

public void displaySalary(){


System.out.println("Employee Salary: "+salary);
}
}

name
salary
displaySalary() (*)
empId

Correct

8. In object oriented programming, an object comprises of properties and behaviors


where properties represented as fields of the object and behavior is represented as Mark for
method. Review
(1) Points

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
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

char size = “M”;


char size = ’Medium’;
char size = “Medium”;
char size = ’M’; (*)

Correct

Previous Page 2 of 10 Next Summary

Test: Java Foundations Midterm Exam


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

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

(Choose all correct answers)

Capitalize every letter (*)


Separate words with an underscore (*)
Capitalize first letter
Separate words with an space

Correct

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


Mark for
Review
(1) Points

const
final (*)
static
break

Correct

15. This declaration represents a long data type.


long a = 123L; Mark for
Review
(1) Points

True (*)
False

Correct

Previous Page 3 of 10 Next Summary

Test: Java Foundations Midterm Exam


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

The size of the smallest data type used in the expression.


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.

Correct

17. What is parsing?


Mark for
Review
(1) Points

Converting text to numeric data (*)


Converting numeric data to text
Reading text from numeric data
Converting numeric data to a specified numeric data type

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
public class Variables { Review
public static void main(String args[]) { (1) Points
String strVal = "Hello";
int intVal = 0;
System.out.println("Integer: " +intVal)
}
}

(Choose all correct answers)

int
String
strVal (*)
Hello
intVal (*)

Correct

20. What is the output?


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

Hello
Hello
World
World (*)
Hello World

Correct

Previous Page 4 of 10 Next Summary

Test: Java Foundations Midterm Exam


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
(Choose all correct answers)

Scanners cannot read text files.


A Scanner’s delimiter can be changed. (*)
A Scanner object opens a stream for collecting input. (*)
A Scanner object doesn’t have fields and methods.

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)

25. Which of the following statements are true?


Mark for
Review
(1) Points

(Choose all correct answers)

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

Previous Page 5 of 10 Next Summary

Test: Java Foundations Midterm Exam


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

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. (*)

Incorrect. Refer to Section 4 Lesson 1.

28. Which is a valid way of calling the testMethod in the TestClass? Assume a testInstance
has been created. Mark for
Review
public void testMethod(int x, double y){ (1) Points
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

Previous Page 6 of 10 Next Summary

Test: Section 6 Quiz


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

2. What is the result?


Mark for
public static void main(String[] args) { Review
for (int var1 = 0; var1 < 2; var1++) { (1) Points
for (int var2 = 0; var2 < 2; var2++) {
if (var2 == 2) {
continue;
}
System.out.println("var1:" + var1 + ", var2:" + var2);
}
}
}

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

4. Which loop type is considered to be a post-test loop?


Mark for
Review
(1) Points

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

Page 1 of 3 Next Summary

Test: Section 6 Quiz


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

Section 6 Quiz
(Answer all questions in this section)

6. Which two statements are true about the while loop.


Mark for
Review
(1) Points

(Choose all correct answers)

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. (*)
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.

Correct

7. Which of the two are pre-test loops?


Mark for
Review
(1) Points

(Choose all correct answers)

for (*)
while (*)
forEach
do-while

Incorrect. Refer to Section 6 Lesson 2.

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

10. Which two are valid syntax to create a for loop?


Mark for
Review
(1) Points

(Choose all correct answers)

for(int i = 10; i >= 0; i++ ) {


System.out.println("i="+i);
} (*)
for(int i = 10, i >= 0, i++ ) {
System.out.println("i="+i);
}
for(int i = 10 i >= 0; i++ ) {
System.out.println("i="+i);
}
for(int i = 10; i >= 0; ) {
System.out.println("i="+i);
} (*)

Incorrect. Refer to Section 6 Lesson 1.

Previous Page 2 of 3 Next Summary


Test: Section 6 Quiz
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
for (initialization; condition; update) { Review
// Code statement(s) } (1) Points

for (initialization; condition; update) { Code statement(s) }


for (initialization; condition; update) { }
Code statement(s)
for (initialization; condition; update) (*)

Correct

12. What is the result?


Mark for
public static void main(String[] args) { Review
for (;;) { (1) Points
System.out.println("Welcome to Java");
}
}

Compilation error as expressions are missing in the for loop.


Program prints “Welcome to Java” once.
No error and no output.
Program prints “Welcome to Java” an infinite number of times. (*)

Incorrect. Refer to Section 6 Lesson 1.

13. A for loop is also called a definite loop


Mark for
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

15. Given:
Mark for
for(int i = 0; i > 10; i++){ } Review
What type of variable is i? (1) Points

Local (*)
Member
Static
Global

Correct

Previous Page 3 of 3 Summary

Test: Section 7 Quiz 1 - L1-L3


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

Section 7 Quiz 1 - L1-L3


(Answer all questions in this section)

1. Objects are accessed using reference variables.


Mark for
Review
(1) Points

True (*)
False

Correct

2. In the following statements, how many employee objects are created?


Mark for
Employee e1 = new Employee(); Review
Employee e2 = new Employee(); (1) Points
Employee e3 = new Employee();

1
3 (*)
0
2
Correct

3. Which type of memory is allocated for the code below?


Mark for
int x = 1; Review
int y = 2; (1) Points
x=y;

Stack memory (*)


No memory is allocated
PileDriver memory
Heap memory

Correct

4. Java developers don't need to know an object’s location in memory.


Mark for
Review
(1) Points

True (*)
False

Correct

5. In this statement, identify the type of the variable s.


Mark for
Student s = new Student(); Review
(1) Points

Class
null
Student (*)
String

Correct

Page 1 of 3 Next Summary

Test: Section 7 Quiz 1 - L1-L3


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

Section 7 Quiz 1 - L1-L3


(Answer all questions in this section)
6. Java automatically clears the memory once occupied by an object using garbage
collection. Mark for
Review
(1) Points

True (*)
False

Correct

7. Which has a default value of null?


Mark for
Review
(1) Points

boolean
int
String (*)
double

Correct

8. If fields aren't initialized, they take on a default value.


Mark for
Review
(1) Points

True (*)
False

Correct

9. Which statement is true about the default constructor of a class?


Mark for
Review
(1) Points

Java automatically provides a constructor for every class. (*)


You must write a default constructor.
The default constructor always returns void.
Default constructor should have at least one argument.

Correct

10. How would you instantiate the Employee class from a main method located in another
class? Mark for
Review
public class Employee{ (1) Points
private String name;
private double salary;

public Employee(String n, double s){


name = n;
salary = s;
}
}

Employee emp1 = new Employee();


Employee emp1 = new Employee(50000);
Employee emp1 = new Employee(50000, "Syam");
Employee emp1 = new Employee("Syam", 50000); (*)

Correct

Previous Page 2 of 3 Next Summary

Test: Section 7 Quiz 1 - L1-L3


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

Section 7 Quiz 1 - L1-L3


(Answer all questions in this section)

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
employees? Review
(1) Points
True
False (*)

Correct

14. How can you retrieve a value from a method?


Mark for
Review
(1) Points

Pass a variable as an argument to the method.


Use a return statement and define the method’s return type as non-void (*)
Define the method return type as void
Define a variable as a field member of the method

Correct

15. Variables created within a method can be accessed outside that method.
Mark for
Review
(1) Points

True
False (*)

Correct

Previous Page 3 of 3 Summary

Test: Section 7 Quiz 2 - L4-L6


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

Section 7 Quiz 2 - L4-L6


(Answer all questions in this section)

1. Which two statements are true about private access modifier?


Mark for
Review
(1) Points

(Choose all correct answers)

Class fields marked private are most secure. (*)


Class fields marked private are visible to any class.
Class fields are typically marked private. (*)
Class fields are typically marked public.

Correct

2. An object reference directs you from one object to another.


Mark for
Review
(1) Points

True (*)
False

Incorrect. Refer to Section 7 Lesson 5.

3. What is encapsulation?
Mark for
Review
(1) Points

A technique for writing more than one main method.


A technique for limiting one class’s visibility to another. (*)
A technique for including primitives within an ArrayList.
A technique for debugging.

Correct

4. Which two are access modifiers?


Mark for
Review
(1) Points

(Choose all correct answers)

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

Page 1 of 3 Next Summary

Test: Section 7 Quiz 2 - L4-L6


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

Section 7 Quiz 2 - L4-L6


(Answer all questions in this section)

6. Setters are void return type methods.


Mark for
Review
(1) Points

True (*)
False

Correct

7. Which two statements are true?


Mark for
Review
(1) Points

(Choose all correct answers)

An object can access another object’s main method.


An object can access another object’s public methods. (*)
An object can access another object’s public fields. (*)
An object can access another object’s public constructor.

Incorrect. Refer to Section 7 Lesson 5.

8. All overloaded methods share the same name.


Mark for
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 similar
functionality or calculations. Mark for
Review
(1) Points

True (*)
False

Correct

Previous Page 2 of 3 Next Summary

Test: Section 7 Quiz 2 - L4-L6


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

Section 7 Quiz 2 - L4-L6


(Answer all questions in this section)

11. Which three can vary in overloaded methods?


Mark for
Review
(1) Points

(Choose all correct answers)

Order of parameters. (*)


The names of parameters
Method return type.
Number of parameters. (*)
Types of parameters. (*)

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

13. You never need to instantiate a Math object.


Mark for
Review
(1) Points

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
public class Employee{ (1) Points
public static int employeeID;
public String name;

public static void display(){


System.out.println(employeeID);
System.out.println(name);
}
}

It would be possible to call the display() method and attempt to reference an


object’s name before any object exists. (*)
Static variables are only accessible from instance methods.
Static variables cannot be referenced from methods.
The variable name has a null value.

Correct

Previous Page 3 of 3 Summary


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)

1. Which two cannot be stored in an ArrayList?


Mark for
Review
(1) Points

(Choose all correct answers)

Integer
float (*)
int (*)
String

Incorrect. Refer to Section 8 Lesson 2.

2. Which of the following is not a wrapper class?


Mark for
Review
(1) Points

String (*)
Boolean
Integer
Byte

Correct

3. Which is NOT a benefit of ArrayList class?


Mark for
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

4. What is the output?


int[] arr = new int[5]; Mark for
for(int i=0; i<arr.length; i++){ Review
arr[i] = i; (1) Points
}
for(int i=0; i<arr.length; i++) {
System.out.print(arr[i]);
}

01234 (*)
012345
123
12345

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

Page 1 of 3 Next Summary

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)

6. Given:
int x[]; Mark for
What is the value of x? Review
(1) Points

null (*)
0
Some random number.
1

Correct

7. What is the output?


int[] arr = new int[2]; Mark for
for(int i=0; i < arr.length; i++){ Review
System.out.print("hai "); (1) Points
}
hai hai (*)
hai hai hai
12
hai

Correct

8. What is the starting index of an array?


Mark for
Review
(1) Points

0 (*)
1
You can start with anything
It depends on the type of the array.

Correct

9. What is the output?


int[] arr = new int[1]; Mark for
arr[0] = 10; Review
System.out.println(arr[0]); (1) Points

1
0
10 (*)
ArrayIndexOutOfBoundsException

Correct

10. What is the output?


Mark for
int[] array = {10, 20, 30}; Review
int b = 0; (1) Points
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

Previous Page 2 of 3 Next Summary

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)

11. If the try block succeeds then no exception has occurred.


Mark for
Review
(1) Points

True (*)
False

Correct

12. Which code goes in the try block?


Mark for
Review
(1) Points

Any code that is likely to cause an exception. (*)


Any code that is safe from an exception.
Any code that can handle an exception.
Any code that is likely to print the exception details.

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

(Choose all correct answers)

Print statements cannot print the values of variables.


Too many print statements lead to information overload. (*)
It’s tedious to remove print statements. (*)
Print statements cannot print the values of an object’s fields.

Correct

15. Identify where there is a potential bug in this code:


Mark for
int radiusOfCircle = 10; Review
int areaOfCircle = Math.PI * radiusOfCircle * radiusOfCircle; (1) Points

A variable name is misspelled.


A variable hasn’t been assigned a value.
A datatype is incorrect. (*)
A semi-colon is missing.

Correct

Previous Page 3 of 3 Summary

Test: Section 9 Quiz


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

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

2. Which method is used to for mouse click events?


Mark for
Review
(1) Points

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

Page 1 of 3 Next Summary


Test: Section 9 Quiz
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 9 Quiz
(Answer all questions in this section)

6. JavaFX is used to create GUI applications.


Mark for
Review
(1) Points

True (*)
False

Correct

7. How would you set the title of the Stage primaryStage?


Mark for
Review
(1) Points

primaryStage = "New Title!;


primaryStage("New Title!");
primaryStage.setTitle("New Title!"); (*)
primaryStage.title = "New Title!";

Correct

8. The start() method is the entry point for all JavaFX applications.
Mark for
Review
(1) Points

True (*)
False

Correct

9. A layout Pane dictates how Nodes must be positioned


Mark for
Review
(1) Points

True (*)
False
Correct

10. Which is not a JavaFX Node?


Mark for
Review
(1) Points

Object (*)
Button
ImageView
ScrollBar

Correct

Previous Page 2 of 3 Next Summary

Test: Section 9 Quiz


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

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

Rectangle rect = new Rectangle(20, 20, 100);


Rectangle rect = new Rectangle(20, 20);
Rectangle rect = new Rectangle(20, 20, 100, 200); (*)
Rectangle rect = Rectangle(20, 20, 100, 200);

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

Color customColor = Color.rgb(0, 255, 255); (*)


Color customColor = Color.rgb(0, 255, 0);
Color customColor = Color.rgb(255, 255, 0);
Color customColor = Color.rgb(0, 0, 255);

Correct

15. Which color is not directly used when creating custom Color.rgb()?
Mark for
Review
(1) Points

Yellow (*)
Red
Blue
Green

Correct

Previous Page 3 of 3 Summary

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

Breakpoints will stop program execution at the last breakpoint.


Any Breakpoint will stop program execution.
Breakpoints will not have any effect on program execution. (*)
Breakpoints will stop program execution at the first breakpoint.

Correct

2. Which of the following 2 statements are true about whitespace?


Mark for
Review
(1) Points

(Choose all correct answers)

Whitespace eliminates typing mistakes while programming.


Whitespace makes your code more readable. (*)
Whitespace reduces the performance of the program.
Whitespace helps to keep your code organized. (*)
Whitespace increases execution time of your program.

Correct

3. Which two are the correct syntax for adding comments?


Mark for
Review
(1) Points

(Choose all correct answers)

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

(Choose all correct answers)

They insert break statements.


They pause code execution. (*)
They abruptly ends the code execution.
They help with debugging. (*)
They can be used to check the current state of the program (*)

Correct

Page 1 of 3 Next Summary

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)

6. What is the purpose of adding comments in the code?


Mark for
Review
(1) Points

Provide an explanation about the code to the programmer. (*)


To provide better security to the program.
It increases the execution time of the code.
Provide good look and feel of the code.

Correct

7. During the Design phase of software development, the programmer implements


features gathered during the Requirement phase. Mark for
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

9. The Spiral Model reflects an iterative development process.


Mark for
Review
(1) Points

True (*)
False

Correct

10. Which of the following are adequate definitions for components of the Spiral Model of
Development? Mark for
Review
(1) Points

(Choose all correct answers)

Design: Plan the approach (*)


Develop: Collect all specified instructions
Test: Run the code and verify results (*)
Requirements: Start the development

Correct

Previous Page 2 of 3 Next Summary

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)

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

12. In object oriented programming, an object comprises of properties and behaviors


where properties represented as fields of the object and behavior is represented as Mark for
method. Review
(1) Points

True (*)
False

Correct

13. In the code example below, identify any methods:


Mark for
public class Employee { Review
public String name = " Duke"; (1) Points
public int empId = 12105;
public float salary;

public void displaySalary(){


System.out.println("Employee Salary: "+salary);
}
}

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
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 following could
be fields in this class? Distinguish which of these are between the properties and Mark for
behavior. Review
(1) Points

(Choose all correct answers)

radius (*)
color (*)
calculateCircumference()
calculateArea()
calculateDiameter()

Correct

Previous Page 3 of 3 Summary

Test: Section 3 Quiz 1 - L1-L2


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

Section 3 Quiz 1 - L1-L2


(Answer all questions in this section)

1. What is the output?


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

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

(Choose all correct answers)

They make code becomes flexible. (*)


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

Correct

4. Which two statements will not compile?


Mark for
Review
(1) Points

(Choose all correct answers)

int abc = 10;


double double=10; (*)
double salary = 20000.34;
int age=20;
int break=10; (*)

Correct

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


Mark for
public class Variables { Review
public static void main(String args[]) { (1) Points
String strVal = "Hello";
int intVal = 0;
System.out.println("Integer: " +intVal)
}
}
(Choose all correct answers)

intVal (*)
String
Hello
int
strVal (*)

Correct

Page 1 of 3 Next Summary

Test: Section 3 Quiz 1 - L1-L2


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

Section 3 Quiz 1 - L1-L2


(Answer all questions in this section)

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


Mark for
Review
(1) Points

(Choose all correct answers)

boolean age = 20;


double checkingAmount = 1500; (*)
String firstName = “Alex”; (*)
int averageDollarAmount = 19.95;

Correct

7. Which two are valid assignments of a?


Mark for
Review
(1) Points

(Choose all correct answers)

int a; a = 10; (*)


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

8. Which of the following data types is the largest?


Mark for
Review
(1) Points

byte
short
int
long (*)

Correct

9. This declaration represents a long data type.


long a = 123L; Mark for
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

Incorrect. Refer to Section 3 Lesson 2.

Previous Page 2 of 3 Next Summary

Test: Section 3 Quiz 1 - L1-L2


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

Section 3 Quiz 1 - L1-L2


(Answer all questions in this section)

11. What is the output?


Mark for
public class Person { Review
public static void main(String args[]) { (1) Points
int age = 20;
System.out.println("Value of age: " +age);
age = 5 + 3;
System.out.println("Value of age: " +age);
age = age + 1;
age++;
System.out.println("Value of age: " +age);
}
}

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

(Choose all correct answers)

x = x +1; (*)
x = +1;
x+;
x++; (*)
x += 1; (*)

Correct

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


int x = 100; Mark for
int y = x; Review
y++; (1) Points
System.out.println("Value of x is " + x);
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

(Choose all correct answers)

Capitalize every letter (*)


Separate words with an underscore (*)
Capitalize first letter
Separate words with an space

Correct

15. Which two are mathematical operators?


Mark for
Review
(1) Points

(Choose all correct answers)

+ (*)
– (*)
#
@

Correct

Previous Page 3 of 3 Summary

Test: Section 3 Quiz 2 - L3-L5


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)

6. Which two statements are true about String concatenation.


Mark for
Review
(1) Points
(Choose all correct answers)

Strings can be combined using the ‘+’ operator (*)


String concatenation can be done with String variables and String Literals. (*)
String concatenation cannot be done with more than two String Literals.
String concatenation cannot be done with numbers.

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 the input.
Mark for
Review
(1) Points

True (*)
False

Correct

9. The Scanner class accepts input in which form?


Mark for
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 int?
Mark for
Review
(1) Points
25
20.5
20 (*)
21

Correct

Previous Page 2 of 3 Next Summary

Test: Section 3 Quiz 2 - L3-L5


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)

1. An Object cannot have String objects as properties.


Mark for
Review
(1) Points

True
False (*)

Correct

2. Double quotes may be used with char literal values.


Mark for
Review
(1) Points

True
False (*)

Incorrect. Refer to Section 3 Lesson 3.

3. Which is the correct declaration for a char data type?


Mark for
Review
(1) Points

char size = “Medium”;


char size = ’M’; (*)
char size = ’Medium’;
char size = “M”;

Correct

4. A character preceded by backslash is called an escape sequence.


Mark for
Review
(1) Points

True (*)
False

Correct

5. Given the expression:


Mark for
String message = ”Hello World”; Review
(1) Points
Which is the String Literal?

String message = ”Hello World”;


String message
message
Hello World (*)

Correct

Page 1 of 3 Next Summary

Test: Section 3 Quiz 2 - L3-L5


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)

11. What is parsing?


Mark for
Review
(1) Points

Converting numeric data to a specified numeric data type


Reading text from numeric data
Converting text to numeric data (*)
Converting numeric data to text

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

int longToInt = 20L(int);


int longToInt = 20L;
int longToInt = int 20L;
int longToInt = (int)20L; (*)

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

(Choose all correct answers)

double (*)
long (*)
int (*)
byte
boolean

Correct

Previous Page 3 of 3 Summary

Test: Section 4 Quiz 1 - L1-L2


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)

1. Which of the following statements are true?


Mark for
Review
(1) Points

(Choose all correct answers)

Methods can be written with any number of parameters. (*)


Methods cannot be written with parameters.
Parameter values can be used within the method code block. (*)
Parameter values can never be used within the method code block.
Methods can never be written with more than four parameters.

Correct

2. Which of the following are the arguments in the following method?


Mark for
Employee emp = new Employee(); Review
emp.calculateSalary(100000, 3.2, 15); (1) Points

calculateSalary(100000, 3.2, 15);


emp
100000, 3.2, 15 (*)
emp.calculateSalary(100000, 3.2, 15);

Correct

3. Which is a valid way of calling the testMethod in the TestClass? Assume a testInstance
has been created. Mark for
Review
public void testMethod(int x, double y){ (1) Points
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

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

(Choose all correct answers)

Assigning memory to the variables


Creating instances of objects (*)
Calling an instance object’s field and methods. (*)
Calling local variables declared within a class’s method

Correct

Page 1 of 3 Next Summary

Test: Section 4 Quiz 1 - L1-L2


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. Which of the following scenarios would be ideal for writing a method?


Mark for
Review
(1) Points
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

7. Methods allow all instance of a class to share same behaviors.


Mark for
Review
(1) Points

True (*)
False

Incorrect. Refer to Section 4 Lesson 1.

8. Object instantiation is done using what keyword?


Mark for
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

(Choose all correct answers)


import java.util.*; (*)
import java.util.Scanner; (*)
import java.*;
import java.util;

Correct

Previous Page 2 of 3 Next Summary

Test: Section 4 Quiz 1 - L1-L2


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)

11. Given the import statement:


import java.awt.font.TextLayout; Mark for
which is the package name? 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 two will
import those classes? Mark for
Review
(1) Points

(Choose all correct answers)

import javax.swing.*; (*)


import javax.swing;
import javax.swing.JOptionPane;
import javax.swing.JFrame; (*)
import javax.swing.J*;

Correct

13. Which statement is true about packages?


Mark for
Review
(1) Points
A package contains a group of related classes. (*)
A package makes it difficult to locate the related classes.
Packages of the Java class library do not contain related classes.
A package doesn’t contain a group of related classes.

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

Memory usage is increased.


The compiler runs longer.
Code readability is reduced. (*)
Performance of the code is reduced.

Correct

Previous Page 3 of 3 Summary

Test: Section 4 Quiz 2 - L3-L5


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

Section 4 Quiz 2 - L3-L5


(Answer all questions in this section)

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
Random r = new Random(); (1) Points
r.nextInt(9) + 2;

True (*)
False
Incorrect. Refer to Section 4 Lesson 4.

2. Which values are returned by the method nextBoolean();


Mark for
Review
(1) Points

Returns the next value.


Nothing is returned.
Either a true or false. (*)
An integer value.

Correct

3. Which class is used to generate random numbers?


Mark for
Review
(1) Points

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

Page 1 of 3 Next Summary

Test: Section 4 Quiz 2 - L3-L5


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

Section 4 Quiz 2 - L3-L5


(Answer all questions in this section)

6. Which method returns the length of a String?


Mark for
Review
(1) Points

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

8. What is the output?


Mark for
public static void main(String args[]) { Review
String alphaNumeric = "Java World!" + 8; (1) Points
System.out.println(alphaNumeric);
}

Java World! 8
Java World!8 (*)
Java World! + 8
Compilation error.

Correct
9. What is the output?
Mark for
public static void main(String args[]) { Review
String greeting = "Java World!"; (1) Points
String w = greeting.substring(7, 11);
System.out.println(w);
}

rld! (*)
rld
ld!
orld!

Correct

10. The String class must be imported using java.lang.String;


Mark for
Review
(1) Points

True
False (*)

Correct

Previous Page 2 of 3 Next Summary

Test: Section 4 Quiz 2 - L3-L5


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

Section 4 Quiz 2 - L3-L5


(Answer all questions in this section)

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 Math object.
Mark for
Review
(1) Points

True (*)
False

Correct

14. Which is NOT true?


Mark for
Review
(1) Points

Static methods must be of return void. (*)


Static methods can be invoked through an instance of a class
Static methods can be invoked through the class name.
A class can have multiple static methods.

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

Previous Page 3 of 3 Summary

Test: Section 5 Quiz


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

2. Which three are conditional statements?


Mark for
Review
(1) Points

(Choose all correct answers)

for loop
do while loop
switch statement (*)
if statement (*)
if/else statement (*)

Incorrect. Refer to Section 5 Lesson 1.

3. Which operator is used to test if both sides of a boolean expression are equal?
Mark for
Review
(1) Points

<=
== (*)
=
>=

Correct

4. How should Strings be compared?


Mark for
Review
(1) Points

The equals() method (*)


=
==
~=

Correct

5. An if/else statement is used when you need to choose between two alternatives.
Mark for
Review
(1) Points

True (*)
False

Correct

Page 1 of 3 Next Summary

Test: Section 5 Quiz


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

Section 5 Quiz
(Answer all questions in this section)

6. What is the output?


Mark for
public static void main(String[] args) { Review
String name = "Java"; (1) Points
String language = "Programming";
String fullName = name + language;
boolean test = fullName.equals(name + language);
System.out.println(test);
}

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 with a large
range of unknown values. Mark for
Review
(1) Points

True
False (*)

Correct

9. What is the output?


Mark for
public static void main(String args[]) { Review
char grade ='E'; (1) Points
if (grade == 'A') {
System.out.println("Excellent performer");
}else if (grade == 'B') {
System.out.println("Good Performer");
}else if (grade == 'C') {
System.out.println("Average Performer");
}else {
System.out.println("Below Average Performer");
}
}

Below Average Performer (*)


Below Performer
Not a Good Performer
Excellent performer

Correct

10. A break statement causes control to transfer to the end of the switch statement.
Mark for
Review
(1) Points

True (*)
False

Correct

Previous Page 2 of 3 Next Summary

Test: Section 5 Quiz


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

(Choose all correct answers)

A default statement is required in every switch statement.


A default statement is executed by default when the program is executed.
When the input does not match any of the cases, the default statement is
executed. (*)
The default statement is optional in switch statement. (*)

Incorrect. Refer to Section 5 Lesson 3.

12. What is the result?


Mark for
public static void main(String[] args) { Review
int point = 10; (1) Points
String s = (point == 1 ? "point" : "points");
System.out.println("I scored " +point +" " +s );
}

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
int rating; (1) Points
int experience;
if (rating > 1 && experience == 5) {
System.out.println (“Eligible for a bonus”);
}

5 rating and 1 experience


Less than 5 experience and 1 rating.
5 experience and 2 or more rating (*)
5 experience and 1 rating
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

15. In Java, an if statement can be nested inside another if statement.


Mark for
Review
(1) Points

True (*)
False

Correct

Previous Page 3 of 3 Summary

Test: Section 6 Quiz


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

A while loop boolean expression is made up of a counter, increment, and test.


The counter which gets incremented determines the number of loop iterations is
within the parentheses of a while loop.
The boolean expression that determines the number of loop iterations is within the
parentheses of a while loop. (*)
A counter (i) is declared and initialized inside the while loop.

Incorrect. Refer to Section 6 Lesson 2.

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

5. Which two statements are true about the while loop.


Mark for
Review
(1) Points

(Choose all correct answers)

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

Page 1 of 3 Next Summary

Test: Section 6 Quiz


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

Section 6 Quiz
(Answer all questions in this section)
6. What is the output?
Mark for
public static void main(String[] args) { Review
int num = 1; (1) Points
while (num >= 200){
System.out.print(num + "" "");
num = num * 5;
}
}

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

8. Which is used to terminate a loop?


Mark for
Review
(1) Points

continue
catch
switch
break (*)

Correct

9. What is the result?


Mark for
public static void main(String[] args) { Review
for (int var1 = 0; var1 < 2; var1++) { (1) Points
for (int var2 = 0; var2 < 2; var2++) {
if (var2 == 2) {
continue;
}
System.out.println("var1:" + var1 + ", var2:" + var2);
}
}
}

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.

Previous Page 2 of 3 Next Summary

Test: Section 6 Quiz


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

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

for (int i = 2; i <= 10; i += 2) {


System.out.print(i + " ");
} (*)
for (int i = 0; i < 10; i += 2) {
System.out.print(i + " ");
}
for (int i = 0; i < 8; i += 2) {
System.out.print(i + " ");
}
for (int i = 1; i < 10; i += 2) {
System.out.print(i + " ");
}

Correct

12. Given:
Mark for
for(int i = 0; i > 10; i++){ } Review
What type of variable is i? (1) Points

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

14. When is an update expression in a for loop executed?


Mark for
Review
(1) Points

After each iteration through the loop. (*)


Before each iteration through the loop.
After two iterations through the loop.
Before the first iteration through the loop.

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

Previous Page 3 of 3 Summary

Test: Section 7 Quiz 1 - L1-L3


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

Section 7 Quiz 1 - L1-L3


(Answer all questions in this section)

1. Class name should follow Camel casing rules.


Mark for
Review
(1) Points

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
circles share behaviors to calculate circumference and area. Can you identify which of Review
the following is an object? (1) Points

radius
fiveCircles
circle (*)
circumference

Correct

3. How can you retrieve a value from a method?


Mark for
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

(Choose all correct answers)

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. (*)

Incorrect. Refer to Section 7 Lesson 2.

5. In the following statements, how many employee objects are created?


Mark for
Employee e1 = new Employee(); Review
Employee e2 = new Employee(); (1) Points
Employee e3 = new Employee();

1
0
2
3 (*)

Correct

Page 1 of 3 Next Summary

Test: Section 7 Quiz 1 - L1-L3


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

Section 7 Quiz 1 - L1-L3


(Answer all questions in this section)

6. Objects are stored within the heap memory.


Mark for
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
Previous Page 2 of 3 Next Summary

Test: Section 7 Quiz 1 - L1-L3


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

Section 7 Quiz 1 - L1-L3


(Answer all questions in this section)

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. Which statement is true about the default constructor of a class?


Mark for
Review
(1) Points

Java automatically provides a constructor for every class. (*)


You must write a default constructor.
The default constructor always returns void.
Default constructor should have at least one argument.

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

Previous Page 3 of 3 Summary

Test: Section 7 Quiz 2 - L4-L6


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

Section 7 Quiz 2 - L4-L6


(Answer all questions in this section)

1. An object reference directs you from one object to another.


Mark for
Review
(1) Points

True (*)
False

Correct

2. What is encapsulation?
Mark for
Review
(1) Points

A technique for including primitives within an ArrayList.


A technique for limiting one class’s visibility to another. (*)
A technique for writing more than one main method.
A technique for debugging.

Correct
3. Which two statements are true about getter methods?
Mark for
Review
(1) Points

(Choose all correct answers)

Getters usually accept no arguments. (*)


Getters have a public access modifier. (*)
You must have a setter method if you have a getter method.
Getter methods typically return void.

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

5. Which two are access modifiers?


Mark for
Review
(1) Points

(Choose all correct answers)

final
public (*)
static
private (*)

Correct

Page 1 of 3 Next Summary

Test: Section 7 Quiz 2 - L4-L6


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

Section 7 Quiz 2 - L4-L6


(Answer all questions in this section)
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

(Choose all correct answers)

Class fields marked private are most secure. (*)


Class fields are typically marked private. (*)
Class fields are typically marked public.
Class fields marked private are visible to any class.

Incorrect. Refer to Section 7 Lesson 5.

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
public class Employee{ (1) Points
public static int employeeID;
public String name;

public static void display(){


System.out.println(employeeID);
System.out.println(name);
}
}

Static variables are only accessible from instance methods.


Static variables cannot be referenced from methods.
The variable name has a null value.
It would be possible to call the display() method and attempt to reference an
object’s name before any object exists. (*)

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.

Incorrect. Refer to Section 7 Lesson 6.

10. An object must be instantiated before its non-static fields and methods can be
accessed. Mark for
Review
(1) Points

True (*)
False

Correct

Previous Page 2 of 3 Next Summary

Test: Section 7 Quiz 2 - L4-L6


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

Section 7 Quiz 2 - L4-L6


(Answer all questions in this section)

11. The fields and methods of the Math class cannot be directly accessed as they are
static. Mark for
Review
(1) Points

True
False (*)

Incorrect. Refer to Section 7 Lesson 6.

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 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
public int add(int a, int b, int c) { (1) Points
return(a+b+c);
}
public int add(int a, int b){
//Complete this line.
}

return (a, b, c);


return add(a, b, c);
return add(a, b, 0); (*)
return (a, b);

Correct

15. Which three can vary in overloaded methods?


Mark for
Review
(1) Points

(Choose all correct answers)

Method return type.


The names of parameters
Types of parameters. (*)
Number of parameters. (*)
Order of parameters. (*)

Correct

Previous Page 3 of 3 Summary

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)
1. Which code goes in the try block?
Mark for
Review
(1) Points

Any code that is likely to cause an exception. (*)


Any code that is safe from an exception.
Any code that can handle an exception.
Any code that is likely to print the exception details.

Correct

2. What happens when you don’t handle an exception?


Mark for
Review
(1) Points

The execution of the program is terminated abruptly. (*)


The program encounters error and simply ignores it.
A message is printed to the console to ask you how to handle the error.
All of the code after the error is skipped, but the program still runs.

Correct

3. What is the output?


Mark for
int[] array = {10, 20, 30}; Review
int b = 0; (1) Points
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

4. Runtime errors can be caught by Java’s exception handling mechanism.


Mark for
Review
(1) Points

True (*)
False

Incorrect. Refer to Section 8 Lesson 4.

5. Identify where there is a potential bug in this code:


Mark for
int radiusOfCircle = 10; Review
int areaOfCircle = Math.PI * radiusOfCircle * radiusOfCircle; (1) Points

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

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)

6. What are two


disadvantages of Mark for
adding print Review
statements for (1) Points
debugging?

(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

7. What is the starting


index of an array? Mark for
Review
(1) Points

You can start


with anything
0 (*)
It depends on
the type of the
array.
1

Correct

8. You can access the


size of any array by Mark for
using the array’s Review
“length” property. (1) Points

True (*)
False

Correct

9. Arrays are like


variables which must Mark for
be declared prior to Review
use. (1) Points

True (*)
False

Correct

10. Given:
int x[]; Mark for
What is the value of Review
x? (1) Points
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)

11. What is the output?


int[] arr = new int[2]; Mark for
for(int i=0; i < arr.length; i++){ Review
System.out.print("hai "); (1) Points
}

hai hai (*)


hai
12
hai hai hai

Correct

12. What is the output?


int[] arr = new int[1]; Mark for
arr[0] = 10; Review
System.out.println(arr[0]); (1) Points

10 (*)
ArrayIndexOutOfBoundsException
0
1

Correct

13. Which two are limitations of an array of


primitives (ie: int[] x)? Mark for
Review
(1) Points

(Choose all correct answers)


You can create only one array in a
class.
The size of the array is fixed
during array creation and cannot
grow once initialized. (*)
You need to create your own
methods to manipulate array
contents. (*)
You cannot overwrite the contents
of an array once initialized.

Incorrect. Refer to Section 8


Lesson 2.

14. Which is not used to traverse an


ArrayList? Mark for
Review
(1) Points

ListIterator
do- while loop (*)
for-each loop
iterator

Incorrect. Refer to Section 8


Lesson 2.

15. A wrapper class encapsulates, or


wraps, the primitive types within an Mark for
object. Review
(1) Points

True (*)
False

Correct

Previous Page 3 of 3 Summary

Previous Page 2 of 3 Next Summary

Test: Section 9 Quiz


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

Section 9 Quiz
(Answer all questions in this section)
1. Which is the correct syntax to instantiate a JavaFX Rectangle?
Mark for
Review
(1) Points

Rectangle rect = new Rectangle(20, 20, 100);


Rectangle rect = Rectangle(20, 20, 100, 200);
Rectangle rect = new Rectangle(20, 20, 100, 200); (*)
Rectangle rect = new Rectangle(20, 20);

Correct

2. Which color is not directly used when creating custom Color.rgb()?


Mark for
Review
(1) Points

Yellow (*)
Red
Green
Blue

Correct

3. JavaFX Ensemble contains code examples of JavaFX features.


Mark for
Review
(1) Points

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

Color customColor = Color.rgb(0, 255, 255); (*)


Color customColor = Color.rgb(255, 255, 0);
Color customColor = Color.rgb(0, 255, 0);
Color customColor = Color.rgb(0, 0, 255);

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

Page 1 of 3 Next Summary

Test: Section 9 Quiz


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

Section 9 Quiz
(Answer all questions in this section)

6. Which method is used to for mouse click events?


Mark for
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 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

Previous Page 2 of 3 Next Summary

Test: Section 9 Quiz


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

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

Incorrect. Refer to Section 9 Lesson 1.

14. Which is not a JavaFX Node?


Mark for
Review
(1) Points

Button
ScrollBar
Object (*)
ImageView

Correct

15. How would you set the title of the Stage primaryStage?
Mark for
Review
(1) Points

primaryStage.setTitle("New Title!"); (*)


primaryStage.title = "New Title!";
primaryStage("New Title!");
primaryStage = "New Title!;

Correct

Previous Page 3 of 3 Summary

Test: Java Foundations Final Exam


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

2. A pre-test loop evaluates the condition prior to execution of the loop.


Mark for
Review
(1) Points

True (*)
False

Correct

3. Which statement is true?


Mark for
Review
(1) Points

A counter (i) is declared and initialized inside the while loop.


A while loop boolean expression is made up of a counter, increment, and test.
The counter which gets incremented determines the number of loop iterations is
within the parentheses of a while loop.
The boolean expression that determines the number of loop iterations is within the
parentheses of a while loop. (*)

Correct

4. Given:
Mark for
for(int i = 0; i > 10; i++){ } Review
What type of variable is i? (1) Points

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

Page 1 of 10 Next Summary


Test: Java Foundations Final Exam
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 6
(Answer all questions in this section)

6. What is the result?


Mark for
public static void main(String[] args) { Review
for (;;) { (1) Points
System.out.println("Welcome to Java");
}
}

Compilation error as expressions are missing in the for loop.


Program prints “Welcome to Java” once.
Program prints “Welcome to Java” an infinite number of times. (*)
No error and no output.

Correct

7. Which two are valid syntax to create a for loop?


Mark for
Review
(1) Points

(Choose all correct answers)

for(int i = 10, i >= 0, i++ ) {


System.out.println("i="+i);
}
for(int i = 10; i >= 0; ) {
System.out.println("i="+i);
} (*)
for(int i = 10; i >= 0; i++ ) {
System.out.println("i="+i);
} (*)
for(int i = 10 i >= 0; i++ ) {
System.out.println("i="+i);
}

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

9. Which is used to terminate a loop?


Mark for
Review
(1) Points

catch
break (*)
switch
continue

Correct

Section 7
(Answer all questions in this section)

10. Given the method:


Mark for
void add(double a, double b) Review
(1) Points
Which method signature would not overload this method?

int add (double a, double b) (*)


void add (double a, int b)
void add(String a, String b)
void add(int a, int b)
void add(int a, int b, int c)

Correct

Previous Page 2 of 10 Next Summary

Test: Java Foundations Final Exam


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

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

13. Which two statements are true?


Mark for
Review
(1) Points

(Choose all correct answers)

An object can access another object’s public fields. (*)


An object can access another object’s public methods. (*)
An object can access another object’s main method.
An object can access another object’s public constructor.

Correct
14. Which two statements are true?
Mark for
Review
(1) Points

(Choose all correct answers)

The purpose of a setter method is to modify a public field


The purpose of a getter method is to grant other classes access to public data.
The purpose of a setter method is to allow private data to be modified safely (*)
The purpose of a getter method is to return the value of a private field (*)

Correct

15. Which two are access modifiers?


Mark for
Review
(1) Points

(Choose all correct answers)

final
private (*)
static
public (*)

Correct

Previous Page 3 of 10 Next Summary

Test: Java Foundations Final Exam


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
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

19. You never need to instantiate a Math object.


Mark for
Review
(1) Points

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
public class Employee{ (1) Points
public static int employeeID;
public String name;

public static void display(){


System.out.println(employeeID);
System.out.println(name);
}
}

Static variables are only accessible from instance methods.


Static variables cannot be referenced from methods.
It would be possible to call the display() method and attempt to reference an
object’s name before any object exists. (*)
The variable name has a null value.

Correct
Previous Page 4 of 10 Next Summary

Test: Java Foundations Final Exam


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

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 in another
class? Mark for
Review
public class Employee{ (1) Points
private String name;
private double salary;

public Employee(String n, double s){


name = n;
salary = s;
}
}

Employee emp1 = new Employee();


Employee emp1 = new Employee(50000);
Employee emp1 = new Employee(50000, "Syam");
Employee emp1 = new Employee("Syam", 50000); (*)
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

Previous Page 5 of 10 Next Summary

Test: Java Foundations Final Exam


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

Section 7
(Answer all questions in this section)

26. Which type of memory is allocated for the code below?


Mark for
int x = 1; Review
int y = 2; (1) Points
x=y;

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

28. In this statement, identify the type of the variable s.


Mark for
Student s = new Student(); Review
(1) Points

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

ArrayList<Boolean> arrList = new ArrayList<>(); (*)


ArrayList<True, False> arrList = new ArrayList<>();
ArrayList<true, false> arrList = new ArrayList<>();
ArrayList<boolean> arrList = new ArrayList<>();

Correct

30. The size of an ArrayList can grow as needed.


Mark for
Review
(1) Points

True (*)
False
Correct

Previous Page 6 of 10 Next Summary

Test: Java Foundations Final Exam


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

Section 8
(Answer all questions in this section)

31. Which is not used to traverse an ArrayList?


Mark for
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

33. Which is not a compilation error?


Mark for
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

(Choose all correct answers)

You can identify which methods have been called. (*)


You can identify runtime errors.
You can identify the order in which methods have been called. (*)
You can identify compilation errors.

Incorrect. Refer to Section 8 Lesson 4.

35. Identify where there is a potential bug in this code:


Mark for
int radiusOfCircle = 10; Review
int areaOfCircle = Math.PI * radiusOfCircle * radiusOfCircle; (1) Points

A variable hasn’t been assigned a value.


A semi-colon is missing.
A variable name is misspelled.
A datatype is incorrect. (*)

Correct

Previous Page 7 of 10 Next Summary

Test: Java Foundations Final Exam


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
An array is a way to create multiple copies of a single value.
An array is an indexed container that holds a set of values of a single type. (*)
An array is a Java primitive type.
An array is an indexed container that holds a set of values of a multiple types.

Correct

38. Which two are valid array declarations?


Mark for
Review
(1) Points

(Choose all correct answers)

[]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

Previous Page 8 of 10 Next Summary

Test: Java Foundations Final Exam


Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 8
(Answer all questions in this section)

41. What is the output?


Mark for
int[] array = {10, 20, 30}; Review
int b = 0; (1) Points
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

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 always
create your own graphics. Mark for
Review
(1) Points

True
False (*)

Correct

Previous Page 9 of 10 Next Summary

Test: Java Foundations Final Exam


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

Section 9
(Answer all questions in this section)

46. Which is not a JavaFX Node?


Mark for
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

Rectangle rect = new Rectangle(20, 20, 100, 200); (*)


Rectangle rect = Rectangle(20, 20, 100, 200);
Rectangle rect = new Rectangle(20, 20, 100);
Rectangle rect = new Rectangle(20, 20);

Correct

50. Which color is not directly used when creating custom Color.rgb()?
Mark for
Review
(1) Points

Blue
Yellow (*)
Green
Red
Correct

Previous Page 10 of 10 Summary

S-ar putea să vă placă și