❌ A. LinkedHashMap: {B=5, A=2, C=1, E=3, D=4}; TreeMap: {B=5, D=4, E=3, A=2, C=1} ❌ B. LinkedHashMap: {B=5, A=2, C=1, D=4, E=3}; TreeMap: {B=5, A=2, C=1, D=4, E=3} ❌ C. LinkedHashMap: {A=2, B=5, C=1, D=4, E=3}; TreeMap: {C=1, A=2, E=3, D=4, B=5} ✅ D. LinkedHashMap: {A=2, B=5, C=1, D=4, E=3}; TreeMap: {B=5, D=4, E=3, A=2, C=1} ❌ E. Error ❌ F. None of the above
Explanation: 1. LinkedHashMap Behavior: • LinkedHashMap maintains the insertion order of elements. • Here, linkedHashMap will display entries in the exact order they were inserted: {A=2, B=5, C=1, D=4, E=3}.
2. TreeMap with Custom Comparator: • TreeMap typically orders entries based on the natural order of keys, but here it uses a custom comparator to sort entries in descending order based on values from linkedHashMap. • Comparator.comparingInt(linkedHashMap::get).reversed() sorts treeMap by values in descending order, resulting in {B=5, D=4, E=3, A=2, C=1}.
3. Expected Output: • The LinkedHashMap output maintains the insertion order. • The TreeMap output shows entries sorted by values in descending order based on linkedHashMap values.
❌ A. LinkedHashMap: {B=5, A=2, C=1, E=3, D=4}; TreeMap: {B=5, D=4, E=3, A=2, C=1} ❌ B. LinkedHashMap: {B=5, A=2, C=1, D=4, E=3}; TreeMap: {B=5, A=2, C=1, D=4, E=3} ❌ C. LinkedHashMap: {A=2, B=5, C=1, D=4, E=3}; TreeMap: {C=1, A=2, E=3, D=4, B=5} ✅ D. LinkedHashMap: {A=2, B=5, C=1, D=4, E=3}; TreeMap: {B=5, D=4, E=3, A=2, C=1} ❌ E. Error ❌ F. None of the above
Explanation: 1. LinkedHashMap Behavior: • LinkedHashMap maintains the insertion order of elements. • Here, linkedHashMap will display entries in the exact order they were inserted: {A=2, B=5, C=1, D=4, E=3}.
2. TreeMap with Custom Comparator: • TreeMap typically orders entries based on the natural order of keys, but here it uses a custom comparator to sort entries in descending order based on values from linkedHashMap. • Comparator.comparingInt(linkedHashMap::get).reversed() sorts treeMap by values in descending order, resulting in {B=5, D=4, E=3, A=2, C=1}.
3. Expected Output: • The LinkedHashMap output maintains the insertion order. • The TreeMap output shows entries sorted by values in descending order based on linkedHashMap values.
Correct Answer: D
BY Explanations “Top Java Quiz Questions”
Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283
A leaked Telegram discussion by 50 so-called crypto influencers has exposed the extraordinary steps they take in order to profit on the back off unsuspecting defi investors. According to a leaked screenshot of the chat, an elaborate plan to defraud defi investors using the worthless “$Few” tokens had been hatched. $Few tokens would be airdropped to some of the influencers who in turn promoted these to unsuspecting followers on Twitter.
Telegram hopes to raise $1bn with a convertible bond private placement
The super secure UAE-based Telegram messenger service, developed by Russian-born software icon Pavel Durov, is looking to raise $1bn through a bond placement to a limited number of investors from Russia, Europe, Asia and the Middle East, the Kommersant daily reported citing unnamed sources on February 18, 2021.The issue reportedly comprises exchange bonds that could be converted into equity in the messaging service that is currently 100% owned by Durov and his brother Nikolai.Kommersant reports that the price of the conversion would be at a 10% discount to a potential IPO should it happen within five years.The minimum bond placement is said to be set at $50mn, but could be lowered to $10mn. Five-year bonds could carry an annual coupon of 7-8%.