Add fresher-qa module: 50 Java interview questions for freshers, one runnable demo each, asserted transcripts, javac error captures
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b5DfjBGLBr7F5km2AN
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
=== 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
|
||||
Reference in New Issue
Block a user