Blog Archives

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 FAQs Free, Multithreading, What is wrong with this code?
Tags: ,

06: ♥♦ HashMap & HashSet and how do they internally work? What is a hashing function?

HashMap & HashSet are not only one of the frequently used data structures, but also one of the popular interview topics. Q1. How does a HashMap store data? A1. As key/value pairs. You can store and retrieve values with the keys. Q2. What is the HashMap lookup time in Big

Read more ›

Posted in Collection and Data structures, FAQs Free, Objects, Understanding Core Java
Tags: ,

05: ♥ Overloaded methods Vs Generic methods in Java with JD-GUI & javap to look under the covers

In an earlier post we looked at Understanding Overriding, Hiding, and Overloading in Java?. We also discussed how “method overriding” gives polymorphism. In this post, let’s see how a “generic method” can replace a number of overloaded methods. Then see under the hood as to what happens to the compiled

Read more ›

Posted in Generics
Tags:

04: Identifying and fixing LazyInitializationException in Hibernate

LazyInitializationException is thrown when an object becomes detached, and if you try to access associated (i.e. proxied) object(s) of a detached object. Q. What is a detached object in Hibernate? When you close an individual Hibernate Session, the persistent objects you are working with are detached. This means the object

Read more ›

Posted in Hibernate, Java Debugging
Tags:

03: Identifying and fixing NonUniqueObjectException in Hibernate

NonUniqueObjectException is thrown when there is an object already associated with the session with the same id (primary key) (i.e. a duplicate). It is important to understand the concept of a “detached” object in Hibernate. This is one of the most common errors, understanding why and when this error is

Read more ›

Posted in Hibernate, Java Debugging
Tags:

07: ♥ Java Iterable Vs Iterator differences and know how

Q1. What are the differences between Iterator<T> Vs Iterable<T>? A1. The “Iterable” was introduced to be able to use in the “foreach” loop. A class implementing the Iterable interface can be iterated over. For example,

Hence, it can be used in the foreach loop

The Iterable interface has

Read more ›

Posted in Collection and Data structures, Differences Between X & Y
Tags:

06: ♥ Java 8 way of File reading and functionally processing the data

Output:

#1 double colon notation :: The new double colon (::) operator that Java 8 has to convert a normal method into lambda expression. So, Instead of:

You can do:

#2 Why is stream::iterator used? “lines::iterator” where iterator() is an instance method on “BaseStream<T,Stream<T>>” from which

Read more ›

Posted in IO, Java 8
Tags:

03: ♥♦ Java autoboxing & unboxing benefits & caveats interview Q&As

Q1. What do you understand by the terms “autoboxing” and “autounboxing” in Java? A1. Java automatically converts a primitive type like “int” into corresponding wrapper object class Integer. This is known as the autoboxing. When it converts a wrapper object class Integer back to its primitive type “int”, it is

Read more ›

Posted in Data types, FAQs Free, Understanding Core Java
Tags: ,
Page 1 of 6123456

800+ Java Interview Q&As – ♥ Free | ♦ FAQs

open all | close all

Pressed for time? 200+ Quick Prep

open all | close all

16 Java Key Areas to be a top-notch

open all | close all

100+ Java Tutorials – Step by step

open all | close all

100+ Java Coding Exercises

open all | close all

How good are your

open all | close all