Chapter 7-11 and 14 Gaddis 6th, Starting out with java

¡Supera tus tareas y exámenes ahora con Quizwiz!

D) inheritance

In object-oriented programming, ________ allows you to extend the capabilities of a class by creating another class that is a specialized version of it. A) data hiding B) prototyping C) code reusability D) inheritance

False

True or False: Objects in an array are accessed with subscripts, just like any other data type in an array

valueOf

The String class's __________ method accepts a value of any primitive data type as its argument and returns a string representation of the value. -trim -getChar -toString -valueOf

C) base case

The ________ is at least one case in which a problem can be solved without recursion. A) point of absolution B) termination point C) base case D) recursive case

True

True or False: A problem can be solved recursively if it can be broken down into successive smaller problems that are identical to the overall problem.

The code contains a syntax error and will not compile.

What will be the result after the following code is executed? final int ARRAY_SIZE = 5; float[] x = float[ARRAY_SIZE]; for (i = 1; i <= ARRAY_SIZE; i++){ x[i] = 10.0; } -A runtime error will occur. -All the values in the array will be initialized to 10.0. -All the values in the array except the first will be set to 10.0. -The code contains a syntax error and will not compile.

B) import javafx.scene.layout.BorderPane;

Which of the following import statements is required in order to create a BorderPane layout container? A) import javafx.scene.layout.Box; B) import javafx.scene.layout.BorderPane; C) import javafx.layout.scene.BorderPane; D) import javafx.scene.layout;

import java.util.StringTokenizer;

Which of the following import statements is required to use the StringTokenizer class? -import java.util.Scanner; -import java.text.DecimalFormat; -import java.util.StringTokenizer; -import javax.swing.JOptionPane;

int x = Integer.parseInt(str);

Which of the following statements converts a String object variable named str to an int and stores the value in the variable x? -int x = Integer.integer(str); -int x = str; -int x = Integer.parseInteger(str); -int x = Integer.parseInt(str);

B) public class Salaried extends PayType

Which of the following statements declares Salaried as a subclass of PayType? A) public class PayType derives Salaried B) public class Salaried extends PayType C) public class Salaried derivedFrom(PayType) D) public class Salaried implements PayType

A) Indirect recursion

________ occurs when method A calls method B which in turn calls method A. A) Indirect recursion B) Dynamic recursion C) Direct recursion D) Linear recursion

tokens

A series of words or other items of data, separated by spaces or other characters, are known as -strings -tokens -delimiters -captions

Subscript

A(n) __________ is used as an index to pinpoint a specific element within an array. -boolean value -element -range -subscript

A) event source.

An action that takes place while a program is running is a(n) A) event source. B) event object. C) event handler. D) event.

B) the region will not appear in the GUI.

If a BorderPane region does not contain anything, A) the region will appear gray by default. B) the region will not appear in the GUI. C) an error will occur. D) content from an adjacent region will be duplicated to appear in the empty region.

comma separated value

In the __________ file format, when data in a spreadsheet is exported, each row is written to a line and commas are used to separate the values in the cells. -comma separated value -extensible markup language -excel binary -data interchange

polymorphic byte code

Java provides a mechanism known as a __________ which makes it possible to write a method that takes a variable number of arguments. -variable-length argument list -dynamic parameter list -unary-signature template -polymorphic byte code

A) some way to control the number of time it repeats

Like a loop, a recursive method must have which of the following? A) some way to control the number of time it repeats B) a statement that increments the control variable C) a control variable initialized to a starting value D) All of these

remove

The __________ method removes an item from an ArrayList at a specific index. -remove -pop -deleteAt -clear

C) registering

The process of connecting an event handler object to a control is called ________ the event handler. A) rendering B) passing C) registering D) applying

C) setAlignment method.

To change the alignment of an HBox you call the A) Pos method. B) Alignment method. C) setAlignment method. D) PreferredSize method.

False

True or False: A recursive method can have only one base case.

True

True or False: A sorting algorithm is used to locate a specific item in a larger collection of data.

True

True or False: All JavaFX applications must extend the Application class.

True

True or False: An ArrayList object automatically expands in size to accommodate the items stored in it

True

True or False: An event object is created when an event takes place.

False

True or False: You cannot assign a value to a wrapper class object.

True

Trur or False: An abstract class is not instantiated itself but serves as a superclass for other classes.

add

Which of the following ArrayList class methods is used to insert an item at a specific location in an ArrayList? -set -store -add -insert

A) overhead.

The actions performed by the JVM that take place with each method call are sometimes referred to as A) overhead. B) overflow. C) retention. D) allocation.

True

True or False: Trying to extract more tokens than exist from a StringTokenizer object will cause an error.

True

True or False: When an "is a" relationship exists between objects, it means that the specialized object has all the characteristics of the general object plus additional characteristics that make it special.

int[][] ragged = new int[5][];

Which of the following is a valid declaration for a ragged array with five rows but no columns? -int[][] ragged = new int[5]; -int[][] ragged = new int[][5]; -int[][] ragged = new int[5][]; -int[] ragged = new int[5];

D) All of these are ways a user can interact with a computer.

Which of the following is not a way a user can interact with a computer? A) console interface B) GUI C) command line D) All of these are ways a user can interact with a computer.

D) are treated as final and static.

All fields declared in an interface A) must be initialized in the class implementing the interface. B) have protected access. C) have private access. D) are treated as final and static.

D) 5

Given the following code that uses recursion to find the factorial of a number, how many times will the else clause be executed if n = 5? private static int factorial(int n) { if (n == 0) return 1; else return n * factorial(n - 1); } A) 6 B) 3 C) 4 D) 5

A) overrides

If a method in a subclass has the same signature as a method in the superclass, the subclass method ________ the superclass method. A) overrides B) implements C) inherits D) overloads

A) a UML diagram

In ________, inheritance is shown with a line that has an open arrowhead at one end that points to the superclass. Question options: A) a UML diagram B) a CRC card C) a hierarchy chart D) pseudocode

nonletter

Any ___________ argument passed to the Character class's toLowerCase method or toUpperCase method is returned as it is. -nonletter -char -string -static

4

Given the following code, how many times will the while loop be executed? StringTokenizer st = new StringTokenizer("Java programming is fun!"); while (st.hasMoreTokens()) System.out.println(st.nextToken()); -7 -4 -5 -1

D) package

If you don't provide an access specifier for a class member, the class member is given ________ access by default. A) public B) protected C) private D) package

C) instanceOf

Which of the following is the operator used to determine whether an object is an instance of a particular class? A) equals B) >> C) instanceOf D) isa

D) All of these

Which of the following problems can be solved recursively? A) greatest common denominator B) binary search C) Towers of Hanoi D) All of these

A) if (x % y == 0) return y;

In the following code that uses recursion to find the greatest common divisor of a number, what is the base case? public static int gcd(int x, int y) { if (x % y == 0) return y; else return gcd(y, x % y); } A) if (x % y == 0) return y; B) gcd(int x, int y) C) else return gcd(y, x % y); D) Cannot tell from this code

C) dashed line with an open arrowhead at one end.

In a UML diagram you show a realization relationship by connecting a class and an interface with a A) line with an open diamond at one end. B) line with an open arrowhead at one end. C) dashed line with an open arrowhead at one end. D) dashed line.

B) the depth of recursion.

In a recursive program, the number of times a method calls itself is known as A) the cyclic identity. B) the depth of recursion. C) the method heap. D) the call count.

B) scene, nodes

In memory, GUI objects in a ________ are organized as ________ in a tree-like hierarchical data structure. A) node, scenes B) scene, nodes C) scene graph, nodes D) scene graph, methods

B) #

Protected class members can be denoted in a UML diagram with the ________ symbol. A) + B) # C) * D) -

testing and converting character data

The Character wrapper class provides numerous methods for: -converting objects to primitive data types -testing and converting character data -testing and converting numeric literals -performing operations with named constants

All of these

The StringBuilder class's insert method allows you to insert a(n) __________ into the calling object's string. -char array -primitive type -String object -All of these

B) GridPane

The ________ layout container arranges the contents into cells, similar to a spreadsheet. A) GridPaneObj B) GridPane C) GRID D) CellPane

True

True or False: Any problem that can be solved recursively can also be solved iteratively, with a loop.

True

True or False: Recursion is never absolutely required to solve a problem.

W

What will be displayed after the following code is executed? String str = "RSTUVWXYZ"; System.out.println(str.charAt(5)); -W -X -V -U

True

True or False: Because the subclass is more specialized than the superclass, it is sometimes necessary for the subclass to replace inadequate superclass methods with more suitable ones.

False

True or False: If a string has more than one character used as a delimiter, you must write a loop to determine the tokens, one for each delimiter character.

False

True or False: In a JavaFX application, you are limited to a single layout container since layout containers cannot be nested.

False

True or False: In an inheritance relationship, the subclass constructor always executes before the superclass constructor.

True

True or False: The String class's regionMatches method performs a case-insensitive comparison.

False

True or False: The String class's valueOf method accepts a string representation as an argument and returns its equivalent integer value.

False

True or False: The command line interface is an event-driven interface.

the array must first be sorted

In order to do a binary search on an array: -the array must first be sorted -you must first do a sequential search to be sure the element you are looking for is there -the values of the array must be numeric -All of these are true

B) myView.setPreserveRatio(true);

In order to preserve an image's aspect ratio (so it does not appear stretched or distorted), you should use which of the following? Assume myView references an ImageView object. A) myView.setPreserveRatio(); B) myView.setPreserveRatio(true); C) myView.setPreserveRatio(false); D) Either A or C would work.

C) recursive case

In the ________, we must always reduce the problem to a smaller version of the original problem. A) lessening case B) base case C) recursive case D) partition case

A) ClassA

In the following statement, which is the subclass? public class ClassA extends ClassB implements ClassC A) ClassA B) ClassB C) ClassC D) Both ClassB and ClassC are subclasses.

True

True or False: Because every class directly or indirectly inherits from the Object class, every class inherits the Object class's members.

True

True or False: The String[] args parameter in the main method header allows the program to receive arguments from the operating system command-line

False

True or False: The recursive case does not require recursion so it stops the chain of recursive calls.

True

True or False: To determine if two arrays are equal you must compare each of the elements of the two arrays.

False

True or False: To display an image in a JavaFX application, you use either the Image or ImageView class.

9, 14, 2018, and -

What are the tokens in the following statement? StringTokenizer st = new StringTokenizer("9-14-2018", "-", true); 9, 14, 2018 9, 14, 2018, and - - -None of these

is used to locate a specific item in a collection of data

A search algorithm: -arranges elements in ascending order -arranges elements in descending order -is used to locate a specific item in a collection of data -is rarely used with arrays

All of these are true

Which of the following statements is(are) true about this code? final int ARRAY_SIZE = 10; long[] array1 = new long[ARRAY_SIZE]; -It declares array1 to be a reference to an array of long values. -It will allow valid subscripts in the range of 0 through 9. -It creates an instance of an array of ten long values. -All of these are true.

B) javafx.geometry

Which package contains the Insets class? A) javafx.Insets B) javafx.geometry C) javafx.scene D) javafx.layout

set

You can use the __________ method to replace an item at a specific location in an ArrayList. -set -remove -replace -add

with an accompanying integer value that holds the number of items stored in the array

A partially filled array is normally used: -when only a very small number of values need to be stored -when you know how many elements will be in the array but not what the values are -with an accompanying parallel array -with an accompanying integer value that holds the number of items stored in the array

B) only public and protected members of the superclass.

A subclass can directly access A) only protected and private members of the superclass. B) only public and protected members of the superclass. C) all members of the superclass. D) only public and private members of the superclass.

B) abstract

A(n) ________ method is a method that appears in a superclass but expects to be overridden in a subclass. A) protected B) abstract C) static D) overloaded

B) TextField, javafx.scene.control

To create a TextField control, you use the ________ class which is in the ________ package. A) TextField, javafx.text.control B) TextField, javafx.scene.control C) TextField, javafx.textfield D) TextBox, javafx.scene.control

A) The array must be sorted.

To use recursion for a binary search, what is required before the search can proceed? A) The array must be sorted. B) The array must include only integers. C) The array can only include numerical values. D) All of these are required.

D) It loads an image file named terrier.jpg which is found in the images folder on the user's C-drive.

What does the following statement do? Image puppy = new Image("file:C:\\images\terrier.jpg"); A) It loads an image named "images\terrier.jpg" and stores the image in the Image variable. B) Nothing; it is not possible to include a path to a file when using the Image class. C) It creates an instance of the ImageView class with the terrier.jpg file passed to the constructor. D) It loads an image file named terrier.jpg which is found in the images folder on the user's C-drive.

94

What is the value of scores[2][3] in the following array? int[][] scores = { {88, 80, 79, 92}. {75, 84, 93, 80}, {98, 95, 92, 94}, {91, 84, 88, 96} }; -95 -84 -94 -93

The cow jumped over the moon.

What will be displayed after the following code is executed? StringBuilder strb = new StringBuilder(12); strb.append("The cow "); strb.append("jumped over the "); strb.append("moon."); System.out.println(strb); -The cow jumped over the moon. -The cow jumped over the moon. -The cow jump -12The cow jumped over the moon.

We have lived in Tampa, Trenton, and Atlanta.

What will be displayed after the following statements are executed? StringBuilder strb = new StringBuilder("We have lived in Chicago, Trenton, and Atlanta."); strb.replace(17, 24, "Tampa"); System.out.println(strb); -We have lived in Tampa, Trenton, and Atlanta. -We have lived in Chicago, Trenton, and Tampa. -We have lived in Chicago,Tampaon, and Atlanta. -We have lived in Chicago, Tampa, and Atlanta.

15

What will be the value of position after the following code is executed? int position; String str = "The cow jumped over the moon."; position = str.indexOf("ov"); -14 -15 -18 -17

The value variable will contain the lowest value in the numbers array.

What would be the result after the following code is executed? int[] numbers = {40, 3, 5, 7, 8, 12, 10}; int value = numbers[0]; for (int i = 1; i < numbers.length; i++){ if (numbers[i] < value) value = numbers[i]; } -The value variable will contain the average of all the values in the numbers array. -The value variable will contain the sum of all the values in the numbers array. -The value variable will contain the lowest value in the numbers array. -The value variable will contain the highest value in the numbers array.

An array of 6 values, ranging from 0 through 5 and referenced by the variable x will be created.

What would be the result of executing the following code? int[] x = {0, 1, 2, 3, 4, 5}; -An array of 6 values, all initialized to 0 and referenced by the variable x will be created. -An array of 6 values, ranging from 0 through 5 and referenced by the variable x will be created. -The variable x will contain the values 0 through 5. -A compiler error will occur.

A) extends

Which key word indicates that a class inherits from another class? A) extends B) final C) implements D) super

import java.util.ArrayList;

Which of the following import statements is required in order to use the ArrayList class? -import java.util.Tools; -import java.util.ArrayList; -import java.util.Containers; -import java.util.API;

D) class hierarchy

Which of the following shows the inheritance relationships among classes in a manner similar to that of a family tree? A) CRC card B) flowchart C) UML diagram D) class hierarchy

A) public class ClassA implements Interface1, Interface2

Which of the following statements correctly specifies two interfaces? A) public class ClassA implements Interface1, Interface2 B) public class ClassA implements Interface1 | Interface2 C) public class ClassA implements (Interface1, Interface2) D) public class ClassA implements [Interface1, Interface2]

System.out.println(Double.MAX_VALUE);

Which of the following statements will display the maximum value that a double can hold? -System.out.println(Double.MAX_VALUE); -System.out.println(Double.MAXIMUM_VALUE); -System.out.println(Double.MAX_VAL); -System.out.println(<double>(MAX_VALUE));


Conjuntos de estudio relacionados

Bio - Chapter 21 - evidence for evolution (a), Bio - Chapter 21 - evidence for evolution (b), Bio - Chapter 21 - evidence for evolution (c), Bio - Chapter 21 - evidence for evolution (d), Bio - Chapter 21 - evidence for evolution (e)

View Set

Carbon and Alloy Steels and Alloy Steel Filler Metals

View Set

CNA HIPAA (Health Insurance Portability Accountability Act)

View Set

Chapter 25 Hematologic Disorders Adaptive Quizzing

View Set

13.1 Classical Perspectives on Personality

View Set

Stimulate Your Exam Life and Health

View Set