Previous | Home | Next |
Answer: java.lang package.
Answer: length( ) method.
Answer: By using " + " operator.
Answer: equals( ) method.
Q.5 Which method can be used to perform a comparison between strings that ignores case differences?
Answer: equalsIgnoreCase( ) method.
Answer: valueOf( ) method converts data from its internal format into a human-readable form.
Answer: The method toLowerCase( ) converts all the characters in a string from uppercase to lowercase.
The method toUpperCase( ) converts all the characters in a string from lowercase to uppercase.
Q.8 Which method can be used to find out the total allocated capacity of a StrinBuffer?
Answer: capacity( ) method.
Q.9 Which method can be used to set the length of the buffer within a StringBuffer object?
Answer: setLength( ).
Answer: String objects are constants, whereas StringBuffer objects are not.
String class supports constant strings, whereas StringBuffer class supports growable, modifiable strings.
Answer: Wrapper classes are classes that allow primitive types to be accessed as objects.
(a). String
(b). Integer
(c). Boolean
(d). Character
Answer: (a). String
public class Q: { public static void main(String args[]) { String s1 = "abc"; String s2 = "def"; String s3 = s1.concat(s2.toUpperCase( ) ); System.out.println(s1+s2+s3); } }
(a). abcdefabcdef
(b). abcabcDEFDEF
(c). abcdefabcDEF
(d). None of the above
Answer: (c). abcdefabcDEF
Q.14 Which of the following methods cause the String object referenced by s to be changed?
(a). s.concat( )
(b). s.toUpperCase( )
(c). s.replace( )
(d). s.valueOf( )
Answer:
(a). s.concat( )
(b). s.toUpperCase( )
(a). delete( )
(b). append( )
(c). reverse( )
(d). replace( )
Answer: (d). replace( )
(a).True
(b).False
Answer: (b).False
String s=new String("Bicycle"); int iBegin=1; char iEnd=3; System.out.println(s.substring(iBegin,iEnd));
(a). Bic
(b). ic
(c). icy
(d). error: no method matching substring(int,char)
Answer: (d). replace( )
String s1=new String("Hello") String s2=new String("there"); String s3=new String();
Which of the following are legal operations?
(a). s3=s1 + s2;
(b). s3=s1 - s2;
(c). s3=s1 & s2
(d). s3=s1 && s2
Answer: (a). s3=s1 + s2;
(a). The String class is implemented as a char array, elements are addressed using the stringname[] convention
(b). Strings are a primitive type in Java that overloads the + operator for concatenation
(c). Strings are a primitive type in Java and the StringBuffer is used as the matching wrapper type
(d). The size of a string can be retrieved using the length property.
Answer: (b). Strings are a primitive type in Java that overloads the + operator for concatenation
Previous | Home | Next |