Quiz 3
In the Java programming language, strings are Not objects.
False
You would use the length() method to find the length of a string.
True
What is the output of the following program: String a ="Welcome to "; String b = "California!"; b = a + b; System.out.println(b);
Welcome to California!
A string literal is:
a series of characters in your code that is enclosed in double quotes.
The following is the correct syntax to create a string: string greeting = "I Love Java!";
False
What is the output of the following segment of code: String string1 = "Jill went up "; System.out.println("Jack and " + string1 + "the Hill.");
Jack and Jill went up the Hill.
What is the output of this code segment: char[] helloArray = { 'h', 'e', 'l', 'l', 'o', '.' }; String helloString = new String(helloArray); System.out.println(helloString);
hello
If you wanted to get more than one consecutive character which method would you use?
substring()
What method would you call to convert an object that is not a string?
toString()
You can get the character at a particular index within a string by invoking the ____________ accessor method.
NOT: indexAt() stringAt() letterAt()
Methods used to obtain information about an object are known as _______ methods.
accessor
The index of the first character in a string is:
0
What is the output of the following code segment: String s1 = "Hello, how are you?"; int pos = s1.indexOf("how"); System.out.println( "Pos = " + pos );
7
Which of the following operators is used to concatenate strings:
+
As with any other object, you can create String objects by using the ______ keyword and a constructor.
new
The following is allowed in Java: String quote = "Jack and Jill went up the Hill " + "to fetch a pail of water..."
No
What is the output of the following code segment: String s1 = "Love Java!"; System.out.println( "String Length = " + s1.length() );
String Length = 10