Java Strings
Quiz
•
Other, Education, Computers
•
1st Grade - Professional Development
•
Hard
Darshan B
Used 58+ times
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
Strings in Java are _________.
Mutable
Immutable
Answer explanation
Strings in Java are immutable. When you make some changes to a string variable in Java, it actually creates a new String in the memory.
2.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
Which of the following is the incorrect way of creating a string in java?
var hello string = "world"
String hello = "World";
String hello = new String("World");
final static String hello = "World";
Answer explanation
var hello string = "world" is the incorrect way. This way of creating strings is used in GoLang, and not in Java.
3.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
What is the error in the following lines of code?
private String myMethod() {}
String is not being returned.
No value is being returned.
There is no error.
Answer explanation
In the following lines of code, a string should be returned from 'myMethod'. 'No value is being returned' might confuse you, but it is a string method, so particularly String should be returned and not any value.
4.
FILL IN THE BLANK QUESTION
45 sec • 1 pt
Create a String variable 'name' and put it equal to the value John Doe.
5.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
Which of the following will return the number of characters present in a String?
length()
length
sizeOf()
numberOfChars()
Answer explanation
Number of characters in a string means the length of the string, but length is not a property of strings in java. Instead, there is a method length. Hence, length() is correct, not length.
6.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
What will be the output of the following line of code?
HelloWorld
Hello World
"Hello World"
"HelloWorld"
Answer explanation
While printing strings, double quotes aren't printed. So "Hello World" and "HelloWorld" are cancelled. Now the trim function removes white space from starting and ending of a string, and not from center. So space between hello and world remains. There are no whitespaces on left and right, so Hello World is printed as it is.
7.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
What is the output of the following code?
True
False
true
false
Answer explanation
In java, booleans are written completely in lower case. Thus, True and False are eliminated.
Now Hello World starts with Hello and not hello (with lower case h) so output is false.
Create a free account and access millions of resources
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?
Similar Resources on Wayground
12 questions
Adventure game project
Quiz
•
7th - 8th Grade
15 questions
ข้อมูลและการประมวลผลข้อมูล
Quiz
•
7th Grade
15 questions
Cyber Security KS4
Quiz
•
8th - 12th Grade
15 questions
Всемирная паутина
Quiz
•
1st Grade
15 questions
BÚSQUEDA DE INFORMACIÓN
Quiz
•
University
10 questions
Grade 2 - Pollution and Climate Change
Quiz
•
1st - 2nd Grade
13 questions
WJEC GCSE ICT Unit 1 E-Mail
Quiz
•
9th - 10th Grade
10 questions
Scratch
Quiz
•
KG - Professional Dev...
Popular Resources on Wayground
20 questions
Halloween Trivia
Quiz
•
6th - 8th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
15 questions
Order of Operations
Quiz
•
5th Grade
20 questions
Halloween
Quiz
•
5th Grade
16 questions
Halloween
Quiz
•
3rd Grade
12 questions
It's The Great Pumpkin Charlie Brown
Quiz
•
1st - 5th Grade
20 questions
Possessive Nouns
Quiz
•
5th Grade
10 questions
Halloween Traditions and Origins
Interactive video
•
5th - 10th Grade
Discover more resources for Other
12 questions
Digital Citizenship BSMS
Quiz
•
6th - 8th Grade
25 questions
Career Clusters
Quiz
•
6th - 8th Grade
14 questions
Spookley the Square Pumpkin
Quiz
•
2nd Grade
15 questions
Week 13 ELA Spiral Review
Quiz
•
3rd Grade
15 questions
Complex sentences
Quiz
•
5th Grade
67 questions
Dia de los muertos
Quiz
•
7th - 8th Grade
57 questions
Study Guide: Ser y Estar, El presente, y verbos reflexivos
Quiz
•
9th Grade
10 questions
Welcome Back Wolves/Wolves Don't Belong in Yellowstone
Quiz
•
3rd Grade
