0% found this document useful (0 votes)
18 views

Java Interview Questions Sample..

Uploaded by

Mayank Sikarwal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Java Interview Questions Sample..

Uploaded by

Mayank Sikarwal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Interview Questions :

Brief knowledge about your last project:

1. What’s your role and responsibility in there?


2. Architecture of your last application, How request flows in your application from frontend to
backend (Database)?

Core Java Basic Question :

1. Oops basic concepts?


2. How you perform abstraction and encapsulation in your application.

3. What is polymorphism and types of polymorphism?


4. How can you say overriding is runtime polymorphism and overloading is compile time ,explain
with example?
5. What is the need of interface and abstract class ?
An abstract class permits you to make functionality that subclasses can implement or override
whereas an interface only permits you to state functionality but not to implement it. A class can
extend only one abstract class while a class can implement multiple interfaces.
6. Can we create instance of abstract class?
No

6/18/2020 AXP Internal 1


7. What is the need of constructor in abstract class?
A constructor in Java doesn't actually "build" the object, it is used to initialize fields. Imagine that
your abstract class has fields x and y, and that you always want them to be initialized in a certain
way, no matter what actual concrete subclass is eventually created.
8. What is constructor chaining and method binding?
Constructor chaining is the process of calling one constructor from another constructor with
respect to current object. ... Within same class: It can be done using this() keyword for
constructors in same class. From base class: by using super() keyword to call constructor from
the base class.
9. What is Object Cloning? Types of cloning?
The object cloning is a way to create an exact copy of an object. For this purpose, the clone()
method of an object class is used to clone an object. The Cloneable interface must be
implemented by a class whose object clone to create.
10. What is the diff between static and final keyword in details?
The main difference between a static and final keyword is that static is keyword is used to define
the class member that can be used independently of any object of that class. Final keyword is
used to declare, a constant variable, a method which can not be overridden and a class that can
not be inherited.
11. Types of Inner classes?
12. How perform Exception Handling in your application ?
13. Hierarchy of Exception class? How to create custom Exception?
14. Diff between throw and throws?
Throws clause is used to declare an exception, which means it works similar to the try-catch
block. ... Throw keyword is used in the method body to throw an exception, while throws is used
in method signature to declare the exceptions that can occur in the statements present in the
method.
15. What is the role of finally keyword ?can ask scenario based problem for this?
16. Diff between Exception and Error?
Errors mostly occur at runtime that's they belong to an unchecked type. Exceptions are the
problems which can occur at runtime and compile time. It mainly occurs in the code written by
the developers. Exceptions are divided into two categories such as checked exceptions and
unchecked exceptions.
17. What is marker interface ? types of marker interface ?Can we create your own custom marker
interface if yes then how?
Marker interface in Java is interfaces with no field or methods or in simple word empty interface
in java is called marker interface. Example of marker interface is Serializable, Cloneable, and
Remote interface.
18. Diff between JDK,JRE and JVM? What is the internal structure of JDK?
JDK is a software development kit whereas JRE is a software bundle that allows Java program to
run, whereas JVM is an environment for executing bytecode. The full form of JDK is Java
Development Kit, while the full form of JRE is Java Runtime Environment, while the full form of
JVM is Java Virtual Machine.

6/18/2020 AXP Internal 2


19. how to manage memory leaks in java?
Release the session when it is no longer needed. ...
Keep the time-out time low for each session.
Store only the necessary data in your HttpSession.
Avoid using string concatenation.
20. What is Out of memory?
Out of memory" (OOM) is an error message seen when a computer no longer has any spare
memory to allocate to programs. An out of memory error causes programs — or even the entire
computer — to power down. ... Adding RAM -- or Random Access Memory -- to your computer
can increase its performance.
21. What is StackOverflowError?
A StackOverflowError is a runtime error in java. It is thrown when the amount of call stack
memory allocated by JVM is exceeded. A common case of a StackOverflowError being thrown, is
when call stack exceeds due to excessive deep or infinite recursion.

String:

1. What are different ways to create String Object? He can create objects with diff ways and ask for the
object counts ?
2. Write a method to check if input String is Palindrome? Focus on complexity in your program?
3. How to compare two Strings in java program ?
4. Difference between String, StringBuffer and StringBuilder?
5. Why String is immutable or final in Java?
6. Why Char array is preferred over String for storing password?
7. What is String Pool?
8. What does String intern() method do?
9. Does String is thread-safe in Java?
10. Why String is popular HashMap key in Java?
11. Can you create your own immutable class?
12.

Collection: java.utill.*;

1. Explain Collection’s hierarchy?


2. Diff between Collection and Collections?
3. Why Map interface does not extend Collection interface?
4. What is diff between ArrayList and LinkedList ?
5. How remove() method works in Arraylist? internal implementation of remove()?
6. How to create own custom ArrayList?
7. Remove duplicate values from ArrayList?
8. Why we use Set Interface?what are the main classes implementing Set interface?
9. Diff between TreeSet and HashSet?
10. Internal working of HashSet ?
11. internal working of HashMap like how put(key,value) and get(key) works internally?
12. Diff between comparator and Comparable interface? With example?
13. Contract between hashcode() and equals()?

6/18/2020 AXP Internal 3


14. Can we pass objects of mutable class as a key into a Map?
15. What happens if two different key have the same hashcode?how map handle the hashcode
collision?
16. How to avoid hashcode collision?
17. Diff between FailFast Iterator and FailSafe Iterator?internal working of FailFast and FailSafe
iterator?
18. What is ConcurrentModificationException?How to handle with this?
19. What is ConcurrentHashMap?Internal working of hash map?
20. How you can create your own customaries TreeMap?
21. Where we need to use the Map in our application give any example?
22. How to iterate HashMap?
23. How to iterate LinkedList?
24. What is Map and reduce?
25. Difference between map and for?
26. What is closure?

Multithreading:

1. Consumer producer problem or odd even number print by multiple thread ,practically to
understand the concept of wait and notify and notifyAll?
2. Lifecycle of Thread?
3. How many ways to create a Thread and Which one is better to create Thread ?
4. Difference between Runnable and Callable interface?
5. What is Future Object?
6. What is Executor Framework ?what is the need of Executor Framework?
7. What is Cycli Barrier, CountdownLatch, BlockingQueue, PriorityBlockingQueue ?
8. What is volatile keyword? Difference between static and volatile?
9. What is synchronization? Which one is better synchronization block or method?
10. What is Batch processing?
11. What is callable?
12. Difference between callable and runnable?
13. Return type of callable and runnable?
14. Feature object is Asynchronous or Synchronous?

Serialization :

1. What is serialization how to perform serialization?


2. What is the difference between Serializable and Externalizable interface in
Java?
Serializable is a marker interface i.e. does not contain any method.
Externalizable interface contains two methods writeExternal() and
readExternal() which implementing classes MUST override. Serializable
interface pass the responsibility of serialization to JVM and it's default
algorithm.

6/18/2020 AXP Internal 4


3. How many methods Serializable has? If no method then what is the purpose
of Serializable interface?
4. What is serialVersionUID? What would happen if you don't define this?
5. While serializing you want some of the members not to serialize? How do you
achieve it?
6. What will happen if one of the members in the class doesn't implement
Serializable interface?
7. If a class is Serializable but its super class in not, what will be the state of the
instance variables inherited from super class after deserialization?
8. Can you Customize Serialization process or can you override default
Serialization process in Java?
9. Suppose super class of a new class implement Serializable interface, how can
you avoid new class to being serialized?
10.Which methods are used during Serialization and DeSerialization process in
Java?
11.Suppose you have a class which you serialized it and stored in persistence
and later modified that class to add a new field. What will happen if you
deserialize the object already serialized?

Garbage collection:
1. What is Garbage collection, How its work internally?
2. How G1 Works?

Spring :

1. What is Dependency Injection?


2. What is Inversion of Control?
3. What are different bean scopes?
4. What is the role of IOC container in spring?
5. What are the types of IOC container in spring?
6. What is the difference between BeanFactory and ApplicationContext?
7. What is the difference between constructor injection and setter injection?
8. What is autowiring in spring? What are the autowiring modes?
9. In which scenario, you will use singleton and prototype scope?
10. Prototype scope: A new object is created each time it is injected. Singleton scope: The same
object is returned each time it is injected. Prototype scope is used for all beans that are stateful,
while the singleton scope should be used for stateless beans.

Rest Services:

1. Enlist some of the HTTP methods with description.

6/18/2020 AXP Internal 5


2. What is the difference between PUT method and POST method? What Is Patch, OPTIONS,
HEAD?
3. State The Core Components Of An HTTP Response and Request
4. Security in Rest Services
5. POST vs PUT, when to use which
6. What are the data formats supported by RESTful architecture
7. When and based on what criteria should you bifurcate a monolith into microservices
8. Micro-Components vs micro-services

NoSQL(Couchbase):

1. What is NoSQL
2. NoSQL vs SQL
3. What is N1QL
4. How are data stored in couchbase
5. What are the data formats accepted by couchbase
6. How to search data in couchbase
7. How to configure indexes
8. What are views
9. Is couchbase java SDK async or synchronous, explain
10. What is sub doc API
11. What type of locking is used in couchbase
12. How to avoid locking while doing concurrent updates on same document

RxJava:

1. What is the Threading model in RxJava


2. How is observer pattern implemented in RxJava
3. Is RxJava Async?
4. Is RxJava Reactive?
5. Map vs FlatMap
6. Explain doOnError, doOnNext, doOnEach, subscribe, just
7. Explain Observable, Single, Maybe
8. Is RxJava backward compatible with Java 7?

Vert.x Programming:

1. Event loop vs Worker threads


2. Is vertx Reactive? Explain

6/18/2020 AXP Internal 6


3. How to start a server in vertx
4. How to provide REST endpoints in vertx
5. How many threads does Vert.x has by default(Thread count)
6. Can you have thread pools in vertx?
7. Is vertx Asynchronous, explain
8. What do you mean by polyglot
9. What are verticles
10. What is event bus
11. What is the default implementation of eventbus in vertx, Can you change the default
implementation of event bus in vertx
12. What are nano services
13. What is clustering in vertx
14. What is Rxified Vertx
15. What is WebClient
16. What are the data types supported by eventbus
17. Can kafka be used with eventbus?
18. How does vertx improve upon traditional JDBC connection strategy and traditional JDBC
SDKs

Reactive Programming:

1. What is Reactive Programming?


2. What is Observer Pattern
3. What is Publisher-Subscriber model

Multi Threading:

1. What is context switch?


2. Given that you have to optimize performance of the application and need to make some
upgrades to your threading model, how will you change the threading model and based on
what parameters
3. What is Race condition, deadlock, Thread resource sharing
4. How is thread context switch different from process context switch
5. How many types of threads are in Java, how do they differ from each other
6. Can you use static and volatile together?
7. What is thread priority, and is it modifiable after thread creation
8. Can you change thread type after its creation
9. What does yield, join methods do and when to use them?
10. Multithreading vs Multiprocessing

Java 8:
1. New features introduced in Java 8.
2. Why default method introduced in interfaces?

6/18/2020 AXP Internal 7


3. Why static method introduced in interfaces?
4. What is the advantage of using new Date API?
5. I have list (1,2,3,4,5,6,7,8,9,10). How we can iterate the list and print each element?
{forEach()}
6. What is lambda expression?
7. Do you know what are the various forms of writing lambda expression?
8. What do you understand by @FunctionalInterface annotation?
9. How do you create custom annotation?
10. What is Stream API and what is the need of same?
11. Difference between Collections and SteamAPI?
12. Different ways to create stream?
13. Convert streams to collections?
14. How to avoid NullPointer exception in Java 8? {Optionals concept}

React:

1. What is React?
2. What are the features of React?
3. What is JSX? Why browsers can’t read JSX?
4. Diff between virtual dom and real dom?
5. Name Lifecycle methods and their purpose.
6. What do you understand from “In react everything is a component”?
7. Explain the purpose of render function?
8. Why do we use arrow function in react?
9. How to prevent components from re-rendering?
10. Differentiate between state and props?
11. Differentiate between stateful and stateless components.
12. What is difference between ES5 and ES6 standard?
13. What is an event in React?
14. What are synthetic events in React?
15. What do you understand by refs in React?
16. List some of the cases where you should use refs?
17. How forms are created in React?
18. What do you know about controlled and uncontrolled components?
19. What are higher order components?
20. What are pure components?
21. What is Redux?
22. What are the 3 principles that Redux follows?
23. What do you understand by single source of truth?
24. List down the components of Redux
25. Explain how the data flow through Redux?
26. How are actions defined in Redux?
27. Explain the role of reducers
28. What is the significance of store in Redux?

6/18/2020 AXP Internal 8


29. Differentiate between Flux and Redux.
30. What is React Router?
31. Server side rendering?
32. How to prevent rendering while performing server side rendering?
33. Can we use events in server side rendering?
34. Object destructuring

Microservices:

1. What do you understand by Microservices?


2. Design a simple microservice architecture application
3. Migrate the existing monolithic application to microservices

DB questions:

1. Is null considered same as that of blank space or zero?

Questions from Bangalore Team:

 What all OOP’s principles you have implemented so far?


 How abstraction is implemented?
 Where do we have to use Inheritance?
 Have you used polymorphism?
 Different access modifier in JAVA?
 Wrapper classes in Java.
 Why JAVA has to make String as immutable?
 Did u use finally block? what statements did you use?
 Which test Framework is used for mocking?
 Are you aware for annotations for exception handling?
 Have you used String builder? What is usage for String Builder over Stream API?

Scenario Based question: You have an Array of Integers; it could be of any size/length? You need write
an algorithm to find out the largest number possible from the numbers in array.

Ex : Let say, array has 0,1,2,3,4,5,6,7,8,9 as number. Now the algorithm which you are writing should
have 9876543210 as an output. But number in array will vary as per input.

Spring Boot

1. How to set up a spring Boot project with maven?

6/18/2020 AXP Internal 9


2. Explain about Spring Boot Actuator?

3. Does Spring Boot require an external server? if no then why? How to add server?

4. Explain about ComponentScan, EnableAutoConfiguration, SpringBootApplication annotations?

5. How to implement Security in Spring Boot?

Spring Microservices

1. Is there any other way to expose an application as microservice other than making it as a REST
service?

2. What is Docker and what is the use ?

3. Which are the advantages of Spring Cloud over Spring Boot ?

4. How to implement security in a microservice?

6/18/2020 AXP Internal 10

You might also like