Wednesday, 29 May 2019

What is a Functional interface in Java 8? What does @Functional annotation do?

What is Functional interface in Java 8

Well, a functional interface is nothing but an interface with just one abstract method e.g. Comparable, Runnable, EventListener, Comparator, etc. You can see these interfaces were present in Java even before JDK 8, but why do we call such interface functional interface?

Tuesday, 14 May 2019

Explain Function Overloading and Method Overloading in Java

When in a class, we have more then one method with similar name but with different type signatures i.e. with different number of parameters or with different types of parameters, then we say that the method is overloaded. Compiler will recognize which method to execute on the basis of the type and

What is Abstraction in Java? Abstract Class or Interface

Abstraction in Java: The words "data abstraction" and "information hiding" are generally used interchangeably. The two terms mean the same thing in this context. Abstraction is a simple representation of a complicated situation. It is a technique where we hide irrelevant details and represent only the essential aspects of a context so that one can focus on features one is interested; It helps to deal a complex system by concentrating on the essential features only. It is designed to make

Explain Association, Composition and Aggregation in Java

Association is nothing more than  a connection that exists between two classes.  We use the objects of these classes to set up the connection. Association can be  done in three ways one-to-one, one-to-many and many-to-many. Let’s have a look at an example showing how association is implemented in Java.

Sunday, 12 May 2019

Can you explain how Strings are interned in Java?

String class is designed with the Flyweight design pattern in mind. Flyweight is all about re-usability without having to create too many objects in memory.

Q1. What is the difference between “==” and “equals(…)” in comparing Java String objects?

When you use “==” (i.e. shallow comparison), you are actually comparing the two object references to see if they point to the same object. When you use “equals(…)”, which is a “deep comparison” that

Sunday, 5 May 2019

Spring Annotations [ Quick Reference ]

@Import Annotation in Spring Framework

@Import is the one such annotation used for consolidating all the configurations defined in various configuration files using @Configuration annotation. It is much similar to how we import the different XML configuration files to a single file. @Import annotation will used for the same purpose. This tutorial explains how to use @Import for Importing JavaConfig Files in Spring Projects.

How To Load Properties File using @Value Annotation

This example shows how to load the properties file values using the @Value annotation. Accessing the property file values in the Spring application involves the following steps:

Add the property file details to spring bean configuration file. You have to use the “classpath” prefix if you want to load the files from the classpath.

Saturday, 4 May 2019

Explain @RequestMapping Annotation in Spring MVC

@RequestMapping annotation is used for mapping web requests to particular handler classes or handler methods. The classes or methods that are annotated with @RequestMapping will be scanned and registered as the URI mappings for that specific class or method. Any future web requests will be redirected to that class or method. This annotation is part of Spring MVC module.

Spring Boot @ConfigurationProperties and Properties File

 In this tutorial, you will learn to use @ConfigurationProperties to map properties files to POJO classes in Spring Boot application. Let’s ...