Posts

Topics to Prepare for Java Interview

Companies looking for Java developers who have experience in following topics 1. Core Java 2. Java 8 3. Multithreading (must) 4. Spring 5. Spring Boot (Micro Services) 6. Hibernate 7. XML 8. Concurrency 9. Algorithms 10. Data structures 11. Design patterns 12. Object-Oriented Design 13. Architecture patterns 14. MVC Design 15. RESTful web services 16. Maven 17. MongoDB 18. Git 19. JUnit & Mockito 20. System Design Links to refer: Design patterns https://www.youtube.com/watch?v=EYOKqb2Mf7k&list=PLmCsXDGbJHdjZiLC2HjXrgw8-E4O3MXdN Singleton Implement Singleton using Eager Initialisation Implement Singleton using Lazy Initialisation What is the Double-Checked Locking? When Double-Checked Locking fails? How can you fix Double-Checked Locking fail? Ans: use Volatile Factory  Abstract Factory - Factory of Factories Spring Spring core Spring transactions Spring JDBC Spring MVC CoreJava & Java8 OOP...

What is Group Id && Artifact Id in a maven project

Image
Artifact is a file, usually a jar. So Artifact Id is the name of the jar. Each artifact id has a group ID (usually a reversed domain name like com.example.foo) for example, in the below dependencies, you can observer that, all artifacts are belong to same groupId. Here groupId is org.slf4j & artifacts have different ids.

Different ways to create an object In Java

Below are the different ways to create an object in java. 1. using new keyword 2. using newInstance() method of class Class 3. using newInstance() method of class Constructor 4. using clone() method 5. using deserialization Using new keyword: 1. Employee emp = new Employee(); Using newInstance() method of class Class: 1. Employee emp2 = Class.forName("Employee").newInstance(); 2. Employee emp3 = Employee.class.newInstance(); Using newInstance() method of class Constructor: 1. Constructor empConstructor = Employee.class.getConstructor();  Employee emp4 = empConstructor.newInstance() Using clone() method: 1. Calling clone() method, actually creates a new object and copies all the contents of old object into it. Creating an object using clone method doesn't invoke any constructor. 2. To use clone() method on an object, we need to implement Cloneable interface and define clone() method in it. Employee emp5 = (Employee) emp4.clone(); Using...

ConcurrentHashMap in Java

ConcurrentHashMap is concrete implementation of ConcurrentMap. Both are from java.util.concurrent package. Functionality: 1. The functionality is similar to normal HashMap with better concurrency. 2. ConcurrentHashMap is thread safe. 3. It doesn't lock the Map while you are reading from it. 4. It doesn't lock the entire Map when writing to it, it only locks the part of the Map that is being written to, internally. Difference between HahsMap && ConcurrentHashMap: HashMap ConcurrentHashMap Not Thread Safe Thread Safe Allows 1 null Key Will Not allow NULL Values