
String quiz
Authored by Caleb Kim
Computers
9th - 12th Grade
Used 3+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
25 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following methods will throw an exception if the input is invalid?
compareTo()
charAt()
contains()
equalsIgnoreCase()
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Consider the following code segment.
int one = 1;
int two = 2;
String zee = "Z";
System.out.println(one + two + zee);
What is printed as a result of executing the code segment?
12zee
onetwozee
3zee
3Z
12Z
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following code?
String s1 = "Elephant", s2 = "elephant", s3 = "aardvark"; //underscore represents space in output below
System.out.println(s1.compareTo(s2));
-32
-26
32
26
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following code?
String s1 = "Elephant", s2 = "elephant", s3 = "aardvark"; //underscore represents space in output below
System.out.println(s2.charAt(s2.length()));
t
n
error
k
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following code?
String s1 = "Elephant", s2 = "elephant", s3 = "aardvark"; //underscore represents space in output below
System.out.println(s3.charAt(s3.length()-1));
k
r
t
error
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following code?
String s1 = "Elephant", s2 = "elephant", s3 = "aardvark"; //underscore represents space in output below
System.out.println(s2.compareTo(s3));
-5
4
-4
5
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following code?
String s1 = "Elephant", s2 = "elephant", s3 = "aardvark"; //underscore represents space in output below
System.out.println(s2.substring(5, s2.length()));
nt
ant
error
hant
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Microsoft
or continue with
%20(1).png)
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?