August 2019 - CodeByAkram
undefined 201

What do you mean by Aspect, Join Point, Advice?

What’s the difference between @Component, @Controller, @Repository & @Service annotations in Spring? Pointcut: Pointcut are expressions that is matched with join points to determine whether advice needs to be executed or not. Pointcut uses different kinds of expressions that are matched with the join points...
undefined 201

What’s the difference between @Component, @Controller, @Repository & @Service annotations in Spring?

Spring 2.5 introduces further stereotype annotations: @Component, @Service, and @Controller. @Component is a generic stereotype for any Spring-managed component. @Repository, @Service, and @Controller are specializations of @Component for more specific use cases,...
undefined 201

Differentiate between constructor injection and setter injection

Partial Dependency In Setter Injection, partial dependency is possible, means if we have 4 dependencies as mentioned below, Then it is not necessary to inject all values if we are using setter injection. But in Constructor Injection, partial dependency is not possible because we are calling the constructor of that...
undefined 201

Java 8 Lambda Comparator

Lets se how we can sort the object by using java 8 lambda comparator. For this let take a Employee class. public class Employee { private String name; private int salary; // standard constructors, getters/setters, equals and hashcode } 1. Classic sort (without lambda) Comparator< Employee...
undefined 201

How to get keys and values from Map in Java?

As we know, map is based on key-value pair associations, so interviewer can ask you this question if you are a beginner or having less than 3 years of experience. So lets see how we can the key and values from a Map? In Java we have and Map.Entry method that returns a collection-view of map. Map< string string="">...
undefined 201

How to set connection timeout for RestTemplate in spring?

We can set the timeout for RestTemplate by doing some custom configuration for RestTemplate. First you need to create a class named as HttpClientConfig in this class we configure HttpClient because RestTemplate internally uses the HttpClient. package com.codebyakram; import org.apache.http.client.config.RequestConfig; import...
undefined 201

How to Sort a Stack using Merge Sort?

Interviewer may ask you this question if you have more than 3 years of experience in java development. So lets have a look, how to sort a stack using merge sort? Lets see sample input and output for better understanding: Algorithm For this we will follow these below two steps, 1. Break the stack into two parts...
Page 1 of 61236Next