Loading

Q1.

Which of the following statements about Strings in Java is TRUE?

A. Strings are mutable objects

B. Strings are immutable objects

C. Strings are primitive data types

D. Strings cannot be compared

Q2.

What will be the output of the following code?


String s1 = "Java";

String s2 = "Java";

System.out.println(s1 == s2);

A. true
B. false
C. Compilation error
D. Runtime error

Q3.

Which method is used to compare the content of two strings in Java?

A. ==

B. equals()

C. compare()

D. match()

Q4.

Which of the following is the correct output?


String s = "Programming";

System.out.println(s.substring(3, 6));

A. Pro
B. gra
C. none
D. gram

Q5.

Which class is used when we need a mutable string in Java?

A. String

B. StringBuilder / StringBuffer

C. CharSequence

D. MutableString