Interview Questions
Interview Questions
Interview Questions
1) Given a distance, count the total number of ways to cover the distance with 1, 2 and 3
steps.
Examples:
Input: n = 3
Output: 4
Explanation:
Below are the four ways
Input: n = 4
Output: 7
Explanation:
Below are the four ways
1 step + 1 step + 1 step + 1 step
1 step + 2 step + 1 step
2 step + 1 step + 1 step
1 step + 1 step + 2 step
2 step + 2 step
3 step + 1 step
1 step + 3 step
2) Given a Binary Tree, we need to print the bottom view from left to right
Examples:
20
/ \
8 22
/ \ \
5 3 25
/\
10 14
For the above tree the output should be 5, 10, 3, 14, 25.
20
/ \
8 22
/ \ / \
5 34 25
/\
10 14
For the above tree the output should be 5, 10, 4, 14, 25.
3) Given twio Linked lists joining at one node. Identify the joining node.
H1 1 2 9 4 5 6
12 13 14
H2 7 8 9 10 11
1) Why you have used Postgres DB in your project ? Any major reasons
2) I have developed one microservice in .net and can I consume it from another micro service which
was developed in JAVA ?
3) What is Polymorphism ?
4) How you will acheive Polymorphism (Explanations) ?
5) What is JPA ?
6) Why spring boot ?
7) What is the default scope for Java Bean ?
8) What are the design patterns that you know ?
9) Can you explain your current project in depth (functionalities and how you will acheive that) ?
10) What are observables and promises ?
11) Can you explain about lifecycles in Angular ?
12) You have one method in class A. Class B is extending A and overriding that method. I have
created child class object and call the overriden method. In this case why should I extends A from
B.
GE(Wabtec)
class Employee {
String name;
int id;
//setters and getters
}
for(int i=0;1;i++) {
System.out.println("Naveen");
}
for(int i=0;true;i++) {
System.out.println("hi")
}
class Parent {
public void m1(Object o) {
System.out.println("Parent class m1() method");
}
}
class Test {
public static void main(String[] args) {
Parent p = new Child();
p.m1(null);
}
}
====
class Parent {
public void m1() {
System.out.println("Parent class m1() method");
}
}
class Test {
public static void main(String[] args) {
Parent p = new Child();
p.m1();
}
}
class Employee {
name, id
//setters and getters
}
main() {
List<Employee> list = new ArrayList<Employee>(); //e1 = 2000 e2 = 3000
Employee e1 = new Employee("Manoj", 5042);
Employee e2 = new Employee("Naveen", 5041);
Map<Employee, Integer> map = new HashMap<>();
map.put(e1, 5042);
map.put(e2, 5);
e2.setName("Naveen");
map.get(e2);
list.stream().filter(emp -> emp.getName().startsWith("a") && (emp.getId() <= 1500 &&
emp.getId()>=1000)).collect(Collectors.toMap()); //collect this into map
Set<Employee> set = new TreeSet<>()
set.add(e1);//will this work
set.add(e2);
}
40) Given 3 tables, on certain criteria write a query to perform Join operation
41) What is proxy object ?
42) What is the difference between load() and get() in Hibernate ?
43) Difference between Map, Set, List ?
44) Difference between Arrays and List ?
46) Explain different types of joins ?
47) What is self join ?
48) If there are two GET requests with the same API and both results in Exception, which request
will raise Exception first ?
49)