Java Quiz on String


This section contains a quick assessment test on Java string for interview preparation.



Instructions

Topic- Java - String

The test consists of 11 questions.

No negative marking for this test.

No Time limit

The pass percentage is 70%

The correct answer with a description will be displayed after the answer has been marked.

Submit the test to calculate your score once you are done with all the questions.

Complexity Level- Moderate




Q1: Which of the following is true for StringBuilder class?


















Q2: Which of the following is true for StringBuffer class?


















Q3: StringBuffer is immutable.

Select true or false











Q4: StringBuilder is mutable

Select true or false











Q5: Which of the following is true for split() method in String?















Q6: Which of the following is true for subString() method in String?











Q7: Given a string -

String str = "my name is robert";

String str2 = str.substring(3, 8);

System.out.println(str2);

What will be the output?















Q8: Identify the output of the below String operation:

String str4 = "My @name is @John";

String[] str3=str4.split("@", 5);

for(String a: str3) {
System.out.println(a);
}















Q9: What will be the output of the below code snippet?

String str = "my name is Robert";
System.out.println(str.charAt(4));















Q10: Select the correct output of the below code snippet:

StringBuffer s = new StringBuffer();
s.append("Hello");
s.append("world");
String str2 = s.toString();
System.out.println(str2);















Q11: Select the correct output of the below code snippet:

String str3="Hello";
str3.concat("Robert");
System.out.println(str3);



























Quick Assessment Tests on Java



Java quiz 1

Java quiz 2

Java quiz 3

Java quiz 4

Java quiz 5

Java quiz 6

Java quiz 7

Java quiz 8

Java quiz 9

Java quiz 10