Java Chapter 8 Quiz

अब 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.lastIndexOf("ov", 14);

-1

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

9, 14, 2014, and -

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

False

Which of the following import statements is required to use the Character wrapper class? import java.lang.Char import java.String import java.Char No import statement is needed

No import statement is needed

Which of the following statements converts a double variable named tax to a string and stores the value in the String object variable named str? String str = tax.Double.toString(str); String str = double.toString(tax); String str = double(tax); String str = Double.toString(tax);

String str = Double.toString(tax);

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 are used as delimiters if the StringTokenizer class's constructor is called and a reference to a String object is passed as the only argument? newline space tab

all of the above

In the following statement, what data type must recField be? str.getChars(5, 10, recField, 0);

char []

You cannot assign a value to a wrapper class object. (T/F)

false

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

import java.util.StringTokenizer;

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 = str; int x = Integer.integer(str); int x = Integer.parseInteger(str); int x = Integer.parseInt(str);

int x = Integer.parseInt(str);

What will be displayed after the following code has been executed? String str1 = "The quick brown fox jumped over the lazy dog."; String str2 = str1.substring(20, 26); System.out.println(str2);

jumped

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

nonletter

The term ________ commonly is used to refer to a string that is part of another string.

substring

The Character wrapper class provides numerous methods for

testing and converting character data

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

tokens

The ________ method returns a copy of the calling String object, in which all leading and trailing whitespace characters have been deleted.

trim

Trying to extract more tokens than exist from a StringTokenizer object will cause an error. (T/F)

true

You will cause an off-by-one error, when working with a character position within a string, if you think of the first position in a string as 1. (T/F)

true

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


संबंधित स्टडी सेट्स

OB Module 2: Care of the Pregnant Woman

View Set

Integumentary Assessment/Problems

View Set

Lewis Chapter 16: Fluid, Electrolyte, and Acid-Base Imbalances

View Set

HRT 390- Chapter 9, 10, 11, 12, 14

View Set