CIT260 Midterm

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

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");

15

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());

4

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

9, 14, 2018, and -

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} };

94

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.

Objects in an array are accessed with subscripts, just like any other data type in an array

True

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

True

To determine if two arrays are equal you must compare each of the elements of the two arrays.

True

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

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

Which of the following is the operator used to determine whether an object is an instance of a particular class?

instanceOf

Which of the following is a valid declaration for a ragged array with five rows but no columns?

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

A search algorithm _____________

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

Any ___________ argument passed to the Character class's toLowerCase method or toUpperCase method is returned as it is.

nonletter

A subclass can directly access

only public and protected members of the superclass.

Which of the following statements correctly specifies two interfaces?

public class ClassA implements Interface1, Interface2

In a UML diagram you show a realization relationship by connecting a class and an interface with a

dashed line with an open arrowhead at one end

In the following statement, which is the subclass? public class ClassA extends ClassB implements ClassC

ClassA

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

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

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

In an inheritance relationship, the subclass constructor always executes before the superclass constructor.

False

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

False

You cannot assign a value to a wrapper class object.

False

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.

The __________ method removes an item from an ArrayList at a specific index.

Remove

A(n) __________ is used as an index to pinpoint a specific element within an array.

Subscript

Which of the following statements will display the maximum value that a double can hold?

System.out.println(Double.MAX_VALUE);

The Character wrapper class provides numerous methods for

Testing and converting character data

In order to do a binary search on an array

The array must first be sorted

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;}

The code contains a syntax error and will not compile.

A series of words or other items of data, separated by spaces or other characters, are known as

Tokens

An ArrayList object automatically expands in size to accommodate the items stored in it

True

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

True

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

True

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.

True

The String class's regionMatches method performs a case-insensitive comparison.

True

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

True

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.

True

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

W

A partially filled array is normally used

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

In ________, inheritance is shown with a line that has an open arrowhead at one end that points to the superclass.

a UML diagram

A(n) ________ method is a method that appears in a superclass but expects to be overridden in a subclass.

abstract

All fields declared in an interface

are treated as final and static.

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

Which of the following shows the inheritance relationships among classes in a manner similar to that of a family tree?

class hierarchy

Which key word indicates that a class inherits from another class?

extends

Which of the following import statements is required in order to use the ArrayList class?

import java.util.ArrayList;

Which of the following import statements is required to use the StringTokenizer class?

import java.util.StringTokenizer;

In object-oriented programming, ________ allows you to extend the capabilities of a class by creating another class that is a specialized version of it.

inheritance

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.parseInt(str);

If a method in a subclass has the same signature as a method in the superclass, the subclass method ________ the superclass method.

overrides

If you don't provide an access specifier for a class member, the class member is given ________ access by default.

package

Protected class members can be denoted in a UML diagram with the ________ symbol.

#

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

Add

What would be the result of executing the following code?

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

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 lowest value in the numbers array.

Which of the following statements declares Salaried as a subclass of PayType?

public class Salaried extends PayType

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

set

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

valueOf


Ensembles d'études connexes

French 10- Les Questions (Quand, Depuis quand, ou, pourquoi, comment, combien de, quel, qu'est-ce que, qui) #1

View Set

Prep U Ch 45 Digestive and Gastrointestinal Treatment Modalities

View Set

ZOOLOGY II UNIT 2 FISH REVIEW WORKSHEET

View Set

Final Test for MPhil - Comparative Government

View Set

CHAPTER 17 - OLDER ADULTHOOD: PERSONALITY AND SOCIOCULTURAL DEVELOPMENT

View Set

Chapter 7: Memory: Constructing and Reconstructing Our Pasts

View Set