Deck 10: Text Processing and More About Wrapper Classes
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/49
العب
ملء الشاشة (f)
Deck 10: Text Processing and More About Wrapper Classes
1
When using the StringBuilder class's insert method,you can insert
A) any primitive type
B) a String object
C) a char array
D) All of the above
A) any primitive type
B) a String object
C) a char array
D) All of the above
D
2
To convert the int variable,number to a string,use the following statement.
A) String str = Integer.toString(number);
B) String str = integer.toString(number);
C) String str = integer(number);
D) String str = number.Integer.toString(str);
A) String str = Integer.toString(number);
B) String str = integer.toString(number);
C) String str = integer(number);
D) String str = number.Integer.toString(str);
A
3
What will be the value of matches after the following code is executed? boolean matches;
String[] productCodes = {"456HI345","3456hj"};
Matches = productCodes[0].regionMatches(true,1,
ProductCodes[1],2,3);
A) 56H
B) 56h
C) true
D) false
String[] productCodes = {"456HI345","3456hj"};
Matches = productCodes[0].regionMatches(true,1,
ProductCodes[1],2,3);
A) 56H
B) 56h
C) true
D) false
C
4
What will be the tokens in the following statement? StringTokenizer strToken = new StringTokenizer("123-456-7890",
"-",true);
A) 123,456,and 7890
B) -
C) 123,456,7890,and -
D) None of the above
"-",true);
A) 123,456,and 7890
B) -
C) 123,456,7890,and -
D) None of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
5
Assuming that str is declared as follows, String str = "RSTUVWXYZ";
What value will be returned from str.charAt(5)?
A) U
B) V
C) W
D) X
What value will be returned from str.charAt(5)?
A) U
B) V
C) W
D) X
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
6
What would be the results of executing the following code? StringBuilder str = new StringBuilder("Little Jack Horner ");
Str)append("sat on the ");
Str)append("corner");
A) The program would crash.
B) str would reference "Little Jack Horner ".
C) str would reference "Little Jac Horner sat on the ".
D) str would reference "Little Jack Horner sat on the corner".
Str)append("sat on the ");
Str)append("corner");
A) The program would crash.
B) str would reference "Little Jack Horner ".
C) str would reference "Little Jac Horner sat on the ".
D) str would reference "Little Jack Horner sat on the corner".
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
7
In a string that contains a series of words or other items of data separated by spaces or other characters,the programming term for the spaces or other characters is
A) token
B) delimiter
C) buffer
D) separator
A) token
B) delimiter
C) buffer
D) separator
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
8
What will be printed after the following code is executed? String str = "abc456";
Int m = 0;
While ( m < 6 )
{
If (Character.isLetter(str.charAt(m)))
System.out.print(
Character.toUpperCase(str.charAt(m)));
M++;
}
A) abc456
B) ABC456
C) ABC
D) 456
Int m = 0;
While ( m < 6 )
{
If (Character.isLetter(str.charAt(m)))
System.out.print(
Character.toUpperCase(str.charAt(m)));
M++;
}
A) abc456
B) ABC456
C) ABC
D) 456
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
9
The StringBuilder constructor used in the following statement will... StringBuilder str = new StringBuilder(25);
A) give the object,str,25 bytes of storage and store spaces in them
B) give the object,str,25 bytes of storage and not store anything in them
C) give the object,str,25 or more bytes of storage and store spaces in them
D) give the object,str,0 bytes of storage
A) give the object,str,25 bytes of storage and store spaces in them
B) give the object,str,25 bytes of storage and not store anything in them
C) give the object,str,25 or more bytes of storage and store spaces in them
D) give the object,str,0 bytes of storage
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
10
Use the following import statement when using the Character wrapper class
A) import java.Char
B) import java.lang.Char
C) import java.String
D) No import statement is needed
A) import java.Char
B) import java.lang.Char
C) import java.String
D) No import statement is needed
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
11
To use the StringTokenizer class you must have the following import statement.
A) import java.util.StringTokenizer;
B) import java.util.String;
C) import java.StringTokenizer;
D) import java.String;
A) import java.util.StringTokenizer;
B) import java.util.String;
C) import java.StringTokenizer;
D) import java.String;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
12
Which of the following statements will print the maximum value a double variable may have?
A) System.out.println(MAX_VALUE);
B) System.out.println(double.MAX_VALUE);
C) System.out.println(Double.MAX_VALUE);
D) System.out.println(Double.MAXIMUM_VALUE);
A) System.out.println(MAX_VALUE);
B) System.out.println(double.MAX_VALUE);
C) System.out.println(Double.MAX_VALUE);
D) System.out.println(Double.MAXIMUM_VALUE);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
13
When you are writing a program with String objects that may have unwanted spaces at the beginning or end of the strings,use this method to delete them.
A) replace
B) trim
C) valueOf
D) substring
A) replace
B) trim
C) valueOf
D) substring
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
14
What does the following statement do? Double number = new Double(8.8);
A) It creates a Double object
B) It initializes that object to 8.8
C) It assigns the object's address to the number variable
D) All of the above
A) It creates a Double object
B) It initializes that object to 8.8
C) It assigns the object's address to the number variable
D) All of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
15
What will be the value of str after the following statements are executed? StringBuilder str =
New StringBuilder("We have lived in Chicago," +
"Trenton,and Atlanta.");
Str)replace(17,24,"Tampa");
A) We have lived in Tampa,Trenton,and Atlanta.
B) We have lived in Chicago,Tampa,and Atlanta.
C) We have lived in Tampa Trenton,and Tampa.
D) We have lived in Tampalanta.
New StringBuilder("We have lived in Chicago," +
"Trenton,and Atlanta.");
Str)replace(17,24,"Tampa");
A) We have lived in Tampa,Trenton,and Atlanta.
B) We have lived in Chicago,Tampa,and Atlanta.
C) We have lived in Tampa Trenton,and Tampa.
D) We have lived in Tampalanta.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
16
What will be the value of loc after the following code is executed? int loc;
String str = "The cow jumped over the moon.";
Loc = str.indexOf("ov");
A) 15
B) 16
C) 17
D) 18
String str = "The cow jumped over the moon.";
Loc = str.indexOf("ov");
A) 15
B) 16
C) 17
D) 18
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
17
In the following statement,what data type must recField be? str.getChars(5,10,recField,0);
A) String
B) int
C) char
D) char[]
A) String
B) int
C) char
D) char[]
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
18
For the following code,how many times would the while loop execute? StringTokenizer strToken =
New StringTokenizer("Cars,trucks,and SUVs " +
"are all types of automobiles.");
While (strToken.hasMoreTokens())
{
System.out.println(strToken.nextToken());
}
A) 1
B) 5
C) 7
D) 9
New StringTokenizer("Cars,trucks,and SUVs " +
"are all types of automobiles.");
While (strToken.hasMoreTokens())
{
System.out.println(strToken.nextToken());
}
A) 1
B) 5
C) 7
D) 9
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
19
To convert the string,str = "285.74" to a double,use the following statement.
A) double x = str;
B) double x = Double.parseDouble(str);
C) double x = Double.Double(str);
D) double x = str,Double.parseDouble;
A) double x = str;
B) double x = Double.parseDouble(str);
C) double x = Double.Double(str);
D) double x = str,Double.parseDouble;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
20
The Character wrapper class provides numerous methods for
A) testing String objects
B) testing and converting char variables
C) converting String variables
D) adding two char variables
A) testing String objects
B) testing and converting char variables
C) converting String variables
D) adding two char variables
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
21
What would be the results of executing the following code? StringBuilder str = new StringBuilder(12);
Str)append("The cow");
Str)append(" jumped over the ");
Str)append("moon.");
A) The program would crash
B) str would reference "The cow jump"
C) str would reference "The cow jumped over the "
D) str would reference "The cow jumped over the moon."
Str)append("The cow");
Str)append(" jumped over the ");
Str)append("moon.");
A) The program would crash
B) str would reference "The cow jump"
C) str would reference "The cow jumped over the "
D) str would reference "The cow jumped over the moon."
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
22
Look at the following code. Integer myNumber = new Integer(5);
Int var = myNumber;
Which of the following is true about the second statement?
A) It results in an error because you cannot assign a wrapper class object to a primitive variable.
B) The statement performs autoboxing.
C) The statement performs unboxing.
D) The statement performs unwrapping.
Int var = myNumber;
Which of the following is true about the second statement?
A) It results in an error because you cannot assign a wrapper class object to a primitive variable.
B) The statement performs autoboxing.
C) The statement performs unboxing.
D) The statement performs unwrapping.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
23
Look at the following code. Integer myNumber;
MyNumber = 5;
Which of the following is true about the second statement?
A) It results in an error because you cannot assign a primitive type to a wrapper class object.
B) The statement performs autoboxing.
C) The statement performs unboxing.
D) The statement performs autowrapping.
MyNumber = 5;
Which of the following is true about the second statement?
A) It results in an error because you cannot assign a primitive type to a wrapper class object.
B) The statement performs autoboxing.
C) The statement performs unboxing.
D) The statement performs autowrapping.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
24
What does the following statement do? Float number = new Float(8.8);
A) It creates a Float object
B) It initializes that object to 8.8
C) It assigns the object's address to the number variable
D) All of the above
A) It creates a Float object
B) It initializes that object to 8.8
C) It assigns the object's address to the number variable
D) All of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
25
Given the following statement,which of the following is not true? str.insert(8,32);
A) str is a StringBuilder type object
B) The insert will start at position 32
C) The starting position for the insert is 8
D) The literal number 32 will be inserted
A) str is a StringBuilder type object
B) The insert will start at position 32
C) The starting position for the insert is 8
D) The literal number 32 will be inserted
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
26
What will be the tokens in the following statement? String str = "red$green&blue#orange";
String tokens = str.split("[$&#]");
A) "red","green","blue"and "orange"
B) "$","&",and "#"
C) "[","$","&","#",and "]"
D) None of the above
String tokens = str.split("[$&#]");
A) "red","green","blue"and "orange"
B) "$","&",and "#"
C) "[","$","&","#",and "]"
D) None of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
27
What will be printed after the following code is executed? String str = "abc456";
Int m = 0;
While ( m < 6 )
{
If (!Character.isLetter(str.charAt(m)))
System.out.print(
Character.toUpperCase(str.charAt(m)));
M++;
}
A) 456
B) ABC456
C) ABC
D) abc456
Int m = 0;
While ( m < 6 )
{
If (!Character.isLetter(str.charAt(m)))
System.out.print(
Character.toUpperCase(str.charAt(m)));
M++;
}
A) 456
B) ABC456
C) ABC
D) abc456
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
28
For the following code,how many times would the while loop execute? StringTokenizer strToken =
New StringTokenizer("Ben and Jerry's ice cream is great.");
While (strToken.hasMoreTokens())
{
System.out.println(strToken.nextToken());
}
A) 1
B) 3
C) 5
D) 7
New StringTokenizer("Ben and Jerry's ice cream is great.");
While (strToken.hasMoreTokens())
{
System.out.println(strToken.nextToken());
}
A) 1
B) 3
C) 5
D) 7
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
29
If you do not specify delimiters in the StringToken constructor,which of the following cannot be a delimiter?
A) Space
B) Tab
C) Semicolon
D) Newline
A) Space
B) Tab
C) Semicolon
D) Newline
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
30
What is the value of str after the following code has been executed? String str;
String sourceStr = "Hey diddle,diddle,the cat and the fiddle";
Str = sourceStr.substring(12,17);
A) diddle
B) diddl
C) ,didd
D) Iddle
String sourceStr = "Hey diddle,diddle,the cat and the fiddle";
Str = sourceStr.substring(12,17);
A) diddle
B) diddl
C) ,didd
D) Iddle
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
31
In a string that contains a series of words or other items of data separated by spaces or other characters,the programming term for the data items is
A) token
B) delimiter
C) buffer
D) separator
A) token
B) delimiter
C) buffer
D) separator
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
32
What will be the value of matches after the following code has been executed? boolean matches;
String str1 = "The cow jumped over the moon.";
String str2 = "moon";
Matches = str1.endsWith(str2);
A) true
B) false
C) moon
D) The cow
String str1 = "The cow jumped over the moon.";
String str2 = "moon";
Matches = str1.endsWith(str2);
A) true
B) false
C) moon
D) The cow
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
33
What will be the value of loc after the following code is executed? int loc;
String str = "The cow jumped over the moon.";
Loc = str.lastIndexOf("ov",14);
A) 15
B) 16
C) 0
D) -1
String str = "The cow jumped over the moon.";
Loc = str.lastIndexOf("ov",14);
A) 15
B) 16
C) 0
D) -1
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
34
What will be the tokens in the following statement? StringTokenizer strToken =
New StringTokenizer("January 1,2008",",",true);
A) The tokens will be:
January,1
2008
B) The tokens will be
,
Space
C) The tokens will be:
January
1
2008
Space
D) The tokens will be:
January
Space
1
,
Space
2008
New StringTokenizer("January 1,2008",",",true);
A) The tokens will be:
January,1
2008
B) The tokens will be
,
Space
C) The tokens will be:
January
1
2008
Space
D) The tokens will be:
January
Space
1
,
Space
2008
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
35
Two ways of concatenating two Strings are
A) Use the concat()method or use the + between the two Strings
B) Use the concatenate()method or use the + between the two Strings
C) Use the contenate()method or the concat()method
D) Use the concat()method or the trim()method
A) Use the concat()method or use the + between the two Strings
B) Use the concatenate()method or use the + between the two Strings
C) Use the contenate()method or the concat()method
D) Use the concat()method or the trim()method
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
36
Which of the following statements will print the maximum value an int variable may have?
A) System.out.println(MAX_VALUE);
B) System.out.println(integer.MAX_VALUE);
C) System.out.println(Integer.MAX_VALUE);
D) System.out.println(INTEGER.MAX_VALUE);
A) System.out.println(MAX_VALUE);
B) System.out.println(integer.MAX_VALUE);
C) System.out.println(Integer.MAX_VALUE);
D) System.out.println(INTEGER.MAX_VALUE);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
37
The no-arg constructor for a StringBuilder object gives the object enough storage space to hold this many characters.
A) 0 characters
B) 8 characters
C) 16 characters
D) 32 characters
A) 0 characters
B) 8 characters
C) 16 characters
D) 32 characters
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
38
If str is declared as String str = "ABCDEFGHI";
What will be returned from Character.toLowerCase(str.charAt(5))?
A) e
B) E
C) f
D) F
What will be returned from Character.toLowerCase(str.charAt(5))?
A) e
B) E
C) f
D) F
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
39
If a non-letter is passed to the toLowerCase or toUpperCase method,it is returned unchanged.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
40
To convert the string,str = "285" to an int,use the following statement
A) int x = str;
B) int x = Integer.parseInteger(str);
C) int x = Integer.integer(str);
D) int x = Integer.parseInt(str);
A) int x = str;
B) int x = Integer.parseInteger(str);
C) int x = Integer.integer(str);
D) int x = Integer.parseInt(str);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
41
StringBuilder objects are immutable.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
42
The String class's valueOf()method accepts a string representation as an argument and returns its equivalent integer value.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
43
If a non-letter argument is passed to the toLowerCase or toUpperCase method,the boolean value false is returned.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
44
The following statement correctly creates a StringBuilder object.
StringBuilder str = "Caesar Salad";
StringBuilder str = "Caesar Salad";
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
45
If you are using characters other than whitespaces as delimiters,you will probably want to trim the string before tokenizing;otherwise,the leading and/or following whitespaces will become part of the first and/or last token.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
46
You must call a method to get the value of a wrapper class object.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
47
If a string has more than one character used as a delimiter,we must write a loop to determine the tokens,one for each delimiter character.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
48
You cannot assign a value to a wrapper class object.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
49
The String class's valueOf()method accepts a value of any primitive data type as an argument and returns a string representation of the value.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck