Files
java-interview-lab/fresher-qa/output/03-strings.txt
T

32 lines
1.0 KiB
Plaintext

=== Q21 == vs equals() on Strings ===
a == b -> true
a == c -> false
a.equals(c) -> true
=== Q22 Why is String immutable? ===
s = java
upper = JAVA
same object returned when nothing changes: true
=== Q23 String vs StringBuilder vs StringBuffer ===
builder result: cba-
append is synchronized: StringBuffer=true, StringBuilder=false
=== Q24 The string pool, compile-time constants and intern() ===
"hel" + "lo" == "hello" -> true
"hel" + lo == "hello" -> false
"hel" + finalLo == "hello" -> true
("hel" + lo).intern() == "hello" -> true
=== Q25 Reverse a string and check for a palindrome ===
weivretni
true
false
=== Q26 Useful String methods and the split() surprises ===
trim().length() = 6
strip().length() = 2
" ".isBlank() = true, "ab".repeat(3) = ababab
"a,b,,".split(",").length = 2
"a,b,,".split(",", -1).length = 4
String.join: 2026-11-11
=== Q27 Count characters, find the first non-repeating one, check anagrams ===
frequency: {s=3, w=1, i=1}
first non-repeating: w
listen/silent anagrams: true