Font size
WorksheetsJava Strings
Total questions: 10
Worksheet time: 8mins
Strings in Java are _________.
Mutable
Immutable
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";
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.
Create a String variable 'name' and put it equal to the value John Doe.
(a)
Which of the following will return the number of characters present in a String?
length()
length
sizeOf()
numberOfChars()
What will be the output of the following line of code?
HelloWorld
Hello World
"Hello World"
"HelloWorld"
What is the output of the following code?
True
False
true
false
What is the output of following code?
Llo World
Hello World
llo World
llo world
What is the output of the following lines of code?
8
r
o
IndexOutOfBoundsException in thread main
What is the output of the following code?
HELLO WORLD
hello world
"HELLO WORLD"
Hello World
