Auto-unboxing, switch, short circuit logical operators & exception handling are core Java basics that sometimes lead to obscure errors if not understood well & often tested in coding tests.
Q1.
…
Auto-unboxing, switch, short circuit logical operators & exception handling are core Java basics that sometimes lead to obscure errors if not understood well & often tested in coding tests.
Q1.
…
Q6. What is wring with this code?
A6. Infinite loop at due to sum != 1.0. Using floating point variables like float or double in loops to compare for equality can lead to infinite loops.
…
Q9. What is wring with this code? A9. throws a Runtime exception called “java.util.ConcurrentModificationException” The output will be: Fix 1: Use iterator.remove() instead of collection.remove Output: Fix 2: Use java.util.…...
Q10 What is wring with this code? A10. date1 == date2 only compares the references and not the actual dates. Since both the references are different objects, … Read more...
An excellent written test question to assess your Java multi-threading knowledge. Please practice it by doing it yourself.
Q. Review the code shown below and then answer the following questions.…
Q. What is wrong with the following Java code? Explain what does the following code do? Explain if there is anything wrong with the following code? … Read more ›...
Q. Can you review the following code and see if it has any issues? A. The “MyStack” class is not properly using “generics”. … Read more ›...
Q. What is wrong with the following code snippet? A. It is NOT thread-safe as a “HashMap” is not thread-safe as per the Java API, … Read more ›...
Q. What output is expected from the following code? What does it actually output? A. It is expected to output counts from 100,001 to 100,010, … Read more ›...
This post covers must know Java Multithreading basics – Heap Vs Stack, Thread-safety & Synchronization. When you have a multithreaded Java application, you need to code in a thread-safe manner.
…