Blog Archives

09: What is wrong with this code? ConcurrentHashMap & Atomic operations

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, but actually the output will be as shown below missing counts. Output with missing counts

Why does the output miss counts? This is…...

Members Only Content

This content is for the members with any one of the following paid subscriptions:

30-Day-Java-JEE-Career-Training, 90-Day-Java-JEE-Career-Training, 180-Day-Java-JEE-Career-Training, 365-Day-Java-JEE-Career-Training, 60-Day-Java-JEE-Career-Training and 2-Year-Java-JEE-Career-Training

Want to evaluate the quality of the contents to see if they will add value to you?

Click Here and check the contents with Try.

Log In | Register
Posted in member-paid, What is wrong with this code?

02: ♥♦ What is wrong with this code? Heap Vs Stack, Thread safety & Synchronized

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. Java interviewers may ask you to detect thread-safety issues as discussed in “What is wrong with this code?“. 1.What is

Read more ›

Posted in Multithreading, What is wrong with this code?
Tags: ,

07: What is wrong with this code? Multithreading & locks

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? If there is something wrong, how will you go about fixing it?

A. 1. Explanation a. The main thread gets implicitly created by…...

Members Only Content

This content is for the members with any one of the following paid subscriptions:

30-Day-Java-JEE-Career-Training, 90-Day-Java-JEE-Career-Training, 180-Day-Java-JEE-Career-Training, 365-Day-Java-JEE-Career-Training, 60-Day-Java-JEE-Career-Training and 2-Year-Java-JEE-Career-Training

Want to evaluate the quality of the contents to see if they will add value to you?

Click Here and check the contents with Try.

Log In | Register
Posted in member-paid, What is wrong with this code?

05: What is wrong with this code? Deep Vs Shallow comparison & multithreading

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, they will never be the same, and nothing will be printed. This is also known as the “shallow” comparison. To fix it:…...

Members Only Content

This content is for the members with any one of the following paid subscriptions:

30-Day-Java-JEE-Career-Training, 90-Day-Java-JEE-Career-Training, 180-Day-Java-JEE-Career-Training, 365-Day-Java-JEE-Career-Training, 60-Day-Java-JEE-Career-Training and 2-Year-Java-JEE-Career-Training

Want to evaluate the quality of the contents to see if they will add value to you?

Click Here and check the contents with Try.

Log In | Register
Posted in member-paid, What is wrong with this code?

04: What is wrong with this code? Java Collection & ConcurrentModificationException

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.concurrent classes like CopyOnWriteArrayList

Output:

Where can we use collection.remove() Collection.remove( ) is very useful.…...

Members Only Content

This content is for the members with any one of the following paid subscriptions:

30-Day-Java-JEE-Career-Training, 90-Day-Java-JEE-Career-Training, 180-Day-Java-JEE-Career-Training, 365-Day-Java-JEE-Career-Training, 60-Day-Java-JEE-Career-Training and 2-Year-Java-JEE-Career-Training

Want to evaluate the quality of the contents to see if they will add value to you?

Click Here and check the contents with Try.

Log In | Register
Posted in member-paid, What is wrong with this code?

03: What is wrong with this code? Data types & equals( ) Vs, hashCode( ) contract

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. Comparing for “>” or “...

Members Only Content

This content is for the members with any one of the following paid subscriptions:

30-Day-Java-JEE-Career-Training, 90-Day-Java-JEE-Career-Training, 180-Day-Java-JEE-Career-Training, 365-Day-Java-JEE-Career-Training, 60-Day-Java-JEE-Career-Training and 2-Year-Java-JEE-Career-Training

Want to evaluate the quality of the contents to see if they will add value to you?

Click Here and check the contents with Try.

Log In | Register
Posted in member-paid, What is wrong with this code?

01: ♥ What is wrong with this code? Auto-unboxing, switch, short circuit & exception

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. What is wrong with this code?

A1. compile-error at switch(i) as switch works only with “int” and “String” (i.e.

Read more ›

Posted in What is wrong with this code?

08: What is wrong with this code? Generics

Q. Can you review the following code and see if it has any issues?

A. The “MyStack” class is not properly using “generics”. It only works with “String” class. Here is the revised solution using generics to work with any object type.

The above example shows that “MyStack”…...

Members Only Content

This content is for the members with any one of the following paid subscriptions:

30-Day-Java-JEE-Career-Training, 90-Day-Java-JEE-Career-Training, 180-Day-Java-JEE-Career-Training, 365-Day-Java-JEE-Career-Training, 60-Day-Java-JEE-Career-Training and 2-Year-Java-JEE-Career-Training

Want to evaluate the quality of the contents to see if they will add value to you?

Click Here and check the contents with Try.

Log In | Register
Posted in member-paid, What is wrong with this code?
Page 1 of 212

800+ Interview Q&As ♥Free|♦FAQ (Mouse Hover for Full Text)

open all | close all

200+ Java FAQs – Memory Joggers

open all | close all

16 Java Key Areas to be a top-notch

open all | close all

80+ Java Tutorials – Step by step

open all | close all

100+ Java Coding Exercises

open all | close all

How good are your "Career Skills"?

open all | close all