
Java String Quiz Questions
This Java String quiz helps you revise core interview topics like String immutability, the string constant pool, StringBuilder, and StringBuffer. It mixes conceptual and code-based MCQs so you can quickly test whether your fundamentals are solid.
Java String Wrapper Class Quiz Important Multiple Choice Questions
1. Which of the below method of the String class can be used to test string equality?
A) equals()
B) isEqual()
C) isequals()
D) equal()
Answer
A
2. Which of the below method of String class is used to obtain character at specified index?
A) char()
B) Charat()
C) charAt()
D) CharacterAt()
Answer
C
3. What is the full form of Java String SCP?
A) String Collection Pool
B)Â String Constant Pool
C) String Common Pool
D) String Count Pool
Answer
B
4. Which of the below method of the String class can be used to find the total number of characters in the String?
A) chars()
B)Â size()
C) len()
D) length()
Answer
D
5. What would be the output of the below code related to String equality?
String s = new String(“PraBhu”); String p = new String(“PraBhu”); System.out.println(s == p);
A) true
B)Â false
Answer
B
6. Choose the correct output of the below code about String – Character Equality?
Character c = ‘A’; String s = “A”; System.out.println(c.equals(s));
A) true
B)Â false
Answer
B
7. Choose the correct output of the below code about the String value equality?
String s = new String(“ADevGuide”); String p = new String(“ADevguide”); System.out.println(s.equals(p));
A) true
B)Â false
Answer
A
8. Choose the correct output of the below code about String addition?
String s1 = “ADev”; String s2 = “Guide”; String s3 = s1 + s2; String s4 = “ADevGuide”; System.out.println(s4 == s3);
A) true
B)Â false
Answer
B
9. Choose the correct output of the below code about String compile-time addition?
String s1 = “ADev”; String s2 = “Guide”; String s3 = “ADev” + “Guide”; String s4 = “ADevGuide”; System.out.println(s4 == s3);
A) true
B)Â false
Answer
A
10. Choose the correct output of the below code?
String s1 = “ADev”; String s2 = “Guide”; String s3 = s1 + “Guide”; String s4 = “ADevGuide”; System.out.println(s4 == s3);
A) true
B)Â false
Answer
B
11. Choose the correct output of the below code?
String s1 = new String(“ADevGuide”); String s2 = s1.intern(); String s3 = “ADevGuide”; System.out.println(s1 == s2); System.out.println(s2 == s3);
A) true false
B) true true
C) false false
D) false true
Answer
D
12. Is the below statement true about the SCP and Garbage Collector?
Garbage Collector is not allowed to access SCP. SCP is destroyed only on JVM Shutdown.
A) True
B) False
Answer
A
13. Choose the correct output of the below code about String default value?
String s1 = new String(); System.out.println(s1 == null); System.out.println(s1 == "");
A) true false
B) true true
C) false false
D) false true
Answer
C  ; **Explaination:** s1.intern()==â€â€ will be true.
14. Choose the correct output of the below code about String Builder?
String s1 = “ADevGuide”; StringBuilder sb1 = new StringBuilder(“ADevGuide”); System.out.println(sb1.equals(s1));
A) true
B) false
Answer
B
15. Choose the correct output of the below code about String Builder equality?
StringBuilder sb1 = new StringBuilder(“ADevGuide”); StringBuilder sb2= new StringBuilder(“ADevGuide”); System.out.println(sb1.equals(sb2));
A) true
B) false
Answer
B
16. Choose the correct output of the below code about String Builder-String equality?
String s1 = “ADevGuide”; StringBuilder sb1 = new StringBuilder(“ADevGuide”); StringBuilder sb2= new StringBuilder(s1); System.out.println(sb1.equals(sb2));
A) true
B) false
Answer
B
To Learn More:
That’s all from now, we will keep adding more questions to the “Java String Wrapper Class Quizâ€. If you have any questions, drop us a comment below.