- Selenium
- JMeter
- DevOps
- VERSION CTRL
- ONLINE QUIZ
- Number System MCQ - 1
- Number System MCQ - 2
- Number System MCQ - 3
- Simplification MCQ - 1
- Average MCQ - 1
- Simple Interest MCQ - 1
- Compound Interest - MCQ
- Percentage - MCQ
- Ratio and Proportion - MCQ
- Profit and Loss - MCQ
- Time, Speed, and Distance - MCQ
- Time, and Work - MCQ
- Boats and Streams - MCQ
- General Knowledge Quiz - Indian Polity
- General Knowledge Quiz - History
- General Knowledge Quiz - Geography
- GK Quiz - Indian Polity - 2
- GK Quiz - Banking and Finance
- GK Quiz - Economics
- GK Quiz- Merger and Acquisition
- GK Quiz- International Bodies
- English Grammar quiz-1
- English Grammar quiz-2
- S/W PROJECT MANAGEMENT
- PROTRACTOR
- Java -Tutorials
- MORE
Java String MCQ
Multiple choice questions on Java strings for interview preparation. This quick assessment test on Strings in Java will help you assess your Java expertise.
Instructions
Topic- Java - String
The test consists of 13 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: What will be the output of the below code snippet?
String s1 = "Hello";
String s2 = "John";
System.out.println(s1.concat(s2));
String s1 = "Hello";
String s2 = "John";
System.out.println(s1.concat(s2));
Q2: What will be the output of the below code snippet?
StringBuffer sb = new StringBuffer();
sb.append("Hi");
sb.append("John");
System.out.println(sb.length());
StringBuffer sb = new StringBuffer();
sb.append("Hi");
sb.append("John");
System.out.println(sb.length());
Q3: String class in Java is immutable.
What does the above statement mean?
What does the above statement mean?
Q4: Which of the following are valid string functions?
Q5: Which of the following string initialization is correct?
1. String teststr = "test";
2. String teststr2 = new String ("test2");
1. String teststr = "test";
2. String teststr2 = new String ("test2");
Q6: What will be the output of the below code snippet?
String s1 = "Hello";
String s2 = "John";
System.out.println(s1.equals(s2));
String s1 = "Hello";
String s2 = "John";
System.out.println(s1.equals(s2));
Q7: What will be the output of the below code snippet?
String teststr = "testing";
char[] arr=teststr.toCharArray();
for(int p=arr.length-1;p>=0;p--) {
System.out.print(arr[p]);
}
String teststr = "testing";
char[] arr=teststr.toCharArray();
for(int p=arr.length-1;p>=0;p--) {
System.out.print(arr[p]);
}
Q8: Select the correct output of the below code snippet:
String str = "Hi";
str.concat("John");
System.out.println(str.length());
String str = "Hi";
str.concat("John");
System.out.println(str.length());
Q9: Select the correct output of the below code snippet:
String[] strArr = {"hi","john","how","are", "you"};
System.out.println(strArr.length);
String[] strArr = {"hi","john","how","are", "you"};
System.out.println(strArr.length);
Q10: Which of the following methods is used to find the length of a String in Java?
Q11: Which of the following is not a valid string function in Java?
Q12: Which method removes whitespace from the beginning and end of a String in Java?
Q13: Select the correct output of the below code snippet:
String str7 = "orange";
String str8 = "orange";
System.out.println(str7 == str8);
String str7 = "orange";
String str8 = "orange";
System.out.println(str7 == str8);
Q14: Select the correct output of the below code snippet:
String str7 = "orange";
String str8 = new String("orange");
System.out.println(str7 == str8);
String str7 = "orange";
String str8 = new String("orange");
System.out.println(str7 == str8);
More questions on Java String
Java string quiz