Section 1

Preview this deck

What's a syntax error?

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

1

Favorites

0

Last updated

1 year ago

Date created

Mar 1, 2020

Cards (247)

Section 1

(50 cards)

What's a syntax error?

Front

When any programming statements violate the syntax rules of the Java language; ex. [System.out.println("There is a mistake here.)]- the error is the missing " and ;

Back

What value is computed by the following Java expression? 10 / 3 - 14 % 2

Front

3 (14 % 2 = 0 and 10/3 = 3.3 but there's no double value so round to the lowest integer

Back

If gen is a Random object, what range of values would the following expression produce? gen.nextInt(70) - 20

Front

-20 to 49

Back

String is a Java primitive type. True False

Front

False

Back

A String literal cannot span multiple lines in a Java program. True False

Front

True; Opening and closing quote must be on the same line of code so to print multiple lines you concatenate the lines

Back

What does the || boolean operator mean and what does X || Y give?

Front

|| means Or; X || Y will be true if X or Y or BOTH are true and false otherwise

Back

In Java, object reference variables do not have to be declared. True False

Front

False

Back

What output would be produced by the following statement? System.out.print("ABC" + 10 + 5);

Front

ABC105

Back

Which of the following identifiers follows the Java convention for a variable name? Max_Height MAX_HEIGHT MaxHeight maxHeight

Front

maxHeight

Back

What value is stored in the variable x after the following code segment is executed? int x = 0; for (int i = 1; i <= 4; i++) x = x + i;

Front

10

Back

What's a software development environment? The software that lets you develop Java programs. The library of Java classes that any programmer can use. A conceptual platform on which Java programs run. The software that checks and translates Java code

Front

The software that lets you develop Java programs; set of tools used to create, organize, modify, test, and debug a program; ex. BlueJ

Back

What value is computed by the following Java expression? 6 + 2 * 3 - 3

Front

9

Back

What are the two types of software development environment and what are they?

Front

1) Command-line environment- console/terminal window that prompts you to enter text commands; JDK is set of command-line tools 2) Integrated development environments (IDE's)- tools are integrated into one program that provides a graphical user interface (Eclipse or BlueJ)

Back

What output would be produced by the following code? String text = "idiosyncratic"; System.out.print(text.substring(2, 7));

Front

iosyn

Back

Assume the variable str refers to a string object containing the characters "To be or not to be" What does str.substring(9, 12) give?

Front

not substring with two values gives back from index of the first value to the index of the second value - 1

Back

Assume the variable str refers to a string object containing the characters "To be or not to be" What does str.charAt(0) give?

Front

T charAt gives the character it's asked for in a specific index number

Back

What does the ^ boolean operator mean and what does X ^ Y give?

Front

^ means Exclusive Or; X ^ Y will be true if X or Y (but not both) are true and false otherwise

Back

If gen is a Random object, what range of values would the following expression produce? gen.nextInt(100)

Front

0 to 99 Remember: When there's one number, it ranges from 0 to N-1; but if have a shift value of Y, it will be from Y to N+Y-1

Back

Which of the following is NOT a feature of the Java programming language? It is graphics neutral. It is platform independent. It has automatic garbage collection. It is an object-oriented language.

Front

It is graphics neutral; IT IS general-purpose, has applets to be able to run on web tech, & it was created by Sun and is now ran by Oracle

Back

Assume the variable str refers to a string object containing the characters "To be or not to be" What does str.replace("be", "are") give?

Front

To are or not to are replace replaces the first word or character with the second word or character

Back

If A is true and B is false, what is the value of the expression A && B? True False

Front

False

Back

Assume the variable str refers to a string object containing the characters "To be or not to be" What does str.concat("xyz") give?

Front

To be or not to bexyz concat adds whatever characters to the string

Back

The functionality of a for loop can always be written as a while loop. True False

Front

True

Back

What does the ! boolean operator mean and what does !X give?

Front

! means Not; !X will be true if X is false and false if X is true; also called a unary operator bc it only requires one operand

Back

What are the 8 primitive data types?

Front

Byte, short, int, long (integers); float, double (floating-point types); char (character type); boolean (boolean type)

Back

Assume the variable str refers to a string object containing the characters "To be or not to be" What does str.indexOf("r") and str.indexOf("or") give?

Front

7 and 6 indexOf gives back index value of first occurrence of the value or word given

Back

The compiler will issue an error if you violate a Java programming convention. True False

Front

False; Conventions are rules outside of the language syntax that programmers should follow; ex. indentation, comments, spaces, etc

Back

What is the boolean primitive type boolean?

Front

Represents true or false

Back

What is the Java API? The software that lets you develop Java programs. The library of Java classes that any programmer can use. A conceptual platform on which Java programs run. The software that checks and translates Java code

Front

A large library of Java classes that any programmer can use; organized into packages and classes from the API can be imported

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

Are numeric types signed? True False

Front

True

Back

If gen is a Random object, what range of values would the following expression produce? gen.nextInt(50) + 20

Front

20 to 69

Back

Computing an incorrect result is an example of what kind of error? Production error Logic error Runtime error Syntax error

Front

Logic error

Back

What is the value of num after the following code segment is executed? int num = 12; num *= 3; int val = num + 1; num = num + val;

Front

73

Back

Given the following code segment: for (int i = 1; i < 10; i++) { System.out.println("apple"); for (int j = 1; j <= 5; j++) System.out.println("lemon"); } How many times does the word "apple" get printed? How many times does the word "lemon" get printed?

Front

9, 45

Back

Which expression can be used to determine if num is an even number? (even) num num / 2 != 0 Math.even(num) num % 2 == 0

Front

num % 2 == 0

Back

What is the difference between the floating-point types float and double?

Front

Both hold values w/ decimals but float values includes the F character

Back

Assume the variable str refers to a string object containing the characters "To be or not to be" What does str.substring(9) give?

Front

not to be substring with just one value gives back from index of that value to the end of the string

Back

What's a runtime error?

Front

When any program executes and causes it to terminate abnormally; "crashes" or "blows up"; ex. when try to divide a # by zero, [123/0]

Back

What is the character primitive type char?

Front

Represents a single character

Back

What is the difference between the integer primitive data types int, long, short, and byte?

Front

int-stores an integer but not as large as long long- stores a large integer (includes L character) short- stores a shorter integer than int byte- stories the shortest amount of integers

Back

If A and B are both true, what is the value of the expression A || B? True False

Front

True

Back

A Java compiler translates Java byte code into source code. True False

Front

False; the compiler translates source code (code you write) into byte code

Back

Assume the variable str refers to a string object containing the characters "To be or not to be" What does str.equals("xyz") give?

Front

False equals checks if str has the same characters as inputed, if not, false, if does, true

Back

What do the
and \t characters do?

Front


starts a new line in a string and \t makes a tab

Back

What value is computed by the following Java expression? 10 % 4 * 10 + 10

Front

30

Back

What is an escape sequence?

Front

A technique for representing a character in situations where the traditional manner would cause problems or be less convenient; begins with the backslash (\) ex. [System.out.println("\"Tell the truth and then run.\"");

Back

Assume the variable str refers to a string object containing the characters "To be or not to be" What does str.toLowerCase() and str.toUpperCase give?

Front

Just changes the str either to all lower case or all upper case

Back

What does the && boolean operator mean and what does X && Y give?

Front

&& means And; X && Y will be true if both X and Y are true and false otherwise

Back

What is the Java Virtual Machine (JVM)? The software that lets you develop Java programs. The library of Java classes that any programmer can use. A conceptual platform on which Java programs run. The software that checks and translates Java code.

Front

A conceptual platform on which bytecode is designed to run on Java programs (makes Java platform-independent-meaning it can run on any computer with the JVM)

Back

Section 2

(50 cards)

Code indentation is ignored by the compiler (T or F)

Front

True

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

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

Front

The values of its instance data.

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

A for-each loop can always be translated into an equivalent for loop. True False

Front

True

Back

What is the value of the following expressions? 12 / 5 + 12 % 5

Front

4

Back

The JavaFX graphics framework is designed to replace older technologies such as Swing and AWT. True False

Front

True

Back

Debugging is the process of evaluating a program to discover errors (T or F)

Front

False, testing means this. Debugging is the process of determining the root cause of a problem and fixing it

Back

The Java API is organized into what? A) Packages B) Groups C) Tuples D) Objects

Front

A) Packages

Back

What is the value of the following expressions? 2 + 2 / 4 + 6

Front

8

Back

Where is the origin point on a Java container (such as a Pane)? The center of the visible space The upper right corner The upper left corner The center of the container's original size

Front

The upper left corner

Back

The ASCII character set is a subset of the Unicode character set (T or F)

Front

True

Back

A for-each loop cannot be used to store values in an array. True False

Front

True

Back

A JavaFX Arc is defined as a portion of what other shape? Circle Polyline Line Ellipse

Front

Ellipse

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

A constructor cannot be overloaded. True False

Front

False

Back

In Java, an array is an object. True False

Front

True; it is NOT a primitive type

Back

A getter method always returns an integer value. True False

Front

False

Back

What value is printed by the following code? int[] myStuff = new int[400]; System.out.println(myStuff.length);

Front

400

Back

A method that does not return a value should have a return type of void (T or F)

Front

True

Back

What happens when an invalid index is used to access an array? The closest valid index is used. An exception is thrown. The statement is ignored. The compiler will issue an error message.

Front

An exception is thrown

Back

In a JavaFX Polygon object, the last vertex point is automatically connected to the first. True False

Front

True

Back

Each object has its own memory space for instance data (T or F)

Front

True

Back

If a binary search is used to find the value 74 in the following list of numbers, how many comparisons will it take? 12 19 23 28 35 37 40 49 54 61 65 74 82 88 93

Front

2

Back

Approximately what percentage of the viable candidates does a binary search algorithm eliminate with each comparison?

Front

50

Back

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

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

How many assignment statements are needed to swap two elements in an array?

Front

3

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

Which expression determines whether x is an odd number? A) x / 2 != 0 B) Math.odd(x) C) x % 2 == 1 D) (odd)x

Front

C) x % 2 == 1

Back

What does the following code accomplish? int x = sizes[0]; for (int val : sizes) if (val < x) x = val; Determines the maximum value in the array sizes Determines the minimum value in the array sizes Computes the sum of the values in the array sizes Performs a linear search on the array sizes

Front

Determines the minimum value in the array sizes; it would be determining max value if it the 3rd line was [if (val > x)]

Back

JavaFX embraces which of the following? A theater analogy A museum analogy A printing press analogy A portrait analogy

Front

A theater analogy

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

A Java compiler translates Java source code into bytecode (T or F)

Front

True

Back

BlueJ is an integrated development environment (IDE) (T or F)

Front

True

Back

If a method doesn't return a value, what should its return type be? There should be no return type. void this null

Front

Void

Back

The return type of a constructor must be void (T or F)

Front

False

Back

If an instantiation list is used to create an array, the new operator is not used. True False

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

Variables declared within a method cease to exist when the method returns control to the caller. True False

Front

True

Back

What is the range of the valid indexes for an array that can hold 300 values?

Front

0 to 299

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)a class is like a blueprint and an object is like a house

Back

Scaling a JavaFX Group object causes each element in the group to be scaled by the same amount. True False

Front

True

Back

Within a class, methods must have unique names. True False

Front

False; can have same name just have different parameter lists; called method overloading

Back

Logic errors are caught by the compiler (T or F)

Front

False

Back

Given the following code segment int num = 0, val = 1; while (val < 8) { val = val + 2; num = num + val; } What number is stored in the variable val after the loop ends? What number is stored in the variable num after the loop ends?

Front

9, 24

Back

All methods of a class can access data declared at the class level (T or F)

Front

True

Back

What is the value of the following expressions? 7 + 3 * 2 - 1

Front

12

Back

Which of the following is the proper way to set up an object to read from an input file? PrintWriter in = new PrintWriter("myInput.txt"); Scanner in = new File("myInput.txt"); File in = new File(new Scanner("myInput.txt")); Scanner in = new Scanner(new File("myInput.txt"));

Front

Scanner in = new Scanner(new File("myInput.txt"));

Back

The element type of an array can be any type except boolean. True False

Front

False

Back

Section 3

(50 cards)

T/F: The Java keyword this is an explicit reference to the object on which a method is invoked.

Front

True, this allows an object to refer to itself in methods declared inside that object.

Back

T/F: Both dimensions of a two-dimensional array must have the same element type

Front

True

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) it can be used to call a method from a parent class

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

A number between 1 and 20

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) that an object is in charge of modifying the values of its data

Back

T/F: Encapsulation makes is difficult for hackers to access your data.

Front

False, Encapsulation is not about guarding against security breeches.

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: The deposit method of the BankAccount class is a mutator method

Front

True

Back

T/F: Two methods in the same class can have the same name

Front

True

Back

Assuming list is an array, what does the following for-each loop accomplish? A) nothing- the values in the array list are unchanged B) all elements in the array are set to 10 C) only the last element in the array is set to 10 D) only the first element in the array is set to 10

Front

A) nothing- the values in the array list are unchanged; a for-each loop CANNOT change the values of the array

Back

T/F: You cannot use relational operators (such as < or >) on objects.

Front

True, You have to use the compareTo method instead.

Back

T/F: A class must have a getter and setter method for each instance variable.

Front

False, They sometimes do, but don't have to.

Back

Caused when you try to access an array element that doesn't exist.

Front

Bounds error

Back

T/F: Constructors cannot be overloaded.

Front

False, Sure they can, and often are. Overloaded constructors provide different ways to set up an object.

Back

The elements of an array of length N can be accessed using what range of indexes?

Front

0 to N-1

Back

T/F: The behavior of an object is determined by its public interface

Front

True

Back

What is the method signature of the method below? public void setCoordinates(int x, int y)

Front

setCoordinates(int, int) Remember, method signatures (and parameters) MUST BE UNIQUE for method overload to be acceptable

Back

Method overloading is helpful in which of the following situations? A) When two methods have different return types B) When a method has the same name as its enclosing class. C) When two methods perform a similar task on different types of data. D) When two classes have the same name E) When two methods perform a different task on the same types of data.

Front

C) When two methods perform a similar task on different types of data.

Back

T/F: A method can only be an accessor or a mutator but not both.

Front

False, It can be both, such as a method that changes an instance value and then returns the new value.

Back

T/F: Traversing an array or collection means accessing each element one at a time.

Front

True, common for for-each loop

Back

T/F: If you call a method through a null reference the compiler will issue an error

Front

False; null just means that nothing's there or that whatever value is not there

Back

A one-dimensional array has only one element type, but a multidimensional array can hold several types of elements. True False

Front

False; Every array has a single element type. The difference is in how the values are arranged.

Back

An integer value that is used to access a particular element in an array.

Front

Index

Back

T/F: Arrays can hold primitive types, but not objects.

Front

False, The element type of an array can be either a primitive type or an object reference.

Back

Given the following code segment: int list[] = new list[10]; for (int i = 0; i < list.length; i++) list[i] = i * 10; What is the value of list.length?

Front

10

Back

What violates encapsulation?

Front

Public variables and instance data

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

An ellipses (...) is used to specify a method that accepts command-line arguments. True False

Front

False; a variable-length parameter is specified using an ellipses (..) between the type and parameter name

Back

T/F: Getter methods always return a String.

Front

False, The return type of each getter method must match the type of the value being retrieved.

Back

When performing a binary search, how many comparisons are required to find a value in a list of N values, in the worst case?

Front

log2N + 1

Back

T/F: The return type of a method is NOT part of the method's signature

Front

True

Back

How many comparisons are necessary to find the value 43 in the following list using a binary search? 13 25 28 30 39 43 44 58 66 70 78 81 86 88 95

Front

3

Back

What doesn't violate encapsulation?

Front

Private variables/instance data, public methods, private methods, constants

Back

The println method accepts a variable number of parameters.

Front

False

Back

Given the following code segment: int list[] = new list[10]; for (int i = 0; i < list.length; i++) list[i] = i * 10; What is the value of the last element in the list array after this code completes?

Front

90

Back

T/F: An array that holds objects cannot be created using initialization lists

Front

False

Back

T/F: The main method accepts a variable-length argument list

Front

False; main method accepts an array of String objects as a parameter called args which represents any command-line arguments that are provided when the program is run

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) the object on which a method is invoked

Back

The main method accepts an array of String as a parameter. True False

Front

True

Back

A two-dimensional array is suitable for storing tabular data. True False

Front

True; The two dimensions of the array mimic the row and column layout of the table.

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

T/F: The toString method is automatically called when an object is printed.

Front

True, And when an object is concatenated with a string; but the toString method DOES NOT print anything

Back

T/F: A binary search only works on a list of sorted elements

Front

True

Back

Program options are often specified using what?

Front

Command-line arguments

Back

T/F: A bounds error will result in an exception being thrown

Front

True; like when an invalid index is used to access an array

Back

Given the following code segment: int list[] = new list[10]; for (int i = 0; i < list.length; i++) list[i] = i * 10; What is the value of the first element in the list array after this code completes?

Front

0

Back

An object that holds a set of values that can be accessed using a numeric index.

Front

Array

Back

Which method signature could NOT represent an overloaded version of the following method? public int max(int x, int y) { return (x > y) ? x : y; } A) max(Object, Object) B) max(int, int) C) max(double, double) D) max(String, String) E) max(int, int, int)

Front

B) max(int, int) bc the signatures match exactly so this couldn't be an overloaded version of the method.

Back

T/F: The element type of an array can be any type except boolen

Front

False

Back

Given the following code segment: int list[] = new list[10]; for (int i = 0; i < list.length; i++) list[i] = i * 10; What is the value of list[3] after this code completes?

Front

30

Back

Section 4

(50 cards)

What must the child of an abstract class provide in order not to be considered abstract also?

Front

Must provide definitions for the inherited abstract methods

Back

Deriving one class from another establishes what kind of relationship between the two classes?

Front

is-a

Back

What is dynamic binding?

Front

When a line of code calls the same method every time and Java defers this binding until run time; ensures that the invocation is polymorphic

Back

A two-dimensional array is really a one-dimensional array of one-dimensional arrays. True False

Front

True; Each dimension of a multidimensional array is really a single-dimensional array.

Back

The maximum indexes of a two-dimensional array with 6 rows and 10 columns are 5 and 9, respectively. True False

Front

True; Each dimension is indexed from 0 to N-1, where N represents the number of elements in that dimension.

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

The instanceof operator determines if an object reference variable is currently pointing to an object of a particular type. True False

Front

True; It produces a boolean (true or false) result.

Back

What is the ultimate root of every class hierarchy?

Front

java.lang.Object class

Back

What are abstract methods?

Front

methods headers with no bodies

Back

Which of the following identifiers follow the naming convention for a Java constant? maxPenalties MAX_PENALTIES MAXPENALTIES Max_Penalties

Front

MAX_PENALTIES

Back

The expression x^y raises the value x to the power y. True/False

Front

False; Use Math.pow(x, y) instead

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

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 is an abstract class useful?

Front

When it is used to derive other classes; to make a class abstract must use abstract in the class header

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

If the final modifier is applied to a class, that class cannot be used to derive a subclass True/False

Front

True

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]; it's within the bounds and correctly called

Back

The first parameter to the printf method is the format string. True/False

Front

True; It determines what the output will look like. Ex. System.out.printf("|%-10d|%n", num); // width of 10, left justified

Back

Method overloading is helpful in which of the following situations? When two classes have the same name. When two methods have different return types. When a method has the same name as its enclosing class. When two methods perform a similar task on different types of data. When two methods perform a different task on the same types of data

Front

When two methods perform a similar task on different types of data.

Back

What Java keyword is used to create a subclass? interface implements extends inherits

Front

Extends

Back

A Java interface defines which of the following? system interface keyword interface printable interface user interface

Front

system interface; It defines the way one part of a system can talk to another.

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

What's an abstract class?

Front

is a placeholder in a class hierarchy that represents a general concept

Back

An integer can equal a double True/False

Front

False; only a double can equal an integer

Back

What are synonyms for the new class, the subclass?

Front

Child class, derived class

Back

Every class can only have one parent. True/False

Front

True; called single inheritance; a parent can derive multiple classes though

Back

What's a polymorphic reference?

Front

object variable that can refer to different types of objects at different points in time

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

A Java interface cannot be instantiated. True False

Front

True; unlike a class, you cannot create an object from an interface just methods

Back

What does the % sign perform?

Front

The remainder, so how much there is leftover AFTER the division is performed

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; it can also contain fully defined methods

Back

If a class is not explicitly derived from a particular class, where is it derived from?

Front

The Object class; can therefore point to any object bc it's inherited by all classes

Back

When a method is invoked, what determines which is invoked?

Front

The type of the object NOT the type of reference

Back

What character set does Java use to represent characters?

Front

Unicode

Back

How many elements can be stored in a two-dimensional array with dimensions 5 and 10?

Front

50

Back

An abstract class can instantiated True/False

Front

False

Back

A class can only implement one interface at a time. True False

Front

False; a class can implement multiple interfaces

Back

If both operands to the remainder operator (%) are positive, a divisor of n will produce a result in the range 1 to n. True/False

Front

False; It will produce a result in the range 0 to n-1.

Back

It is possible to create an array with more than two dimensions. True False

Front

True; A multidimensional array can have any number of dimensions, though more than three dimensions is rare.

Back

What is polymorphism?

Front

is the ability of a language to determine at runtime which of several possible methods will be executed

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

The methods of the Math class are called through the class name because they are abstract. True/False

Front

False, the methods of the Math class are static

Back

An abstract class cannot be declared as final

Front

True bc it must derive classes from it since it's abstract

Back

The methods in a Java interface are abstract. True False

Front

True; Interface methods don't have a body defined for them. That's up to the class that implements the interface.

Back

Private data and methods cannot be accessed by name in a derived class True/False

Front

True

Back

What are synonyms for the existing class, the superclass?

Front

Parent class, base class

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

Methods and data declared as protected can be accessed from any derived class True/False

Front

True

Back

Section 5

(47 cards)

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

A way to refer to a specific object.

Front

Identity

Back

What are the three parameters in order of the color method?

Front

Red, Green , Blue (RGB)

Back

The list of services that an object will perform.

Front

Behavior

Back

The values of an object's instance data.

Front

State

Back

Which of the following declares a valid PrintWriter object that represents an output file named myOutput.txt?

Front

PrintWriter out = new PrintWriter("myOutput.txt");

Back

What does the break statement do in a switch statement?

Front

It terminates each case; so if a case is found then it jumps out of the switch statement if break is there, if no break it keeps going

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

The String class is part of the java.util package. True/False

Front

False, it's part of the java.lang package

Back

When creating a Text object, you specify the position on which you want the text centered. True/False

Front

False, The coordinates specify where the leading (left) edge of the text begins.

Back

A program component that represents something and performs related tasks.

Front

Object

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 (obj1.equals(obj2)) means?

Front

Equivalent content

Back

The body of a for loop is always executed at least once. True/False

Front

False, Like a while loop, if the condition is false initially, the body is never executed.

Back

What's the default statement in a switch statement?

Front

The default statement is what is printed if no case values matched

Back

An import statement should be written inside a class but before any methods. True/False

Front

False, it should be written above the class

Back

A container that manages the visual presentation of the nodes it contains.

Front

Layout Pane

Back

In some cases, a sentinel value can be used to signal the end of input. True/False

Front

True, each input value is compared to the sentinel value to know when the loop should terminate.

Back

Each value of a case can be a constant, variable, or expression. True/False

Front

False, The value of each case can only be a constant (literal or named constant).

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

How do the ArcType.OPEN arcs look like?

Front

Just outlines the Ellipse

Back

A container that manages the nodes in an interface.

Front

Stage

Back

A JavaFX window.

Front

Stage

Back

What does this.radius=radius do?

Front

It assigns the parameter value to the instance data

Back

A particular object.

Front

Instance

Back

The classes of the java.util package are automatically imported into every Java program. True/False

Front

False, the only package automatically imported is java.lang

Back

The control variable must be declared in the for loop header. True/False

Front

False, It often is, but might also be declared previously.

Back

What number is printed by the following code? int num = 20; switch (num) { case 1: num = num + 1; break; case 12: num = num + 1; num = num * 2; case 20: num = num * 2; case 25: num = num + 1; break; case 999: num = 20; break; default: num = 999; } System.out.println(num);

Front

41

Back

What three numbers make white? Black? Gray?

Front

White- 255, 255, 255 Black- 0, 0, 0 Gray- all = numbers

Back

The body of a do-while loop is always executed at least one time True/False

Front

True, unlike while loops that execute from zero to n times

Back

The pattern from which an object is created.

Front

Class

Back

Which of the following is NOT a repetition statement in Java? if statement while statement for statement for-each statement do-while statement They are all repetition statements.

Front

if statement

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

if (obj1 == obj2) means?

Front

Point to same object (reference equality)

Back

The expression in a switch statement can be an int or double value. True/False

Front

False, a switch expression can only be a integer, character or enumeration constant (no floating-point).

Back

What's a do-while statement?

Front

repetition statement, or loop, allowing you to execute a set of programming statements multiple times.

Back

How do the ArcType.CHORD arcs look like?

Front

Closed half circle

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

Switch statements can only test equality; they cannot make relational comparisons like greater than (>). True/False

Front

True, A switch sees which case value matches its expression.

Back

The arithmetic operators have a lower precedence than the relational operators. True/False

Front

False; The arithmetic operators have a higher precedence than the relational operators

Back

The Java keyword new is a method that can be called to create objects. True/False

Front

False, new is an operator

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

The data managed by an object.

Front

Instance Data

Back

Defines the code that is executed when a method is called.

Front

Method declaration

Back

What's the switch statement?

Front

Same as an if nested statement; like an if statement but can choose among several options

Back

How do the ArcType.ROUND arcs look like?

Front

A triangle with a round edge but still 2 straight lines that point

Back

The increment section of the for loop header always adds 1 to the loop control variable.

Front

False, Although its called the increment section, you can update the control variable in any way you'd like.

Back