Senior Java Developer Interview Question Series's

Senior Java Developer Interview Question Series's

Thanks to the original writer:

https://medium.com/@rathod.ajay10

Senior Java Developer Interview Questions Series 1

Java

  1. What is the difference between Hashmap vs hashTable , which one is synchronized?
  2. Difference between Hashmap vs concurrenthashmap and the follow-up question on how they work internally etc.
  3. How hashmap works ?
  4. How to create custom immutable class ?
  5. What are the in built immutable classes in java ?
  6. Difference between Aggregation vs composition ?
  7. How to create immutable map in java on which we can’t modify after adding the data ?
  8. Explain Throw throws throwable ?
  9. What are the new change in java memory model in java 8?
  10. Questions related to static synchronization in java?
  11. How to create?Thread Pool and how to use it in database Connection pool
  12. What is the life cycle of thread and in Thread Pool?
  13. Explain Diamond problem in java how to solve that /
  14. How to create?Create custom class loader in java?
  15. Java 8 Interface changes ?
  16. How to create an Object in java? Explain Different ways to do it ?
  17. How to restrict object creation in java ?


Senior Java Developer Interview Questions Series 2


  1. Scenario, you must create a cache thread pool using executor framework, but you don’t know the capacity or number of threads needed to achieve that task. how will you determine how much threads you will need based on your requirement? is there any mechanism in executor’s framework to know the capacity of it. (if you know the answers please comment below we can discuss a lot)?
  2. In java 8 what all the major changes happened on memory side?
  3. what is the difference between completable future and callable and runnable future?
  4. Program — WAP using stream java 8,

ArrayList ar = Arrays.asList{1,2,3,4,5,6,7,8,9,10}

from the above list you have to find average of even numbers square using java 8

5. what is parallel processing in java 8, what are the uses of it.

Some Microservice related questions

  1. What is SAGA and CQRS microservice design pattern?
  2. how to maintain a session between two microservices?
  3. Write and end point in spring boot for get and save employee with syntax
  4. how to communicate between two microservices (FYI there are three ways to do it make sure you know all three)
  5. Where to save your username password in spring boot based microservices application
  6. How Oauth/JWT works internally, how to make sure your token is not tampered?
  7. what is IDP and SDP?
  8. How to handle exceptions in Spring boot application what are the best practices to do it?
  9. Design rest api for tiny url application, how many end point it requires and based on that there is discussion on it. so, it’s a system design question.
  10. How to restrict the microservices calling the other microservices

let’s say there are A,B,C,D,E services and i want to restrict A to call to C,D,E. how will you do that?

Senior Java Developer Interview Questions Series 3

1. What is singleton design pattern?

That seemed easy right, now you should know how it work

a. How singleton works in term of Spring IOC containers, how it will behave?

b. And how singleton works in Core java or in a class how singleton will work, is it object per class or one object in whole jvm.

the answer is JVM creates and maintain object in terms of singleton pattern not the per class.

2. What are stateless bean in spring? name it and explain it?

3. What does Spring boot auto detect feature?

Now I have practical question that you should know in, order to know that you have really worked in java development

4. how to parse json to hashmap?

Ans = Use json library and use object mappers read values method to do that.

5. WAP to find duplicates in an array list?

6. Print Array list in descending order?

7. You should know how implement cache in java for eg. read about LRU cache implementation and which data structure is good for cache

8. One question Regarding JDBC which is quite old one but good to know

what does JDBC forName() method does for you when you connect to any DB?

9. How parse XML file with json in java?

10. Can we insert Null in Concurrent Hashmap?

11. How to create custom hashmap of size 2GB?

12. Can we insert null key in hashamp and hashtable?

you should know the collection framework in and out.

Also, for experienced java developer, Spring framework is must one.

Senior Java Developer Interview Question Series 4 (Fintech Company specific)

  1. What is Spring bean lifecycle?


Its difficult to memorize above lifecycle flow, just remember how bean is initialized.

2. So follow-up question would be type bean scopes and what are prototype and request bean scopes?

3.?How would you call a methods before starting/loading an Spring boot applications ?

4. What is the Difference between @Component and @Service @respository @Controller annotations.

5. What exactly @SpringbootApplication annotation does?

6. How to build a restful webservice which is can fetch 1gb of data from database and send back without using Pagination, so question is if you have big size response how would you send back from a rest webservice?

7. How would you design a binary tree kind of data structure into database design, basically the interviewer wants to know how you would design a database in hierarchical way

Ans — Very good link to try and understand challenges and solution

SQL — How to store and navigate hierarchies?

I’ve got to disagree with Josh. What happens if you’re using a huge hierarchical structure like a company organization…stackoverflow.com

8. How would you store millions of records in a table? How many tables it requires, any database pattern can you use here?

9. Tell me about Pros and cons of microservice architecture why we need that (justify what problem microservice architecture solves)

10. Tell me about Microservice patterns? (Recently people started asking about this, it must know some of them with examples).

Very good link to explore the patterns

Microservices Pattern: Microservice Architecture pattern

You are developing a server-side enterprise application. It must support a variety of different clients including…microservices.io

12. follow-up question, which design pattern you have used and why?

I have been asked regarding read heavy and write heavy application, what pattern you can go for. I told them CQRS which is command query.

for database mostly SAGA pattern is used.

13. what is circuit breaker pattern have you used it?

Refer this →

Microservices Pattern: Circuit Breaker

You have applied the Microservice architecture. Services sometimes collaborate when handling requests. When one service…microservices.io

Usually, we want to stop any error cascading to other component in microservice, to stop that we usually use circuit breakers.

Hystrix library from Netflix is very good library to use it in application.

14. How to call methods Asynchronously, in spring framework how can we do that?

FYI, you can use @Async annotation with executors to achieve that.

15. How to call other microservice asynchronously?

16. How to handle exception in spring framework? (using @ControlAdvice annotation)

17. How to break singleton design pattern? and what can we do to stop that?

18. In a database there is index, what is the datatype of index.

I hope you are getting good insights from the actual interview questions.

Senior Java developer Interview series 5 Questions (Core Java 8, Spring)

Object oriented Programming :

What is Method Overriding ?

Can we override static method ? Why Cant we do that?

Static methods cannot be overridden?because they are not dispatched on the object instance at runtime. The compiler decides which method gets called. Overloading is also called static binding, so as soon as the word static is used it means a static method cannot show run-time polymorphism.


Very good link to it, please refer that.

Can You Override Static Method in Java? Method Hiding Example

Can we override the static method in Java? This is one of the most popular Java interview questions. The answer to this…

www.java67.com


What is the use of static keyword in java ??(too basic right ?)

It means we’ll create only one instance of that static member that is shared across all instances of the class.


follow this link to better understand the concept.

https://www.baeldung.com/java-static#:~:text=In%20the%20Java%20programming%20language,all%20instances%20of%20the%20class.

What is Covariant type?

Do it yourself


Memory Management in Java:

Explain the memory management in java?


So, in java you don’t have to worry about the memory management like CPP, It good to know who this works in java. Especially after java 8 changes where there is major updates regarding to it.

In java 8, Permgen is replaced by Metaspace, we should be able to answer what advantage it offers.

What is MetaSpace in java 8 memory? what benefits it offers?

Basically, up till java 7, JVM stores all the static content in this memory section. This includes all the static methods, primitive variables, and references to the static objects.


Furthermore,?it contains data about bytecode, names, and JIT information. Before Java 7, the String Pool was also part of this memory. this was leading to?OutOfMemoryError?in java to reduce that Oracle removed permgen and added?MetaSpace which grows automatically and reduces?generating the famous?OutOfMemoryError.

JAVA-8 related Questions:

What is Functional interface in java 8 ?

Any interface which is having single abstract can be called as Functional Interface.


Examples:

interface FileFilter { boolean accept(File x); } interface ActionListener { void actionPerformed(…); } interface Callable { T call(); }

Types of Functional interface?

Some programming related question around Java 8.

What are the Intermediate and terminal operation in java 8?


· filter()

· map()

· flatMap()

· distinct()

· sorted()

· peek()

· limit()

· skip()

What is the terminal operation in java?

Java Streams Terminal Operations such as?AnyMatch, Collectors, Count, FindAny, FindFirst, Min, Max, NoneMatch, and AllMatch.


Write a Program find the duplicates in an array using stream api?

int[] arr = {1,2,3,5,5,6,6,5} print only duplicates using stream operations?


class Test{

    public static <T> Set<T>
    findDuplicateInStream(Stream<T> stream)
    {

        // Set to store the duplicate elements
        Set<T> items = new HashSet<>();

        // Return the set of duplicate elements
        return stream

                // Set.add() returns false
                // if the element was
                // already present in the set.
                // Hence filter such elements
                .filter(n -> !items.add(n))

                // Collect duplicate elements
                // in the set
                .collect(Collectors.toSet());
    }

    // Driver code
    public static void main(String[] args)
    {

        // Initial stream
        Stream<Integer> stream
                = Stream.of(5, 13, 4,
                21, 13, 27,
                2, 59, 59, 34);

        // Print the found duplicate elements
        System.out.println(
                findDuplicateInStream(stream));
    }
}        

Find the missing number in an Array?

example: int[] arr = {1,2,3,5,6} you need to find 4 that is missing in this.


Program to Find possible combination of given string “GOD” ?

do it yourself


Spring/Spring boot:

What is Spring bean lifecycle? (Really hate this question coz I don’t remember this big cycle at all)

A Spring bean needs to be instantiated when the container starts, based on Java or XML bean definition. The framework may also be required to perform some pre- and post-initialization steps to get the bean into a usable state.


After that, when the bean is no longer required, it will be removed from the IoC container. Like the initialization phase, the Spring framework may need to perform pre-and post-destruction steps to free the other system resources.

No alt text provided for this image

Difference Between BeanFactory and ApplicationContext ?

please use below link


https://www.baeldung.com/spring-beanfactory-vs-applicationcontext

What are the types of dependency injection and what benefit we are getting using that?

What is @ResponseBody Annotations?


What is horizontal scaling how to achieve that?

What is the difference between container and virtual machine?

What is Builder Design pattern?

Wonderful,very helpful and relevent Thanks for sharing!!!

回复
Fazal Haroon

Full Stack Software Developer | ERP | Java, Spring Boot, Angular, TypeScript, Ionic, SQL, Jasper Reports

1 年

Nice

回复

Thanks for sharing this.

回复
Abdul Manan Soomro

Java Engineer with a focus on Spring Boot, Microservices and Docker/Kubernetes

2 年
回复

要查看或添加评论,请登录

社区洞察

其他会员也浏览了