When viewed as as a black box, an object presents the client with which of the following?
Its public interface
Its prime sieve
Its object signature
Its command-line arguments
When viewed as as a black box, an object presents the client with which of the following?
Its public interface
Its prime sieve
Its object signature
Its command-line arguments
Front
its public interface
Back
All methods of a class can access data declared at the class level (T or F)
Front
true
Back
Variables declared within a method cease to exist when the method returns control to the caller.
True
False
Front
true
Back
A constructor cannot be overloaded.
True
False
Front
false
Back
T/F: The main method accepts a variable-length argument list
Front
false
Back
In a JavaFX Polygon object, the last vertex point is automatically connected to the first.
True
False
Front
true
Back
Encapsulation ensures which of the following?
A) that hackers cannot breach the data in an object
B) that a class cannot be used to derive another class
C) that a client is the same class as the object with which it communicates
D) that an object is in charge of modifying the values of its data
Front
D
Back
The println method accepts a variable number of parameters.
Front
false
Back
Given the following code, which of the expressions is false?
Point p1 = new Point(8, 12);
Point p2 = new Point(8, 12);
Point p3 = p2;
p2.equals(p1)
p1 == p2
p2 == p3
p3.equals(p1)
Front
p1 == p2
Back
T/F: The deposit method of the BankAccount class is a mutator method
Front
true
Back
The Java API is organized into what?
A) Packages
B) Groups
C) Tuples
D) Objects
Front
packages
Back
The minimum number of value is minimized to 1 and the maximum value is equal to the number of sides.
What is the output of the following code?
Die die = new Die(6);
System.out.println("Die value: " + die);
Front
die value: 1
Back
T/F: Getter methods always return a String.
Front
false
Back
A getter method always returns an integer value.
True
False
Front
false
Back
Which of the following is NOT true about the this reference?
It can be used to call a method from another class.
It can be used to call a constructor.
It can be used to explicitly refer to the object on which a method is called.
It can be used to distinguish a parameter from instance data.
Front
it can be used to call a method from another class
Back
If the compiler finds two or more methods that equally match a given call, it will issue an error. This problem is called a(n)
Front
ambiguous invocation
Back
T/F: A bounds error will result in an exception being thrown
Front
true
Back
T/F: Two methods in the same class can have the same name
Front
true
Back
T/F: Constructors cannot be overloaded.
Front
false
Back
Caused when you try to access an array element that doesn't exist.
Front
bounds error
Back
The minimum number of value is minimized to 1 and the maximum value is equal to the number of sides.
What is the output of the following code?
Die die = new Die(20);
die.roll();
die.roll();
System.out.println(die.getValue());
Front
# between 1 and 20
Back
Which of the following is NOT true about the this reference?
A) it can be used to call a constructor
B) it can be used to call a method from a parent class
C) it can be used to distinguish a parameter from instance data
D) it can be used to explicitly refer to the object on which a method is invoked
Front
B
Back
The state of an object is represented by what?
The values of its instance data.
The visibility modifiers used on its instance data.
The methods in its public interface.
The signatures of its method
Front
values of its instance data
Back
Which analogy is appropriate?
A) a class is like a car and an object is like a truck
B) an object is like a car and a class like a truck
C)a class is like a blueprint and an object is like a house
D) an object is like a blueprint and a class is like a house
Front
c
Back
Within a class, methods must have unique names.
True
False
Front
false
Back
Are numeric types signed?
Front
yes
Back
What is part of the method signature?
Front
name of the method and the type of its parameters; all method signatures must be unique
Back
What violates encapsulation?
Front
public variables and instance data
Back
T/F: The Java keyword this is an explicit reference to the object on which a method is invoked.
Front
true
Back
The return type of a constructor must be void (T or F)
Front
false
Back
What is the value of val after the following code segment is executed
int val = 20;
val *= 2;
val = val + 5;
Front
45
Back
What does the this reference refer to?
A) the object on which a method is invoked
B) the object passed as the first parameter to a method
C) the object returned by a method
D) the parent object of the current object
Front
A
Back
T/F: The behavior of an object is determined by its public interface
Front
true
Back
T/F: The toString method is automatically called when an object is printed.
Front
true
Back
Computing an incorrect result is an example of what kind of error?
Front
logic
Back
T/F: If you call a method through a null reference the compiler will issue an error
Front
false
Back
What is the method signature of the method below?
public void setCoordinates(int x, int y)
Front
setCoordinates(int, int)
Back
T/F: Both dimensions of a two-dimensional array must have the same element type
Front
true
Back
Suppose a method called checkPos was to return true if both of its parameters was positive, and false otherwise
public ____ checkPos (int a, int b)
{
return _____;
}
What would go in the first and second blank respectfully?
Front
Boolean, a > 0 && b > 0
Back
An ellipses (...) is used to specify a method that accepts command-line arguments.
True
False
Front
false
Back
Each object has its own memory space for instance data (T or F)
Front
true
Back
Which of the following violates the principle of encapsulation?
public constants
private methods
public methods
public instance data
Front
public instance data
Back
Assume the variable str refers to a string object containing the characters "To be or not to be"
What does str.length() give?
Front
18
Length is the number of characters so last index + 1
Back
T/F: An array that holds objects cannot be created using initialization lists
Front
false
Back
Scaling a JavaFX Group object causes each element in the group to be scaled by the same amount.
True
False
Front
true
Back
When comparing String objects, on what does the compareTo method base its result?
Character positions in the Unicode character set
Demographic order
String numeric values after non-alpha characters are removed
Alphabetical order
Front
Character positions in the Unicode character set
Back
T/F: A class must have a getter and setter method for each instance variable.
Front
false
Back
Given the following declaration, which expression will extract the substring "show"?
String phrase = "I could show you incredible things";
Front
phrase.substring(8, 12)
Back
Program options are often specified using what?
Front
command line arguments
Back
A JavaFX Arc is defined as a portion of what other shape?
Circle
Polyline
Line
Ellipse
Front
ellipse
Back
Section 2
(49 cards)
A two-dimensional array is really a one-dimensional array of one-dimensional arrays.
True
False
Front
true
Back
What are synonyms for the existing class, the superclass?
Front
parent class, base class
Back
The pattern from which an object is created.
Front
class
Back
What are synonyms for the new class, the subclass?
Front
child class, derived class
Back
It is possible to create an array with more than two dimensions.
True
False
Front
true
Back
What must the child of an abstract class provide in order not to be considered abstract also?
Front
provide definitions for the inherited abstract methods
Back
Point p1 = new Point(4, 7);
Point p2 = p1;
Point p3 = new Point(4, 7);
Point p4 = new Point(5, 12);
p1 == p2, T/F?
Front
true
Back
An abstract class cannot be declared as final
Front
true
- must derive classes from it
Back
What does this.radius=radius do?
Front
It assigns the parameter value to the instance data
Back
What's different about an overridden method in a subclass compared to the inherited version?
different parameters but same method name and code
same method name and parameters but different code
different method name but the same code
same method name and code but different return type
Front
same method name and parameters but different code
Back
If Lockable is an interface, which statement must be true given the following declaration?
Lockable obj = new Book();
Lockable must define the methods in Book
Book must contain Lockable
Book must implement Lockable
Lockable must implement the Book class
Front
book must implement lockable
Back
if (obj1.equals(obj2)) means?
Front
equivalent content
Back
If the final modifier is applied to a method, that method cannot be overridden in any derived class
True/False
Front
true
Back
Which of the following statements is true?
An interface can contain public and private methods.
An interface can contain methods and classes.
An interface can contain methods and constants.
An interface can contain methods and instance variables.
Front
an interface can contain methods and constants
Back
Graphically and in code, from what to what do you read the is-a relationship ?
Front
Graphically: from the start of arrow to end of arrow
In code: From right to left
ex. Vehicle v;
v= new Sedan();
A sedan IS A vehicle but a vehicle isn't always a sedan
Back
The instanceof operator determines if an object reference variable is currently pointing to an object of a particular type.
True
False
Front
true
Back
Point p1 = new Point(4, 7);
Point p2 = p1;
Point p3 = new Point(4, 7);
Point p4 = new Point(5, 12);
p1 == p3, T/F?
Front
false
Back
Which line of code demonstrates a valid and error-free way to access the following array?
String[][] chessboard = new String[8][8];
String chessPiece = chessboard[1][8];
String chessPiece = chessboard[1];
String chessPiece = chessboard["2"]["3"];
String chessPiece = chessboard[5][2];
String chessPiece = chessboard[4][];
Front
String chessPiece = chessboard[5][2];
* in bounds
Back
How many elements can be stored in a two-dimensional array with dimensions 5 and 10?
Front
50
Back
Point p1 = new Point(4, 7);
Point p2 = p1;
Point p3 = new Point(4, 7);
Point p4 = new Point(5, 12);
p1 == p4, T/F?
Front
false
Back
If a class is not explicitly derived from a particular class, where is it derived from?
Front
the object class
Back
The maximum indexes of a two-dimensional array with 6 rows and 10 columns are 5 and 9, respectively.
True
False
Front
true
Back
The data managed by an object.
Front
instance data
Back
A Java interface defines which of the following?
system interface
keyword interface
printable interface
user interface
Front
system interface
Back
An abstract class can instantiated
True/False
Front
false
Back
Every class can only have one parent.
True/False
Front
true
Back
How does the default version of the equals method act if not overridden?
Front
Acts as the == operator, so returns true if two references point to the same object
Back
When a method is invoked, what determines which is invoked?
Front
The type of the object NOT the type of reference
Back
What Java keyword is used to create a subclass?
interface
implements
extends
inherits
Front
extends
Back
How can it be determined what type of objects an object reference can refer to?
Front
Distinguish between the object reference type and the type of object (class) it refers to
Back
What is the difference between method overloading and overriding
Front
Method overloading is when two or more Java methods in the same class have the same name but as long as have different parameters;
Overriding is when a method from the parent class is defined again in the sub class (overriding the inherited version) with own version
Back
What's an abstract class?
Front
is a placeholder in a class hierarchy that represents a general concept
Back
What is the ultimate root of every class hierarchy?
Front
java.lang.Object class
Back
A Java interface cannot be instantiated.
True
False
Front
true ** can only create methods in an interface
Back
Methods and data declared as protected can be accessed from any derived class
True/False
Front
true
Back
A class can only implement one interface at a time.
True
False
Front
false
Back
What are abstract methods?
Front
method headers with no bodies
Back
Assuming the table is a two-dimensional array of integers, what does the following code do?
int sum = 0;
for (int i = 0; i < table.length; i++)
for (int j = 0; j < table[i].length; j++)
sum = sum + table[i][j];
Computes the sum of each column in the table.
Computes the sum of all elements in the table except those in the last column.
Computes the sum of all elements in the table except those in the last row.
Computes the sum of each row in the table.
Computes the sum of all values in the table.
Front
computes the sum of all values in the table
Back
An abstract can only contain abstract methods
True/False
Front
false
Back
Point p1 = new Point(4, 7);
Point p2 = p1;
Point p3 = new Point(4, 7);
Point p4 = new Point(5, 12);
p1.equals(p4), T/F?
Front
false
Back
An integer can equal a double
True/False
Front
false
* only double can equal integer
Back
What can an object reference variable refer/point to?
Front
Any object of it's type or any type derived from it
ex. A car reference could point to a car object or sedan or suv object but NOT vice-versa
Car automobile; automobile = new Car();
automobile = new Sedan(); automobile = new SUV();
Back
What is the role of the seed value of a random number generator?
It's the maximum number of values that can be produced by the generator.
It's the maximum value that can be generated by that object.
It's a number that is the basis of the calculated pseudorandom numbers.
It's the minimum value of any range produced by the generator.
Front
It's a number that is the basis of the calculated pseudorandom numbers.
Back
Point p1 = new Point(4, 7);
Point p2 = p1;
Point p3 = new Point(4, 7);
Point p4 = new Point(5, 12);
p1.equals(p2), T/F?
Front
true
Back
If the final modifier is applied to a class, that class cannot be used to derive a subclass
True/False
Front
true
Back
Point p1 = new Point(4, 7);
Point p2 = p1;
Point p3 = new Point(4, 7);
Point p4 = new Point(5, 12);
p1.equals(p3), T/F?
Front
true
Back
Defines the code that is executed when a method is called.
Front
method declaration
Back
if (obj1 == obj2) means?
Front
point to the same object (reference equality)
Back
Private data and methods cannot be accessed by name in a derived class
True/False