Javarevisited
Published in

Javarevisited

17 Java Developer Interview Question Series-9(Experienced candidates 0–6 years)

This article will cover Java interview questions on, Core Java, Java-8, Functional programming, Spring Framework, Coding interview questions, and SQL database questions. Let's Dive into it.

Java 8 Stream API:

 Optional<Employee> maxSalaryEmployee = 
employeeList.stream()
.collect(Collectors.maxBy(Comparator.comparing(Employee::getSalary)));

Polymorphism coding puzzle? Guess the Output?

public class InheritanceTest {
public static void main(String[] args) {
method(null);
}
public static void method(Object o) {
System.out.println("Object method");
}
public static void method(String s) {
System.out.println("String method");
}
}

Inheritance Coding problem, guess the output?

class A{
public void m1() throws ArrayIndexOutOfBoundsException{
System.out.println("In m1 A");
}
}
class B extends A
{
void m1() throws IndexOutOfBoundsException
{
System.out.println("In m1 B");
}
void m2() throws IndexOutOfBoundsException
{
System.out.println("In m2 B");
}
}
public class Test {
public static void main(String[] args) {
A a=new B();
a.m2();
}
}

Write a Program to find a common element from three integer ArrayList. eg. arr1, arr2, and arr3.

findCommon(int a[], int b[], int c[], int n1, int n2,int n3)
{
// three sets to maintain frequency of elements
HashSet<Integer> uset = new HashSet<>();
HashSet<Integer> uset2 = new HashSet<>();
HashSet<Integer> uset3 = new HashSet<>();
for (int i = 0; i < n1; i++) {
uset.add(a[i]);
}
for (int i = 0; i < n2; i++) {
uset2.add(b[i]);
}
// checking if elements of 3rd array are present in
// first 2 sets
for (int i = 0; i < n3; i++) {
if (uset.contains(c[i]) && uset2.contains(c[i])) {
// using a 3rd set to prevent duplicates
if (uset3.contains(c[i]) == false)
System.out.print(c[i]+" ");
uset3.add(c[i]);
}
}
}

Employee list, find employees based on location or city and sort in alphabet manners like a-z and each city employee’s salary should be sort max to min salary.

What is Method Reference in Java 8?

ContainingClass::staticMethodName

HashSet Internal Working?

by GeekForGeek

Tell me About SpringBoot’s Entry point. What it does do? What component scan does? how to exclude any configuration?

Spring Bean Lifecycle?

by jstobigdata

How bean is injected in spring? which type of dependency injection is you will prefer?

Tell me about the Java memory model. Memory leak in java? how to rectify that in java? how to use a profiler for that? out of memory error?

Optional in java?

Usage of the index in java? Advantages and disadvantages of it in Database?

Explain database joins.

How to write wrapper class in java?

What is JIT in java?

Have you written the main method without static?

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ajay Rathod

I am a Software Developer. I share articles on Java , Spring Boot, Microservices and Cloud.