331 All Quizzes
Which of the following is a valid identifier? In other words, which could you use as a variable name without causing a syntax error? (pick all that apply)
$343 radius
Each time a method is invoked, the system stores parameters and local variables in an area of memory, known as _______.
a stack
To add a node to the the first row and second column in a GridPane pane, use ________.
pane.add(node, 1, 0);
Quiz 3- 3 You should fill in the blank in the following code with ______________. public class test
void
Given that Math.abs(x - 2) is at most 4, which of the following do we know is true? Mark all that apply.
x - 2 <= 4 && x - 2 >= -4
Which of the following is equivalent to x != y? Mark all that apply.
x > y || x < y ! (x == y)
Which of the following statements are true? Mark all that apply.
(x > 0 || x < 10) is same as ((x > 0) || (x < 10)) (x > 0 || x < 10 && y < 0) is same as (x > 0 || (x < 10 && y < 0)) (x > 0 && x < 10) is same as ((x > 0) && (x < 10))
The Java compiler reads source code, which is found in a file who's extension is named _____ , and translates it into _____ , which is stored in a file who's extension is named ______ .
.java bytecode .class
Which of the following is a possible output from invoking Math.random()? Pick all that apply.
0.0 0.5
In a Java program, what is the result of this expression: 37 % 6?
1
Quiz 2 - 26 What is output of the following code:
1 1 2 3 4 5
For a bottom-tested loop, if the loop body executes 10 times, that means the loop-continuation test takes place ____ times.
10
For a top-tested loop, if the loop body executes 10 times, that means the loop-continuation test takes place ____ times.
11
In a Java program, what is the result of this expression: 45 / 4?
11
Quiz 2 - 25 Consider the following code: How many times will the word "Hi" be printed out?
18
Quiz 2 - 10: What is the value of y after the following switch statement is executed?
2
What is the value of (double)(5/2)?
2.0
Math.pow(3, 3) returns __________.
27.0
Consider this declaration: int[][] x = {{1, 2}, {3, 4, 5}, {5, 6, 5, 9}}; What is x.length?
3
How many classes in the Liang11Samples project make use of the DescriptionPane class of chapter 16?
3
If you declare an array double[] list = {3.4, 2.0, 3.5, 5.5}, the highest index in array list is __________.
3
Consider this declaration: int[][] x = {{1, 2}, {3, 4, 5}, {5, 6, 5, 9}}; What is x[2].length?
4
What is x after the following statements? int x = 2; int y = 1; x *= y + 1;
4
What is the value of i after this code executes? Make sure to consider operator precedence and the behavior of the incrementer operator. int j = 0;int i = j++ + j * 5;
5
Consider a Java class with a main method and with methods m1, m2, and m3. The main method calls method m1 once and method m2 twice. Method m1 calls method m2 once and method m3 once. Method m2 calls method m3 twice. How many times is method m3 called during the execution of this program?
7
Quiz 2 - 11: Which of the following loops prints "Welcome to Java" 10 times?
A and B
________ is invoked to create an object. (select all that apply)
A constructor An instance method
Which of the following statements are true? (select all that apply)
A default constructor is provided automatically if no constructors are explicitly declared in the class. The default constructor is a no-arg constructor.
Which of the following statements are true? (select all that apply)
A method can be overloaded in the same class. If a method overrides another method, these two methods must have the same signature. A method in a subclass can overload a method in the superclass.
Quiz 2 - 15 What will happen when you try to run this code? Assume the user first enters 5 and then 10.
A runtime error because the assignment attempt to go beyond the bounds of the array.
Briefly describe the difference between a syntax error, a runtime error, and a logic error.
A syntax errors occur when source code is compiled. A program with a syntax error cannot be executed. A runtime error is when the program crashes while it's executing. A logic error is when it executes correctly but the logic of the output doesn't make sense.
Briefly explain how visibility modifiers facilitate class abstraction.
A visibility modifier set accessibility of classes, objects, interface, constructors, functions, properties, and their setters. The different levels are public, private, and protected. They are used to access the restricted abstract class.
In chapter 15's USMap example, the variable called points in the MapPane constructor is a referance to a(n):
ArrayList of ArrayLists
What will happen when the following code runs? Why? for (int i=0;i<100;i--) System.out.println("Hi");
Because i is decremented (not incremented) it will never reach 100. Infinite loop.
What is the data type of the parent node in the scene created for ComboBoxDemo example from chapter 16?
BorderPane
Consider Listing 2.2 from Chapter 2 of the Liang textbook Which of the following computer hardware components are involved in executing these statements of this program (mark all that apply)?
CPU input device output device memory
What is the return type of a constructor?
Constructors do not have return types.
A JavaFX action event handler is an instance of _______.
EventHandler<ActionEvent>
In listing 5.3, GuessNumber, is it ever possible for the body of the while loop to never execute? Why or why not?
First time testing loop condition guess = -1 is compared to random number which will be positive, so always drop into the loop the first time.
Which layout pane class causes components to wrap around when you shrink the width of the window?
FlowPane
Quiz 2 - 7: Suppose income is 4001. What is the output of the following code?
Income is greater than 3000
Consider listing 7.1 AnalyzeNumbers. Why was an array necessary for this program?
It was necessary to determine how many numbers were higher than the average.
Quiz 2 - 12 Will this loop ever terminate? Why or why not?
It will never stop. "continue" does not break out of the loop.
The expression "Java " + 1 + 2 + 3 evaluates to ________.
Java 123
JVM stands for _______ , and is used to _______ a Java program.
Java Virtual Machine run
The USMap example from chapter 15 involves use of two Event descendant classes. These are (in alphabetical order) __________ and __________.
KeyEvent MouseEvent
Which of the following statements are true? (select all that apply)
Local variables do not have default values. Data fields have default values. A variable of a primitive type holds a value of the primitive type. A variable of a reference type holds a reference to where an object is stored in the memory.
Suppose s1 and s2 are two variables pointing to String objects. You want to find out whether these two different objects each contain the same string value. Is the expression s1 == s2 a good way to do this? Why or why not?
No, because the relational operators focus on whether they are the same object so if (s1.equals(s2)) should be used instead
Which of the following is NOT a reference? Mark all that apply
Not- The first argument passed to Math.pow. An element of an int array. Is a reference- The parameter passed to the File constructor. A String variable. The args parameter of the main method. A variable of type double[].
Every class in Java is a descendant of the __________ class.
Object
If you want your Java program to loop through database query results, you need to use an implementation of the _______________ interface.
ResultSet
Quiz 3-7 What happens when you try to run this code? public class test
The program has a compile error because the two methods m have the same signature.
Consider the ComputeLoan program from chapter 2. What was the purpose of doing the typecast and arithmetic operations in this expression? (int)(monthlyPayment * 100) / 100.0
The typecast assigns the value of one primitive data type which in this case is int to a float value for the answer at the end. The assignment operator just converts the value based on the order of operations, the division will happen after the multiplication in the beginning. The purpose: get dollars and cents, 2 decimal places.
Suppose s1 and s2 are two strings. What is the value that results from the following expression? s1.equals(s2) == s2.equals(s1) Why would this be the result?
True
Which of the following will cause a while loop to terminate? Mark all that apply.
a break statement in the loop body the condition following the word "while"
A variable defined inside a method is referred to as __________.
a local variable
In an aggregation relationship, the data field (instance member variable) that implements the aggregation is located in the ______________ class.
aggregating
A method that is associated with an individual object is called __________.
an instance method
Which of the following is a class?
application
Another name for an actual parameter is a(n) ____________.
argument
The equal sign ( = ) in Java is a(n) ____________ operator.
assignment
Which of the following is a valid array declaration and instantiation?
boolean[] myArray = new boolean[26];
Which of the following code is incorrect for registering a handler with a button btOK?
btOK.setOnAction(System.out.println("Handle the event");
Which of the following events causes a frame to be placed on the frame stack?
calling a method
In UML terms, multiplicity is most similar to ER's ____________.
cardinality
Quiz 3-6 You should fill in the blank in the following code with ______________. public class test
char
A(n) _______ is a construct that defines objects of the same type.
class
In Java, a(n) ____________ is either preceded with two slashes // or is surrounded by slash-asterisk combinations: /* and */
comment
Which of the following is the most specific and restrictive type of relationship between classes in UML terms?
composition
When applied to strings, the + symbol performs a(n) ____________ operation.
concatenation
The createStatement method needs to be invoked via a reference to a ____________ object:
connection
When using JDBC, you must have an instance of a class that implements the ____________ interface in order to create a Statement object that can be used to query a database.
connection
According to the Java naming conventions, a(n) ___________'s identifier should be in all capital letters.
constant
Suppose the xMethod() is invoked in the following constructor in a class, xMethod() _________ in the class.
could be a static method or an instance method
Consider the following code. Which statements below are true? Mark all that apply. int count = 0;while (count < 100) {// Point ASystem.out.println("Welcome to Java!");count++;// Point B} // Point C
count < 100 is always false at Point C count < 100 is always true at Point A
Quiz 5-9 What is the output of the following code? (using binding properties): import javafx.beans.property
d1 is 2 and d2 is 2, d1 is 3 and d2 is 3
Polymorphism is possible because of _______________.
dynamic binding
A method that attempts to read from or write to a file must either catch or throw a(n) ___________.
exception
A(n) ____________ is a combination of variables, constants, literals and operators that results in a data value.
expression
Every JavaFX subclass __________.
extends javafx.application.Application overrides start(Stage s) method
A Java class can extend any number of other Java classes.
false
A subclass reference can point to a superclass instance.
false
Which of the following are correct names for variables according to Java naming conventions (mark all that apply)?
findArea radius
In a method declaration, the formal parameters will be:
full declarations including data types and identifiers
The method for responding to an action event (e.g. for a button) is called ___________ and takes a parameter of type ___________.
handle ActionEvent
Where in memory is an array stored?
heap
In UML terms a composition is most similar to ER's _____________.
identifying relationship with a weak entity
Suppose isPrime is a boolean variable, which of the following is a correct statement for testing if isPrime is true? Mark all that apply.
if (!isPrime == false) if (isPrime == true) if (isPrime)
According to your textbook, which SDLC involves actually coding the program?
implementation
JDBC drivers are responsible for:
implementing the java.sql interfaces
The object-oriented feature whereby subclasses automatically include properties of their superclasses is called ____________.
inheritance
A this pointer is found in ________ methods but not in __________ methods.
instance static
In JDBC, Statement's executeUpdate method returns an object of type _______________.
int
Which of the following Java statements are incorrect? Mark all that apply.
int a = new int[2]; int[] a = new int(2); int a() = new int[2];
public class Foo {private int x; ........} In this class, the variable x __________.
is definitely an instance variable
When building your JavaFX application, you use a(n) ____________ expression to simplify the task of responding to a button click.
lambda
Consider the following array: int myArray[][] = {{1,2,3},{4,5,6},{7,8,9}}; If I want to access the element that contains the number 7, what is the correct indexing?
myArray[2][0]
Consider the following method header: static void myMethod(int x, double y) Which of the following method calls is the correct one?
myMethod(32, 18.2);
A(n) __________ represents an entity in the real world that can be distinctly identified.
object
To place a node in the left of a BorderPane p, use ___________.
p.setLeft(node);
Overriding a superclass's method in the subclass is the way we implement ____________.
polymorphism
The only way to change the data of __________ member variables (data fields) from outside the class is via a mutator method.
private
Placing a plus sign (+) in front of a class member in a UML diagram marks it as ________.
public
In UML terms, an association is like an ER model's _____________.
relationship
Which of the following is NOT part of a method signature? Mark all that apply:
return statement method modifier actual parameters method body
Overloaded methods involve:
same identifiers and different parameter lists
Every JavaFX Stage object contains a(n):
scene
Which of the following is NOT a node?
scene
A variable's __________ refers to its visibility; i.e. where it can be used in the program.
scope
Statements in Java must end with a(n) ____________.
semicolon
Consider the ComboBoxDemo example from chapter 16, The lambda expression responding to the user's selection of an item from the ComboBox calls a method named:
setDisplay
Polygon is a subclass of ________________.
shape
Which of the following is a Node but not a Parent? in JavaFX?
shape
A(n) ___________ is a last-in first-out data structure.
stack
In a UML diagram, underlining an attribute marks it as _____________.
static
Which of these is not a visibility modifier?
static
A(n) ___________ is a data structure that represents the flow of data between RAM and an external device.
stream
If you want to do a top-down implementation of a program which calls several methods, you can declare methods with empty or incomplete method bodies. Such a method is called a(n) ________.
stub
What if anything is wrong with this code? If anything is wrong, be specific about the cause of the problem. If nothing is wrong, what will be the output? public static void main
the brackets can be after the name in Java. There will be a syntax error with the println outside the loop. The variable i scope is only during the loop.
Quiz 4-18 Consider the following class definition. Which of the following statements is true? public class myClass
the constructor has a this pointer
ResultSetMetaData can give you:
the number of columns returned from a query
When you pass an array variable as an argument to a method, the method receives __________.
the reference of the array
The control variable of a foreach loop that operates on an array contains.
the value of an element of the array
A superclass reference can point to a subclass instance.
true
The effect of putting (int) in front of a double expression is to:
truncate
A Java character is stored in __________.
two bytes