CodeGym /Courses /Java Multithreading /Interview prep | Level 2

Interview prep | Level 2

Java Multithreading
Level 2 , Lesson 17
Available

"I almost forgot. Here are some potential interview questions that we covered in this level:"

Interview questions
1 What's the right way to compare two strings in Java?
2 What's the right way to perform a case-insensitive comparison of two strings in Java?
3 How do you sort a list of strings alphabetically?
4 What encoding is used to store strings in Java?
5 How do you convert a string to the Windows-1251 encoding?
6 How do you split a string into individual words?
7 How do you reverse the order of a string?
8 What happens when we write "A"+"b"+"C"?
9 What are mutable and immutable types?
10 What advantages does String have because it is immutable?
Comments (4)
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION
Ibrahim Level 24, Sheffield, United Kingdom
28 January 2022
1. Using the equals() method which is overridden for you when comparing strings. It compares each character and returns a Boolean value. 2. Using the equalsIgnoreCase() method. 3. Use Collections.sort(), using compareTo(), use Treeset, implementing Comparator. 4. UTF-8 5. String s = "Hello World"; byte[] b = s.getBytes(encoding); 6. Using split() or StringTokenizer and a delimeter. 7. Convert to StringBuilder and reverse(), use toCharArray() and compare each character. 8. String concatenation, it will merge into one string. The result will be "AbC". 9. Mutable types can be changed without returning a new value. Immutable types cannot be changed, therefore when modifying them you are essentially making a copy of them, changing the copy and returning the copy. 10.Immutable objects are much easier to implement than mutable objects. Immutable objects can be freely used across multiple threads simultaneously.
way milky Level 29, Singapore
9 April 2021
can anyone give the answers?
Andrei Level 41
1 April 2021
If you haven't by now, I suggest creating an anki deck with java questions that you revise on a regular basis.
MaGaby2280 Level 41, Guatemala City, Guatemala
30 June 2020
This questions are really helpful to review the topics