Filters
Question type

Study Flashcards

You may cause an off-by-one error when working with a character position within a string if you think of the first position in the string as 1.

Correct Answer

verifed

verified

Which of the following statements converts a String object variable named str to an int and stores the value in the variable x?


A) int x = Integer.integer(str) ;
B) int x - str;
C) int x = Integer.parseInteger(str) ;
D) int x = Integer.parseInt(str) ;

Correct Answer

verifed

verified

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

Correct Answer

verifed

verified

The __________ class is the wrapper class for the char data type.


A) StringBuilder
B) Integer
C) Character
D) String

Correct Answer

verifed

verified

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


A) 14
B) 15
C) 18
D) 17

Correct Answer

verifed

verified

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


A) System.out.println(Double.MAX_VALUE) ;
B) System.out.println(Double.MAXIMUM_VALUE) ;
C) System.out.println(Double.MAX_VAL) ;
D) System.out.println(<double>(MAX_VALUE) ) ;

Correct Answer

verifed

verified

You can concatenate String objects by using the


A) concat or trim methods
B) concat method or the + operator
C) concatenate or join methods
D) concatenate method or the + operator

Correct Answer

verifed

verified

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


A) trim
B) getChar
C) toString
D) valueOf

Correct Answer

verifed

verified

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.


A) comma separated value
B) extensible markup language
C) excel binary
D) data interchange

Correct Answer

verifed

verified

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


A) W
B) X
C) V
D) U

Correct Answer

verifed

verified

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


A) 14
B) 1
C) 0
D) -1

Correct Answer

verifed

verified

The Character wrapper class provides numerous methods for


A) converting objects to primitive data types
B) testing and converting character data
C) testing and converting numeric literals
D) performing operations with named constants

Correct Answer

verifed

verified

Which of the following statements converts a double variable named tax to a string and stores the value in the String object named str?


A) String str = Double.toString(tax) ;
B) String str = double(tax) ;
C) String str = double.toString(tax) ;
D) String str = tax.Double.toString(str) ;

Correct Answer

verifed

verified

What will be displayed after the following code is executed? boolean matches; String str1 = "The cow jumped over the moon."; String str2 = "moon"; Matches = str1.endsWith(str1) ; System.out.println(matches) ;


A) true
B) moon
C) false
D) The cow

Correct Answer

verifed

verified

The __________ method returns a copy of the calling String object with all leading and trailing whitespace characters deleted.


A) remove
B) trim
C) compress
D) concat

Correct Answer

verifed

verified

What will be displayed after the following statements are executed? String str = "red$green&blue#orange"; String[] tokens = str.split("[$&#]") ; For (String s : tokens) System.out.print(s + " ") ;


A) red green blue orange
B) red $ green & blue # orange
C) $ & #
D) red[$&#]green[$&#]blue[$&#]orange

Correct Answer

verifed

verified

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


A) nested string
B) literal
C) substring
D) delimiter

Correct Answer

verifed

verified

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


A) 7
B) 4
C) 5
D) 1

Correct Answer

verifed

verified

A wrapper class is a class that is "wrapped around" a primitive data type and allows you to create objects instead of variables.

Correct Answer

verifed

verified

Most of the String comparison methods are case sensitive.

Correct Answer

verifed

verified

Showing 21 - 40 of 40

Related Exams

Show Answer