Java Interview Questions – Part 1

Collections API Which data structure is used when you have lots of add and remote operations? What is time complexity? LinkedList. The insertion, addition and removal operations of an item are faster in a┬áLinkedList┬ábecause there is no need to resize an array or update the index when an element is added to some arbitrary position […]

Authentication and Authorization Flow in Spring Security

Introduction Spring Security is a framework that provides authentication, authorization, and protection against common attacks. It is the de-facto standard for securing Spring-based applications and supports securing both imperative (servlet) and reactive applications. In this post, we are going to discuss the main actors in the Spring Security architecture that take part in the process […]

Singleton Design Pattern For Interviews

Introduction Singleton is a popular topic that you will encounter at least once during your job search. This short tutorial describes three approaches to implement a singleton class. Singleton Pattern A singleton is simply a class that is instantiated exactly once. We want a single instance of a particular object in the memory. The common […]

If/Else Cumleleri Icin Rule Tasarim Kalibi

Bugun, projemizde kullandigimiz Rule tasarim kalibi (Rule Design Pattern) anlatacagim. Bu yontemi zaman baskisi yuzunden ekibe kabul ettirmek zor oldu ama ortaya cikan sonuctan memnun kaldik. Umarim sizin de isinize yarar. Problem Spring Boot ile yazilan backend uygulamamizda farkli musteri tipleri icin farkli kurallarin uygulandigi bir fonksiyon vardi. Musteri tiplerine gore onyuze farkli bildirim mesajlarini […]

Factory Method Pattern for Spring Hateoas Links

Problem Description You have a single class in your application where you create Hateoas Links for different API versions (e.g.: V1 and V2). The class grows quickly with time as you add a lot of logic for those versions. You want to refactor the existing class so that it is easier to be modified for […]

Testing HTTP Methods using Mockito framework

In this post, you will learn how to create HTTP methods in Spring Boot and test them using the Mockito framework. If you are not familiar with unit testing, see my post on Medium. For those who are impatient, you can find the source code on GitHub. HTTP Verbs Overview The most-commonly-used HTTP verbs are […]

Java SE 8/11 Programmer II Exam Series: Concurrency (Part 1)

Introduction This post is currently in progress… In this post, we will look at the exam objective; create worker threads using Runnable, Callable, and use an ExecutorService to concurrently execute tasks. Note that this is also a part of the Java SE 11 Programmer II Certification. Runnable Interface Runnable interface Usages of Runnable interface Creating a […]

Java SE 8/11 Programmer II Exam Series: Exception Handling and Assertions

Introduction In this post, we will look at the following exam objectives. Note that this is also a part of the Java SE 11 Programmer II Certification. Use the try-with-resources construct Create and use custom exception classes Test invariants by using assertions Use the try-with-resources construct The new try-with-resources statement automatically closes all resources opened […]

Java SE 8/11 Programmer II Exam Series: Internationalization and Localization

Introduction In this post, we will look at how to add internationalization and localization to the Java application. We will learn how to pick a locale, create and use properties files in different languages, and to format the numbers. Note that the localization is also a part of the Java SE 11 Programmer II Certification. […]

Java SE 8/11 Programmer II Exam Series: Advanced Stream Pipeline Concepts

Introduction In this section, we will cover advanced stream pipeline concepts in Java 8. We will analyze chaining Optionals, predefined collectors, and learn how to use groupingBy, partitioningBy, and mapping methods. Chaining Optionals Chaining optionals help eliminate the nested if-statements for Optional variables. The function below prints the virus name if it contains Covid-19 without […]