Professional Documents
Culture Documents
Section 2 Quiz
(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.
Hi Friends,
There’s a new movie “Attack of the Duke!” premiering this Friday at Oracle Cinema
at 4:30 PM. The cinema is at the corner of South Street and Walnut Ave. Subway
would be the best way to get there.
(1) Points
Double check the location by verifying you’re on South Street and Walnut Ave.
2. Which of the following are adequate definitions for components of the Spiral
Model of Development?
(1) Points
Correct
3. If the requirement step of the Spiral Model of development is forgotten, which of
the following could occur?
(1) Points
(1) Points
True
False (*)
Correct
5. When the program runs normally (when not in debug mode), which statement is
true about breakpoints?
(1) Points
Breakpoints will not have any effect on program execution. (*)
(1) Points
True (*)
False
Correct
(1) Points
True (*)
False
Correct
8. Which of the following two features are supported by the NetBeans IDE.
Mark for Review
(1) Points
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.
Correct
(1) Points
Space in the print statements.
Indentation before the code.(*)
(1) Points
They can be used to check the current state of the program(*)
(1) Points
True (*)
False
Correct
(1) Points
C++
C (*)
Java C
Java
Correct
13. 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 behavior.
Mark for Review
(1) Points
radius(*)
calculateDiameter()
calculateArea()
calculateCircumference()
color(*)
Correct
14. 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
size
getShirtSize() (*)
color
price
Correct
(1) Points
Object interaction without a prescribed order.(*)
Modeling objects.(*)
Writing algorithms.
Creation of procedures.
Correct
Previous
1. Which of the following are adequate definitions for components of the Spiral
Model of Development?
(1) Points
Correct
(1) Points
True (*)
False
Correct
3. During the Testing phase of software development, which of the following are the
tasks undertaken by the programmer?
(1) Points
Correct
4. Which of the following two features are supported by the NetBeans IDE.
(1) Points
Once NetBeans spots a problem, it won’t allow you to continue coding until the progrblem is fixed.
NetBeans automatically runs the program once all the braces in the code are matched.
Correct
(1) Points
True (*)
False
Correct
6. You can set any number of breakpoints for your program.
(1) Points
True (*)
False
Correct
(1) Points
True (*)
False
Correct
(1) Points
C++
Java
C (*)
Java C
Correct
9. 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 behavior.
(1) Points
calculateArea()
calculateDiameter()
color(*)
calculateCircumference()
radius(*)
Correct
Section 3
(Answer all questions in this section)
10. A double with the value of 20.5 is cast to an int. What is the value of the int?
(1) Points
20.5
21
25
20 (*)
Correct
Previous
Section 3
(Answer all questions in this section)
(1) Points
nt intVar1 = (int)"100";
12. What is parsing?
(1) Points
13. The print() method prints to the console and automatically creates a line.
(1) Points
True
False (*)
Correct
(1) Points
String concatenation can be done with String variables and String Literals.(*)
String concatenation cannot be done with more than two String Literals.
Correct
(1) Points
True (*)
False
Correct
Previous
(1) Points
True (*)
False
Correct
(1) Points
Hello
strVal(*)
String
int
intVal(*)
Correct
(1) Points
True (*)
False
Correct
(1) Points
A Scanner object doesn’t have fields and methods.
A Scanner object opens a stream for collecting input.(*)
20. The Scanner class considers space as the default delimiter while reading
the input.
Mark for Review
(1) Points
True (*)
False
Correct
Previous
21. It's best-practice to close the Scanner stream when finished
(1) Points
True (*)
False
Correct
(1) Points
const
final (*)
static
break
Correct
(1) Points
–27 to 27–1 (*)
–215 to 215–1
–231 to 231–1
–263 to 263–1
Correct
(1) Points
Value of x is 0
Value of y is 1
Value of x is 100
Value of y is 1
Value of x is 100
Value of y is 1
Value of x is 100
Value of y is 101 (*)
Correct
Section 4
(Answer all questions in this section)
(1) Points
nextInt(81); (*)
nextInt();
nextInt(80);
nextInt(0-79);
Correct
Previous
(1) Points
True (*)
False
Correct
(1) Points
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.
Static methods must be of return void. (*)
Correct
(1) Points
True (*)
False
Correct
(1) Points
True (*)
False
Correct
Previous
31. The indexOf() method returns the index value of a character in the
string.
Mark for Review
(1) Points
True (*)
False
Correct
(1) Points
True
False (*)
Correct
(1) Points
charAt()
length() (*)
findLength ()
compareTo()
Correct
34. The classes of the Java class library are organized into packages.
Mark for Review
(1) Points
True (*)
False
Correct
35. The JFrame and JOptionPane classes are in the javax.swing package.
Which two will import those classes?
Mark for Review
(1) Points
import javax.swing.J*;
import javax.swing.JOptionPane;
import javax.swing.JFrame;(*)
import javax.swing.*;(*)
import javax.swing;
Correct
Previous
36. Which statement is true about packages?
Mark for Review
(1) Points
A package doesn’t contain a group of related classes.
A package makes it difficult to locate the related classes.
A package contains a group of related classes. (*)
Packages of the Java class library do not contain related classes.
Correct
(1) Points
java.math
java.io
java.lang (*)
ava.awt
Correct
(1) Points
emp
calculateSalary(100000, 3.2, 15);
100000, 3.2, 15 (*)
emp.calculateSalary(100000, 3.2, 15);
Incorrect. Refer to Section 4 Lesson 1.
(1) Points
new (*)
instance
System
void
Correct
(1) Points
True
False (*)
Correct
Previous
41. Which of the following scenarios would be ideal for writing a method?
(1) Points
When you don’t want to repeat similar lines of code to describe an object’s
behavior. (*)
Section 5
(Answer all questions in this section)
(1) Points
True (*)
False
Correct
int rating;
int experience;
if (rating > 1 && experience == 5) {
System.out.println (“Eligible for a bonus”);
}
(1) Points
(1) Points
&&
%(*)
+(*)
||
Correct
45. The equal sign (=) is used to make an assignment, whereas the == sign merely
makes a comparison and returns a boolean.
(1) Points
True (*)
False
Correct
Previous
Section 5
(Answer all questions in this section)
(1) Points
good/bad
0/1
yes/no
true/false (*)
Correct
47. Which operator is used to test if both sides of a boolean expression are equal?
(1) Points
>=
== (*)
<=
=
Correct
(1) Points
for loop
do while loop
if/else statement(*)
if statement(*)
switch statement(*)
Correct
49. Which two of the following data types can be used in a switch statement?
Mark for Review
(1) Points
String(*)
int(*)
boolean
float
Correct
(1) Points
When the input does not match any of the cases, the default statement is executed.(*)
Correct
Previous
Section 6
(Answer all questions in this section)
1. The only way to exit a loop is for the loop condition to evaluate to false.
True
False (*)
Correct
(1) Points
When a break statement is executed inside a loop, the loop-statement is terminated immediately.(*)
The execution of the program will stop at the statement following the loop-statement.
The execution of the program will continue with the statement following the loop-statement.(*)
When a break statement is executed inside a loop, the loop-statement is terminated immediately and
Correct
(1) Points
True (*)
False
Correct
4. Given:
(1) Points
Static
Global
Local (*)
Member
Correct
(1) Points
(1) Points
for(int i = 10 i >= 0; i++ ) {
System.out.println("i="+i);
}
for(int i = 10; i >= 0; ) {
System.out.println("i="+i);
}(*)
}(*)
Correct
(1) Points
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. (*)
8. A post-test loop evaluates its condition at the end of the loop instead of the
beginning.
(1) Points
True (*)
False
Correct
(1) Points
If the condition of the loop is true initially, the statements are never executed.
If the condition of a pre-test loop is false, the statements in the loop are never executed.(*)
Correct
Section 7
(Answer all questions in this section)
(1) Points
True (*)
False
Correct
Previous
(1) Points
True (*)
False
Correct
12. In the following statements, how many employee objects are created?
(1) Points
3 (*)
1
0
2
Correct
(1) Points
True (*)
False
Correct
(1) Points
void add(int a, int b)
void add(int a, int b, int c)
void add (double a, int b)
void add(String a, String b)
int add (double a, double b) (*)
Correct
(1) Points
True (*)
False
Correct
Previous
16. Which two statements are true about getter methods?
Mark for Review
(1) Points
You must have a setter method if you have a getter method.
Getters usually accept no arguments.(*)
(1) Points
final
public(*)
private(*)
static
Correct
18. What is encapsulation?
Mark for Review
(1) Points
A technique for limiting one class’s visibility to another. (*)
A technique for including primitives within an ArrayList.
A technique for debugging.
A technique for writing more than one main method.
Correct
(1) Points
The main method should be able to freely manipulate an object’s fields.
The main method is commonly used to instantiate objects.(*)
The main method should store the properties and behaviors of objects.
The main method should be as simple as possible.(*)
Incorrect. Refer to Section 7 Lesson 1.
(1) Points
True (*)
False
Correct
Previous
21. 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 (*)
22. 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 private variable.
A local variable.
A static variable. (*)
A public variable.
Correct
(1) Points
True (*)
False
Correct
(1) Points
null (*)
A space
“Name”
“default”
Correct
(1) Points
True (*)
False
Correct
Previous
26. Which statement is true about the default constructor of a class?
(1) Points
(1) Points
(1) Points
Correct
Section 8
(Answer all questions in this section)
(1) Points
True (*)
False
Correct
30. A wrapper class encapsulates, or wraps, the primitive types within an object.
(1) Points
True (*)
False
Correct
Previous
31. 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<boolean> arrList = new ArrayList<>();
ArrayList<true, false> arrList = new ArrayList<>();
ArrayList<True, False> arrList = new ArrayList<>();
Correct
33. 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 multiple
types.
An array is an indexed container that holds a set of values of a single
type. (*)
An array is a Java primitive type.
Correct
(1) Points
True (*)
False
Correct
(1) Points
12
hai hai hai
hai
hai hai (*)
Correct
Previous
36. What is the output?
int[] arr = new int[1];
arr[0] = 10;
System.out.println(arr[0]);
(1) Points
ArrayIndexOutOfBoundsException
1
0
10 (*)
Correct
(1) Points
True (*)
False
Correct
(1) Points
Too many print statements lead to information overload.(*)
(1) Points
int y;
y++; (*)
y = 3 + * 5;
int x=2
x = ( 3 + 5;
Correct
(1) Points
True (*)
False
Correct
Previous
41. Which code goes in the try block?
(1) Points
(1) Points
1
Arithmetic Exception
1
Array index out of bounds (*)
1
2
1
2
Array index out of bounds
Correct
Section 9
(Answer all questions in this section)
(1) Points
True (*)
False
Correct
setX(double d)
setStroke(Paint paint)
setLayoutX(double d)
setStrokeWidth(double d) (*)
Correct
(1) Points
True (*)
False
Correct
Previous
46. 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
47. 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
(1) Points
True (*)
False
Correct
(1) Points
Button
ScrollBar
ImageView
Object (*)
Correct
(1) Points
Group (*)
TilePane
HBox
StackPane
Correct
Previous