Panda Guru LogoPanda
Guru

HSC | Java Backend Engineer | Gurgaon | September 2024

Round 1

Questions:

  1. Tell me about yourself.
  2. Create a class named Employee and create entries via List<Employee>. Fetch the employee name who is "manager" using Stream API.
  3. Sort a HashMap according to the key using Stream API.
  4. Questions on design patterns (Singleton pattern and Factory design pattern).
  5. How does hashing work internally in HashMap?
  6. Difference between HashMap and TreeMap?
  7. Explain functional interfaces and any pre-defined functional interface.
  8. SQL: Write a SQL query to find employees who are managers and whose joining date is in the month of August.
  9. Difference between TRUNCATE and DELETE.
  10. How does a Spring Boot application start?
  11. How to create a new Spring Boot application?
  12. What are @GetMapping and @PostMapping?
  13. Difference between @QueryParam and @PathParam.

Below is my code snippet:

import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; public class hsc { public static void main(String[] args) { List<Employee2> aList = new ArrayList<Employee2>(); aList.add(new Employee2("Yash", "Manager")); aList.add(new Employee2("Nishant", "Employee")); aList.add(new Employee2("Priti", "HR")); List<Employee2> finaList = aList.stream() .filter(x -> x.getDesignation().equals("Manager")) .collect(Collectors.toList()); HashMap<String, String> hMap = new HashMap<String, String>(); hMap.put("Surya", "Football"); hMap.put("Aditi", "Basketball"); hMap.put("Yash", "Chess"); //to perform sort on basis of name Map<String, String> collect = hMap.entrySet() .stream().sorted(Map.Entry.comparingByKey()) .collect(Collectors.toMap(Map.Entry :: getKey, Map.Entry :: getValue, (oldValue, newValue) -> oldValue, LinkedHashMap::new)); System.out.println(collect); System.out.println(finaList.toString()); singletonExample singlet1 = singletonExample.getInstance(); singletonExample singlet2 = singletonExample.getInstance(); System.out.println(singlet1); System.out.println(singlet2); } } class Employee2{ private String name; private String designation; public Employee2(String name, String designation) { this.name = name; this.designation = designation; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getDesignation() { return designation; } public void setDesignation(String designation) { this.designation = designation; } @Override public String toString() { return "Employee2 [name=" + name + ", designation=" + designation + "]"; } }
public class singletonExample { private static singletonExample singletonExample2; private singletonExample() { } public static singletonExample getInstance() { if(singletonExample2 == null) singletonExample2 = new singletonExample(); return singletonExample2; } }

I answered all the questions correctly and smoothly. Still Rejected.

Candidate's Approach

The candidate created a class Employee2 and used a List to store employee entries. They utilized Stream API to filter and fetch employees with the designation "Manager". For sorting a HashMap, they applied Stream API to sort by keys and collected the results into a LinkedHashMap. The candidate also implemented a Singleton pattern and provided explanations for design patterns and SQL queries as requested.

Interviewer's Feedback

No feedback provided.