Blog Archives

00: Top 50+ Core Java interview questions answered – Q11 to Q23

The focus is on Java OOP interview questions and answers. Q11. What is the difference between constructors and other regular methods? A11. Constructors must have the same name as the class name and cannot return a value. The constructors are called only once per creation of an object while regular…

Read more ...
Tags: , , ,

00: Top 50+ Core Java interview questions answered – Q24 to Q36

Focus is on Java classes, interfaces and generics the interview questions and answers style. Java classes and interfaces are the building blocks. Q24. What happens when a parent and a child class have the same variable name? A24. When both a parent class and its subclass have a field with…

Read more ...
Tags: , , , ,

00: Top 50+ Core Java interview questions answered – Q37 to Q42

As a Java developer, you may not need to know how the JVM works, but the most important topic that you must know is Java Garbage Collection. How the Garbage Collection and object referencing work in Java. Q37. What do you know about the Java garbage collector? When does the…

Read more ...
Tags: , , , ,

00: Top 50+ Core Java Interview questions answered – Q43 to Q54

Q43. What can you tell about the performance of a HashMap compared to a TreeMap? Which one would you prefer? A43. A balanced tree does have O (log n) performance. The TreeMap class in Java maintains key/value objects in a sorted order by using a red-black tree. A red-black tree…

Read more ...
Tags: , , , ,

02: 9 Java Collection interview Q&As on choosing the right data structure

Choosing the right data structure is vital to get the job done with proper space vs performance trade-offs. Q1. What are the common data structures, and where would you use them? A1. Deterministic Data Structures like Arrays, Lists, Sets, Maps, Trees, and Graphs. Many leave out Trees and Graphs as…

Read more ...
Tags: ,

02: Java 8 Streams, lambdas, intermediate vs terminal ops, and lazy loading with simple examples

A stream is an infinite sequence of consumable elements (i.e a data structure) for the consumption of an operation or iteration. Any Collection<T> can be exposed as a stream. It looks complex, but once you get it, it is very simple. The operations you perform on a stream can either…

Read more ...
Tags:

03: 12 Java Generics interview Q&As

Q1 What do you understand by the term type erasure with regards to generics? A1. The term type erasure is used in Java generics. In the interest of backward compatibility, robustness of generics has been sacrificed through type erasure. Type erasure takes place at compile-time. So, after compiling List and…

Read more ...
Tags: , ,

04: 6 popular Java multithreading interview Q&As for the experienced

Q1. Why do threads need to communicate with each other? A1. Inter thread communication is very similar to inter process communication where 2 or more processes communicate with other, the only difference being that inter thread communication happens within the same process (i.e. within the same memory model). Inter thread…

Read more ...
Tags: ,

05: 9 Java multithreading Q&As on concepts like blocking, sequencing, preempting, time slicing & daemon threads

Java multithreading Q&As on concepts like blocking, and debugging blocked threads. How do you sequence threads? what do you understand by the term preemptive scheduling? Q1. What are the different ways a Java thread gets blocked or suspended? How will you debug Java threading issues? A1. 1. It has been…

Read more ...
Tags: ,

12: 5 Java synchronize & concurrency mgmt scenarios interview Q&As

This extends Q1. Can you give some scenarios where you had used multi-threading in Java applications? Q2. Can you give some scenarios where you used the synchronized keyword in Java? A2. Firstly, you need to assume that your code is always going to be accessed by multiple threads. Scenario 1:…

Read more ...
Tags:

5 Java Object class methods interview questions & answers

Q1. What are the non-final methods in Java Object class, which are meant primarily for extension? A1. The non-final methods are equals( ), hashCode( ), toString( ), clone( ), and finalize( ). These methods are meant to be overridden. The equals( ) and hashCode( ) methods prove to be very…

Read more ...
Tags: , ,

8 Java Annotations interview Questions and Answers

Q1. Are annotations a compile time or run-time feature? A1. You can have either compile-time or run-time annotations. @Override is a simple compile-time annotation to catch little mistakes like typing tostring( ) instead of toString( ) in a subclass.

If you remove the toString( ) method in Class A…

Read more ...
Tags: ,

8 Java immutable objects interview questions & answers

Best Practice: “Classes should be immutable unless there’s a very good reason to make them mutable….If a class cannot be made immutable, limit its mutability as much as possible.” — by Joshua Bloch Q1. What is an immutable object? Q2. Immutable objects are objects whose state (the object’s data) cannot…

Read more ...
Tags: , ,

Java classes and interfaces are the building blocks

Q1. Which class declaration is correct if A and B are classes and C and D are interfaces? a) class Z extends A implements C, D{} b) class Z extends A,B implements D {} c) class Z extends C implements A,B {} d) class Z extends C,D implements B {}…

Read more ...
Tags: , ,

Java serialization, cloning, and casting interview Q&A

Q1. Which Java interface must be implemented by a class whose instances are transported via a Web service? a. Accessible b. BeanInfo c. Remote d. Serializable A1. Answer is “d”. Q2. What is serialization? A2. Object serialization is a process of reading or writing an object. It is a process…

Read more ...
Tags: , ,

Mocks, stubs, domain, and anemic objects interview Q&A

Q1. What are mock objects? A1. Mock objects are used in unit testing to ensure that your tests don’t fail due to volatility of the data changes. There are mocking frameworks like EasyMock, Mockito, and PowerMock. The key point to remember regarding mock objects is the ability of the mock…

Read more ...
Tags: ,

Object equals Vs == and pass by reference Vs value

Q1. What is the difference between “==” and equals(..) method when comparing 2 objects?
A1.It is important to understand the difference between identity (i.e. ==) comparison, which is a shallow comparison that compares only the object references, and the equals( ) comparison, which is a deeper comparison that compares the object attributes.… Read more ...

Tags: , ,

Q1 – Q10 Java OOPs interview Q&As

If you don’t get Java OOPs interview questions & answers right in the job interviews you can say OOPS !!!! to your Java interview success. Q1. Is Java a 100% Object Oriented (OO) language? if yes why? and if no, why not? A1. I would say Java is not 100%…

Read more ...
Tags:

SDLC process interview Q&As

No right or wrong answers. The depth and quality of the answers will can prove your seniority and experience. Q1. What are the SDLC activities you perform as a Java developer? A1. Don’t get overwhelmed by this activities list. This proves why employers favor experience to just academic qualifications alone….

Read more ...
Tags:

500+ Java Interview FAQs

Java & Big Data Tutorials

Top