Java8 Collectors mapping and joining function usages


1.       What is annotation in java? Writing custom annotations and internal working of annotations.

2.       What is Generics in java? Wildcards in generics and writing the custom Generic class (Generic Use)

3.       What are the different collections you have used in your previous projects? Internal working of HashMap, TreeMap and PriorityQueue.

4.       What are Fail-Safe and Fail-Fast mechanism of iterators?

5.       What is volatile and differences between Atomic Classes (AtomicInteger, AtomicDouble) and volatile.

6.       What is Lock interface and its implementation and how lock is different from synchronized keyword.

7.       What are the blocked collections in java?

8.       Differences between Runnable and Callable interface.

9.       What is Future class and its methods?

10.   What are the different Synchronizers in java?

11.   What is ExecutorService FrameWork in java?

12.   What are the different Design Patterns you know? How many you have used in your previous projects?

13.   What is SOLID principles and explain them with the scenario used in previous projects.

14.   Differences between Comparable and Comparator and multi-valued sorting using comparator.

15.   What are the ID Generator in hibernate?

16.   What is recursion? and what will happen if we did not provide the base condition in recursive method?

17.   What is Functional Interface in java 8?

18.   What are static and default method in interface in java 8?

19.   What is Stream API in java 8?

20.   Some basic questions on SpringBoot.

21.   Richerdson Maturity Model in RESTFul web service.

22.   Difference between PUT and POST method in RESTFul.

23.   HATEOAS implementation in RESTful API.

24.   What is the IOC in Spring framework?

25.   What are the different modules you know in Spring?

 


Acccount: State Street

Profile: AL2 (Java)

 

Java 8

  1. Stream API: how to iterate, filter and other methods used in stream API such as map, collect, filter etc.
  2. Functional Interface : is it necessary to use annotation @FunctionalInterface. What happens if we don't use it. What methods we can use in FunctionalInterface.
  3. Lambda Expressions : How to use in different scenarios.

Java Core

  1. Collection Framework: Working of HashMap, ConcurentHashMap, ArrayList vs (Set/LinkedList/Array/Vector), Comparator vs Comparable.  Refer link : http://javahungry.blogspot.com/2015/05/50-java-collections-interview-questions-and-answers.html and https://www.journaldev.com/1330/java-collections-interview-questions-and-answers.
  2. Multithreading: Life Cycle of thread, Different ways to achieve thread safety.
  3. Serialization: internal working of serialization.
  4. Design Pattern: Singleton, Proxy, Factory, Abstract Factory. Which pattern lies in what category like behavioral, creational, structural.

Spring

  1. Bean scopes in spring, Bean lifecycle methods, Dependency Injection, types of dependency injection, setter injection vs constructor injection. when to use which injection type.

Hibernate

  1. how to persist an object in database. 
  2. get() vs load().
  3. save() vs persist().

RDBMS

  1. Joins

 

Refer below links for better Understanding:

https://www.journaldev.com/ (Java and Spring)

http://www.mkyong.com/tutorials/hibernate-tutorials/ (Hibernate)


Account : Wellington

1) Internal working of HashMap. How equals and hashcode method works. Complexity of search and insertion. What if equals returns true for all objects but hashcode imp is correct. What if hashcode always return 0 but equals implementation is correct.

2)How to create immutable classes.

3)How to create singleton classes. Lazy and Egarintialization in singleton approach.

4)Inner Classes and how can we use it create singleton class.

5)How to break singleton design and how can you protect that?

6)What is type erasure.

7)How to synchronize HashMap.

8)when to use callable and when runnable.

9) What inern method does

10)There are 1000 threads trying to write on disk. Disk has capacity off 100 threads. What approach will you use for this?

11)There are three threads t1 t2 and t3. Printing 1,2 and 3 respectively. You have to print in sequence first all 1 , after that all 2 and after that 3 . How can you achieve that?

12)Types of dependency injections

13)when to use which type

14) Different types of scopes in bean. What is default bean scope.

15)Create embedded entities in hibernate.

16) Generic Dao implementation

17)Marker Inerface

18)Any use case of generic you have implented

19)Wild cards in generics.

Java 8 specific:

1) Callable Future

2)Stream to collect odd and even number from an array.


1. Problems that can occur due to multithreading ?

2. Left Join and Right Join query ?

3. Create a cacahe API using java which will remove the data enterd after 5 seconds ?

4. How rest Authentication happens ?  Basically Oauth2.0 and OpenID.

5. Equals and Hashcode Contract ? Do they have same implementation ?

6. We have 1000 words find same Anagram words with there count ?

7. Self Join to get employee manager name

8. Internal working of concurenthashmap and hashmap.

9. TreeSet? why we need to implement Comparable interface for element of TreeSet ?  what happens If we do not implemnt it ?

10. Difference between Rest & Soap ? whether Rest is stateless OR Stateful ?

11. Is it necessary to write @override above method while overridding method ?

12. Is it necessary to write @FunctionalInterface above method class ?

13. Java 8 - Steams , Functional Interface , Default & Static methods in Interface, Method Refrence, BiPredicate, BiFunction, BiConsumer.

14. @Transactional with  Rollback , propogation , timeout ?

15. Immutable Class ? Need for declaring the member variable as private when there is no setter method in that ?

16. Design patterns : Decorator , Observer , Singleton

17. Diffrence between Inheritence & Composition and why Decorator different then inheritence ?

18. When we use Future<T> what exception we get if execution is not completed successfully ?

19. Comparable and Comparator ?

20. Rest Exception handling, Idempotance, Http Status Code , HATEOAS

21. spring AOP : before , after , around , pointcut , joinPoint , after throwing , after returning

22. Spring scopes ? How to use Prototype inside Singleton Scope ?

23. LifeCycle of thread ?


 

Spring ---

 

1-spring scope how works if a singleton been is inside of prototye bean and vie versa.

how many bean is created in both case when request come one time only and both type of bean are in application.

 

2- spring propert place holder and el expression

 

3-- circular dependency problem how to reslove

 

4- how implement own factory using spring library

 

 

 

java----

 

 

1- java 8 - stream lambda

 find employee with salary greater than 1000 from custom employee list.

Filter and map use cases

 

 

 2-collector vs reducer

 

 3-when use both in which scenario

 4- flatmap use cases

 

5- predicate bifunction and other built in functional interface details

 

 5- how to write a method to return synchronized map like to write api .

 

 6- volatile memory model

 7- java 8 memory model changes

8- garbage collector algorithm

 9- concurrent hash map java 8 changes

 10 - why default method is added in java 8.

11- method reference useages . scenario when we use method reference .

 

 12- synchronized instance method and static method use cases . multiple thread access both type of method in same instance and in different instance



Thanks&Regards
Dileep Kumar Maurya
+919871785951

package com.dileep.lambda;

import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import com.sun.org.apache.xpath.internal.operations.And;

public class Temp {

    static class Person {

        private String name;
        private int age;
        private long salary;

        Person(String name, int age, long salary) {

            this.name = name;
            this.age = age;
            this.salary = salary;
        }

        @Override
        public String toString() {
            return String.format("Person{name='%s', age=%d, salary=%d}", name, age, salary);
        }
    }

    public static void main(String[] args) {
        Stream people = Stream.of(new Person("Paul", 24, 20000),
                new Person("Mark", 130, 30000),
                new Person("Will", 28, 28000),  new Person("Will", 28, 28000),  new Person("Will", 28, 28000),  new Person("Will", 28, 28000),
                new Person("William", 28, 28000));
        Map> peopleByAge;
        peopleByAge = people
                .collect(Collectors.groupingBy(p -> p.age, Collectors.mapping((Person p) -> p, Collectors.toList())));
        System.out.println(peopleByAge);
        System.out.println();
        Stream people1 = Stream.of(new Person("Paul", 24, 20000),
                new Person("Mark", 30, 30000),
                new Person("Will", 28, 28000),  new Person("Will", 28, 28000),  new Person("Will", 28, 28000),  new Person("Will", 28, 28000),
                new Person("William", 28, 28000));
       
        List personList = people1.collect(Collectors.mapping((Person p)-> p.name, Collectors.toList()));
        System.out.println(personList);
        System.out.println();
       
        Stream people2 = Stream.of(new Person("Paul", 24, 20000),
                new Person("Mark", 340, 30000),
                new Person("Will", 28, 28000),  new Person("Will", 28, 28000),  new Person("Will", 28, 28000),  new Person("Will", 28, 28000),
                new Person("William", 28, 28000));
       
        Optional maxAge =   people2.collect(Collectors.mapping((Person p)->p.age, Collectors.maxBy(Integer::compareTo) ));
        System.out.println(maxAge.get());
    }
}

Comments

Popular posts from this blog

JPA JPQL advantages and disadvantage