![16 Java String Wrapper Class Quiz Important Questions [MCQ]](/images/blog/2021-08-Java-String-Wrapper-Class-Quiz-Important-Questions-MCQ.jpg)
16 Java String Wrapper Class Quiz Important Questions Multiple Choice
Hello learners, we have created a Java String Wrapper Class Quiz MCQ to help you check your Java Strings knowledge. This quiz is a mixture of theoretical and code-based MCQs. The quiz will be useful for you to revise your Java String Concepts.
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
20 Java Regular Expressions Quiz Regex Important Questions [MCQ]
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.