Questions Asked in Interview

 core java interview questions:


1. what is difference between callable and runnable- revise multi threading- DISCUSS


to return anything from thread we use callable, whatever we want to return 


2. what is bloking queue

3. how to stop hashing collision-revise collection framework- DISCUSS


hashing collision: 


4. what is load factor of hashmap- 0.75f (75% of the map size).

5. what is default size of hashmap-16

6. what is builder design pattern- revise design pattern- DISCUSS

It is used to construct a complex object step by step and the final step will return the object.


Consider the construction of a home. Home is the final end product (object) that is to be returned as the output of the construction process. 

It will have many steps like basement construction, wall construction, and so on roof construction. Finally, 

the whole home object is returned. Here using the same process you can build houses with different properties.


7. how to create immutable class- revise string class

Immutable class in java means that once an object is created, we cannot change its content.

In Java, all the wrapper classes (like Integer, Boolean, Byte, Short) and String class is immutable. 

- final class

-final data members

-a parameterized constructor, and getter methods.

-no setter method


8. what is serial versions of compiler- revise garbage collection- DISCUSS


It (serialVersionUID ) is used during deserialization to verify that the sender and receiver of a serialized object have 

loaded classes for that object that are compatible with respect to serialization.


9. what is consumer interface-revise java 8 features


Unlike most other functional interfaces, it accepts a single input argument and returns no result.


10. what is predicator interface


Predicate<T> is a generic functional interface that represents a single argument function that returns a boolean value (true or false).



-----------------------------------------------------------------------------------------------------------------------------------------------------------------------


1. features of java 8

2. how to compare two object in java 8 using comparable and comparator

3. how hashmap internally works- DISCUSS

4. difference between hashmap and concurrent hashmap, how concurrent hashmap is working internally- discuss

-HashMap is the Class which is under Traditional Collection and ConcurrentHashMap is a Class which is under Concurrent Collections

-HashMap is not Thread-safe whereas ConcurrentHashMap is Thread-safe in nature.

-HashMap performance is relatively high because it is non-synchronized in nature and any number of threads can perform simultaneously. But ConcurrentHashMap 

performance is low sometimes because sometimes Threads are required to wait on ConcurrentHashMap.


-While one thread is Iterating the HashMap object, if other thread try to add/modify the contents of Object then we will get

 Run-time exception saying ConcurrentModificationException.Whereas In ConcurrentHashMap we wont get any exception while performing 

any modification at the time of Iteration


-In HashMap, null values are allowed for key and values, whereas in ConcurrentHashMap null value is not allowed for key and value, 

otherwise we will get Run-time exception saying NullPointerException.Using HashMap


-HashMap is introduced in JDK 1.2 whereas ConcurrentHashMap is introduced by SUN Microsystem in JDK 1.5.


5. what is hash collision

6. what is @RequestParam and @PathVariable

The @PathVariable annotation is used for data passed in the URI (e.g. RESTful web services) while @RequestParam is used to extract the data found in query parameters.

7. How Spring boot is making development fast

boilerplate code----->configurations------>Sprint boot (eliminates the boilerplate configurations required for setting up a Spring application)


-In the early days of Java web development, we needed to write a lot of boilerplate code to insert a record into a data source. 

By using the JDBCTemplate of the Spring JDBC module, we can reduce it to a few lines of code with only a few configurations

-Spring Boot is basically an extension of the Spring framework, which eliminates the boilerplate configurations required for setting up a Spring application.


-Here are just a few of the features in Spring Boot:


>Opinionated ‘starter' dependencies to simplify the build and application configuration

>Embedded server to avoid complexity in application deployment

>Metrics, Health check, and externalized configuration

>Automatic config for Spring functionality – whenever possible


8. How to update the pom file in spring boot, manually or automatically if I have to change any version in pom file.

9. different between interface and java 8 interface

10. how you implemented authentication in your application




-------------------------------------------------------------------------------------------------------------------------------------------------------------


1. how to build a customer module using microservice architecture

2. what is d/b @controller and @restcontroller

--@Controller is used to mark classes as Spring MVC Controller. 

-@RestController annotation is a special controller used in RESTful Web services, and it's the combination of @Controller and @ResponseBody annotation.



3. do we need to write response body in controller

4. what are the different types of SQL joins, what is left join, right join


-(INNER) JOIN: Returns records that have matching values in both tables

-inner join: 


SELECT Orders.OrderID, Customers.CustomerName, Shippers.ShipperName

FROM ((Orders

INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID)

INNER JOIN Shippers ON Orders.ShipperID = Shippers.ShipperID);


- The LEFT JOIN keyword returns all records from the left table (table1), and the matching records from the right table (table2). 

The result is 0 records from the right side, if there is no match.


SELECT CUSTOMER.CUSTOMERNAME, ORDER.ORDERID

FROM CUSTOMER

LEFT JOIN ORDER ON CUSTOMER.CUSTOMERID=ORDER.ORDERID

ORDER BY CUSTOMER.CUSTOMERNAME


-The RIGHT JOIN keyword returns all records from the right table (table2), and the matching records from the left table (table1).

The result is 0 records from the left side, if there is no match.


SELECT Orders.OrderID, Employees.LastName, Employees.FirstName

FROM Orders

RIGHT JOIN Employees ON Orders.EmployeeID = Employees.EmployeeID

ORDER BY Orders.OrderID;


- FULL JOIN: 

 The FULL OUTER JOIN keyword returns all matching records from both tables whether the other table matches or not. So, if there are rows in 

"Customers" that do not have matches in "Orders", or if there are rows in "Orders" that do not have matches in "Customers", those rows will be listed as well.


SELECT Customers.CustomerName, Orders.OrderID

FROM Customers

FULL OUTER JOIN Orders ON Customers.CustomerID=Orders.CustomerID

ORDER BY Customers.CustomerName;


5. how to build application using spring boot

--------------------------------------------------------------------------------------------------------------------------------------------------------------


1. fetch only even rows in sql 

2. how to handle exception in spring boot

3. what is role of begin transaction in hibernate

4. can we start thread twice.

5. what is difference between class lock and object lock?

6. when we get out of memory error in java

7. what is softlink and hard link in linux

8. how to stop null in json

9. difference b/w String str="Hello" and String str = new String ("Hello");

10. what is observer design pattern?






Comments