Understanding Daemon Threads and Non-Daemon Threads in Java

In Java’s multithreaded environment, threads can be categorized as either daemon threads or non-daemon threads. The word “daemon” comes from Greek mythology, where daemons were spiritual beings that performed services for others. In the context of Java threads, daemon threads are low-priority threads that are intended to serve and support non-daemon threads. What are Daemon […]

Adapter design pattern

The Adapter design pattern is a structural pattern that allows objects with incompatible interfaces to work together. It acts as a bridge between two incompatible interfaces by creating a class that wraps one interface and exposes another interface that the client expects. Here’s a practical example in Java: Suppose we have a third-party library that […]

Breaking Singleton in Java and How to Prevent It

1. Reflection Reflection: Reflection API can be used to change the access level of the constructor from private to public, and then instantiate the class as many times as desired. Breaking Singleton In the above code, instanceOne and instanceTwo are different instances of the Singleton class, breaking the Singleton pattern. To prevent breaking singleton through […]

Interview at Synechron

Question: You are given a String that contains alphanumeric characters (letters and digits) as well as special characters like !, @, #, and whitespaces. The task is to count the occurrences of only the special characters present in the String, ignoring the letters, digits. Answer: Question: What are the multiple ways in which we can break […]

Securing Database Credentials with AWS Secrets Manager in a Spring Boot Application

Introduction In modern application development, handling sensitive information like database credentials securely is of utmost importance. Hardcoding these credentials in your application code or configuration files is a serious security risk, as they can be easily exposed or accidentally committed to version control systems. AWS Secrets Manager provides a secure and scalable solution for managing […]

Interview At Altimetrik

Question: You are given list {1, 2, 3, 4, 5, 6, 7, 8, 9} you need to rotate by 3 Question: We have a database transactions, right? Every application usually have a database transactions, when it is interacting with the database. So, can you discuss about database transaction with respect to distributed services? Answer: Sure, […]

Understanding equals() and hashCode() in Java

Introduction In Java, equals() and hashCode() are two fundamental methods present in the Object class which are used for comparing object equality and for use in collections, respectively. It’s a common practice to override these methods in your own classes, especially if you want to compare object equality based on their logical state rather than their identity. The equals() Method The […]

Understanding Concurrency in Java

Concurrency is a crucial concept in modern programming, especially in a language like Java. It allows multiple parts of a program to execute simultaneously, potentially leading to more efficient use of resources and improved performance. The Importance of Synchronization In multithreaded programming, synchronization is a mechanism that ensures that two or more concurrent threads do […]

Understanding Abstract Class and Anonymous Class in Java

Java, as an object-oriented programming language, provides several powerful features, two of which are abstract classes and anonymous classes. In this blog post, we will delve into these concepts and understand how they work together. Abstract Classes In Java, an abstract class is a class that cannot be instantiated directly. It often contains one or […]