Search This Blog

Wednesday, May 22, 2019

Banking Domain interview Questions on Java Part-2

Including here part-2 of CitiBank interview questions in Java.
Section A.
Q1. Composition v/s Inheritance.
Q2. HashMap, hashcode() and equals() contract.
Q3. Resizing or Rehashing in HashMap.
Q4. Difference between HashMap and Concurrent HashMap.
Q5. Locking in Concurrent HashMap and internal working.
Q6. Any updation in HashMap in jdk8.-balanced tree
Q7. We have an array of integer
Like : 5, 0, 3, 0, 1, 2, 0, 0, 6
Output should be : 5, 3, 1, 2, 6, 0, 0, 0, 0
Q8. We have 100 stories building and 2 eggs. How you will find the safest floor.
(Assume 45th floor is the safest floor. Below 45th floor all floors will be safe and above will be unsafe. (Safe means if we drop egg from the safe floor it will not break, From unsafe egg will break.)) .
Q9. Find the reminder from the method
public long reminder(long a, long b){
// calculate reminder of a and b and return (Long does not support % operator)
Q10. What will happen if finalize method throw runtime exception. Will System.gc() will start or the program will exit.
Q11. public int add(int a, int b){ return a+b; }
Above code is in multithreaded environment. Do we need to make it thread safe or it is already thread safe.
Q12. Class Circle{
public void printBlankCircle(){
//some code here
public void printBlankCircle(){
//some code here
Above class is in multithreaded environment? You have to ensure that two threads can simultaneously approach both the methods but 2 threads cannot access same method at same time.

Q13. Employee table
Columns : Name, dept, salary, doj
Write a query to find second highest salary for each department.
Section B:
1) How to maintain the count of the Instances created for a class
2) Replace the nth element of the array with the Largest element found on the right side of it

Asked about the sudo code for this scenario




3) Design a System based on the Input and Output are Provided below

Input: there is a stock Trade data coming each second

Output: System will Publish or Produce top 10 Traded stocks

4) Inter thread Communication Techniques

5) DB Related question:

Two tables Employee(empname,empid,depid,salary) and Department(depname, depid)

Find the average salary of the Employees working inside the same department

Section C:
Scenario 1
There are 3 threads:

1st thread prints {1, 4, 7, …}
2nd thread prints {2, 5, 8, …}
3rd thread prints {3, 6, 9, …}

How will you print {1, 2, 3, 4, 5, 6, 7, 8, 9, ...}? (Write pseudocode).

Scenario 2
There is an Employee class with member variables(String name, int id). Create following objects of Employee class:
Employee emp1 = new Employee(1, "John");
Employee emp2 = new Employee(1, "John");

Create hashmap:
Map<Employee, Employee> map = new HashMap<>();

map.put(emp1, emp1); //put emp1 object into hashmap
Q : If we try to get value using map.get(emp2) then what will return?

Follow up question
map.put(emp2, emp2); //now put emp2 object into hashmap
Q : What will be the size of HashMap?

Scenario 3
There is an existing HashMap using in a project and having lots of data then how will you sort this HashMap on the basis of Keys? (Without using TreeSet).

Scenario 4
There is a linkedlist data structure containing 10 elements, then how will you find the nth last(for e.g. 3rd last or 5th last etc.) element? (Write pseudocode).

Scenario 5
There is an Employee class with member variables(String name, int id) then how will you prevent multiple write access of setter method for name field
in case of multi-threaded environment?
I am sure after watching out all the questions from part-1 and part-2 , you will gain more and more knowledge on cracking banking domain company interviews .
You can comment below to discuss the questions in detail.

No comments :

Post a Comment