0% found this document useful (0 votes)
4 views17 pages

Java Topics - Edited (1)

The document outlines a comprehensive guide on Java programming, covering various topics such as OOP concepts, core Java features, collection frameworks, multithreading, Java 8 enhancements, design patterns, Spring core, database management, performance tuning, and interview questions. It includes detailed explanations of concepts like exception handling, garbage collection, and concurrency, along with practical coding challenges and scenarios. Additionally, it addresses microservices architecture and Spring Boot specifics, providing a thorough resource for Java developers preparing for technical interviews.

Uploaded by

ranjith301nrv
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views17 pages

Java Topics - Edited (1)

The document outlines a comprehensive guide on Java programming, covering various topics such as OOP concepts, core Java features, collection frameworks, multithreading, Java 8 enhancements, design patterns, Spring core, database management, performance tuning, and interview questions. It includes detailed explanations of concepts like exception handling, garbage collection, and concurrency, along with practical coding challenges and scenarios. Additionally, it addresses microservices architecture and Spring Boot specifics, providing a thorough resource for Java developers preparing for technical interviews.

Uploaded by

ranjith301nrv
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 17

1.

Introduction:
a. Experience across companies – engineers
b. Latest project
i. Business Intent: Two lines
ii. People: 10 people
iii. Process: Agile
iv. Technology: Architecture of the project – “Module:”

2. OOPS Concepts
a. A.P.I.E. – Abstraction, Polymorphism, Inheritance, Encapsulation (encapsulate
what varies)
b. Strong cohesion, loose coupling, Don’t Repeat Yourself (DRY)
c. SOLID
i. DIP != IoC/DI in Spring
d. Class design – Student – private var, public get/set,
i. Constructors – default constructor
ii. equals, hashcode, - checking equality, hash based collections
iii. comparable – tree (comparator); sorting
iv. toString

3. Core Java

a. Abstract Class vs Interfaces from Java 8 onwards


b. Inner class / static inner class
c. Immutable class => Very important – How to create? Where to use?
d. Interface
e. Marker Interface – Cloneable [clone() - Object], Serializeable
f. Exception handling – Checked/Unchecked(Runtime)…Throwable
g. Garbage Collection – System.gc(); GC Algos – Serial, Parallel, G1, CMS
i. Memory management – heap, stack, metaspace
ii. Reference types : Soft, weak, strong, phantom.
h. Class loader/ static and dynamic loading
i. Comparable / Comparator Interface
j. String pool / String Buffer/ String Builder – Flyweight design pattern
i. Integer i1 = new Integer(1);
ii. Integer i2 = 1;
iii. Integer i3 = Integer.valueOf(“1”);
iv. I1 == i2; //false
v. I2 == i3; //true
vi. I1 == i3; //false
k. Constructor chaining / in case of abstract class/ interface
l. This and super keywords
m. Serialization – Externalizable, SerialVersionUID
n. Iterator / List Iterator – All iterators for all collections – fail fast or fail safe.
ConcurrentModificationException
i. Iterator design pattern
ii. Iterator + Composite design patterns go together mostly.
o. Rules of overloading and overriding (return types, access modifiers, exception)
p. Reflection
q. Exception Hierarchy and throw,catch, throws, try with resources, finally Method.
Exception propagation
i. Try.. catch.. finally…
1. Inside try block – return… Yes
2. Inside try block – system.exit()… No
r. Pass by value / pass by reference
i. Java is only pass by value…
ii. Litmus test… method(arg1,arg2) {//swap}
s. Serializable & Externalizable and cloanable Interfaces
t. Finalize/clone method of object class

4. Collection Framework(internals) – DS+Algos


a. Array / Array List - contiguous
b. Linked List – spread it across your heap/memory with one pointing to the other
c. Vector (rarely asked)
d. Hash Map – Hashing gives O(1) time complexity
e. hash Table
f. Linked Hash Map
g. Tree Map – Comparable/Comparator. (No use of hashcode or equals). Red-Black
Tree. O(logN) time complexity
h. Sorted Map
i. WeakHashMap
j. All kinds of Sets/ Hash Set/Tree Set
k. LinkedHashSet
l. Stack / Queue/ Priority Queue/ Blocking Queue
m. Condition Interface
n. Fail safe and fail fast iterator
o. CopyOnWriteArrayList – Reads >>> Writes
i. ArrayList -> iterator is fail-fast.. .CME.
ii. COWAL -
p. ConcurrentSkipListMap
q. ConcurrentHashMap
r. Collections.unmodifiableCollection()

5. Multithreading and Concurrency


a. Thread lifecycle and basics
6.

a. Volatile (don’t get confused with transient)


b. Synchronized => monitor = lock + condition.
c. Race condition
d. Deadlocks
e. Locks, Reentrant locks, ReadWriteLocks, Condition variables
f. BlockingQueue / Producer Consumer problem – implement blockingqueue.
i. ArrayBlockingQueue – bounded queue (fixed capacity)
1. 6,7,3,4,5
ii. LinkedBlockingQueue – bounded or unbounded
g. Semaphore – Print odd/even –
i. Permits.
ii. One permit…. Looks like a reentrant lock…
h. Synchronizers like CyclicBarrier, CountdownLatch
i. Atomic classes – AtomicInteger – Internal working and usage – CAS
i. Int x=10; synchronized increment(){x++;}
Read x into accumulator=> increment a => write back to x

Continuousincrement(){ while (flag) x++;}


resetFlag(){flag=false;} //volatile….

Pessimistic solution: use lock…


Optimistic solution: Atomicinteger…
T1 -> 10 -> 11 -> put 11 if value in memory is still 10 -> 11
T2 -> 10 -> 11 -> since old value of 10 is not in memory -> redo

Volatile => visibility of latest value


Exit of synchronized block => visibility of latest value

j. ExecutorService –
k. Callable
l. CompleteableFuture

7. Java 8 topics
a. Functional Interfaces
b. Method references
c. Lambdas
d. Optional
e. Streams

8. Design Patterns / Sorting Algorithms


a. Singleton – double check lock, enum, static…
b. Visitor
c. Template
d. Decorator
e. Strategy
f. Observer
g. Façade /session Façade
h. Factory /Abstract Factory
i. DAO

9. Spring Core
a. Bean Factory
b. Application Context
c. Bean Life Cycle
d. Init / destroy methods
e. Bean Listeners
f. Processors
g. Scopes
h. Loading mechanisms
i. IOC

10. Database (SQL/PLSQL)


a. DDL
b. DML
c. Delete/truncate/Drop
d. Union / Union All
e. Index/ clustered- non clustered index (including implementations at DS level)
f. Procedure
g. Group by/ having
h. Count(*) Max , Avg, etc
i. Join (types of joins)
j. Primary Kay / Unique Key
k. Isolation levels
l. ACID properties

11. Java Performance Tuning


a. GC algorithms – mark-sweep (OG – CMS), mark-sweep-compact (OG – Parallel
GC), mark-copy (younger gen)…
i. Serial – Historic, don’t use (<100MB)
ii. Parallel – Throughput collector (1000 requests/5sec)
iii. CMS – latency collector (> 95% of the users are served within 5 sec)
iv. G1 – 2048 sections ( > 4GB memory)
b. Heap memory settings
c. strong, soft, weak and Phantom reference
d. Stack and Heap Concept

12. Analytical/Logical /Scenario Based questions.


a. LRU/LFU dictionary or Cache
b. ATM/Library/HR dept design
c. Parking allocation
d. Find most frequently used word from text file
e. Sorting 10 MB file using 1 MB memory
f. 1 billion cellphone numbers to finds duplicates
g. Find duplicate number in Integer Array
h. Identify palindrome
i. Fibonacci series printing using recursive
j. Calculate factorial using recursive and iterative
k. Implement single elevator , double elevator
l. Simulate DVD renting system
m. etc

Sample questions below:

Question Set 1

1. Design a stack that supports getMin() in O(1) time and O(1) extra space.
2. Program for n’th node from the end of a Linked List

3. Semaphore in java 8, print odd and even number using semaphore

4. How ArrayList works internally in Java 8

5. find second largest number in array without sorting in java

6. Sort an array of 0s, 1s and 2s

7. Reverse a linked list

8. Garbage collection algorithms

9. Implement two stacks in an array

10. Producer-Consumer solution using threads in Java

Question Set 2

1. Implement database connection pooling using semaphore

2. Countdown latch/cyclic barrier -explain, difference between cyclic barrier and countdown
latch

3. How HashMap works internally in Java 8

4. Function to check if a singly linked list is palindrome

5. Atomic variable -How it works internally

6. Difference between Callable and Runnable

7. Detect and Remove Loop in a Linked List

8. CopyOnWriteArrayList implementation

9. Find first unique character in a String

10. Implement Multithreading application which demonstrates deadlocks and how to avoid
deadlocks.
Question Set 3:

1. Find position of an element in a sorted array of infinite numbers

2. How ConcurrentHashMap works internally in Java 8

3. BlockingQueue-Expalin, implement own ArrayBlockingQueue

4. ReentrantLock implementation

5. Intersection point of two Linked Lists.

6. Creating custom exceptions

7. Design a vending machine

8. Java Reference- Soft, Weak, Strong and Phantom

9. Sort an array of 0s, and 1s

10. Different and best approach for Singleton Pattern

Queue Set 4:

1. Search an element in a sorted and rotated array

2. How TreeSet works internally in Java 8

3. UnModifiable collection own implementation

4. Java 8 new features

5. largest-sum-contiguous-subarray

6. Tree traversal with implementation [preorder, postorder, inorder and mirror]

7. Design multi-level parking system

8. Map sort by value

9. Design Principle

10. find the middle element in a linked list


13. Implement StringPool -Flyweight Design Pattern
Question Set 5:

1. a. Write a program, we have an employee list with employee name, date of birth, id ,
salary. Remove name which starts with a (Without JDK 8 and with JDK 8).
b. Sort by salary the employee list using a TreeSet. (Cross question on Comparable vs
Comparator)
c. Write the Same program in the database writes a query with employee name, where
salary is between 20 thousand to 40 thousand.(Cross Questions)
2. Implement immutable class for Student class with attributes id, name and List<Course>
where Course is another class with courseId and courseName as attributes. Take care of the
collection case here: List<Course> should not be editable once assigned through the
constructor.
3. Overloading: add(int, float) and add(float, int). Which method will add(2,3) call?
4. Rules of overriding in detail, including exceptions thrown, covariants
5. Internal implementation of TreeMap – indexing, hashCode, equals, linkedlist, treeify after
Java 8, load factor and its significance.
6. Difference between synchronized block, reentrant lock, synchronized method.
7. Scenarios for ReadWriteLock, AtomicInteger, Semaphore, CyclicBarrier, CountdownLatch
8. Future vs CompleteableFuture
9. Types of SQL joins with examples – Self, inner, outer (R/L), equi vs non-equi
10. Given a DB table with columns Debit/Credit, Amount. Write SQL to find balance.
11. Aggregate queries, group by, having direct questions.
12. Find employees with highest salary from table
13. Remove duplicate employee records from table
14. Spring AOP – terminologies, all annotations associated and where to use, scenario
15. REST – characteristics, advantages, when to use, when not to use.
16. Steps to implement REST API using Spring / Spring Boot
17. When to use GET, PUT, POST, DELETE, PATCH. PUT vs POST, GET vs POST, PUT vs PATCH
18. Design REST API with URL, path variables, request parameters, sorting and paging,
authentication using Spring Boot.
19. Monitor performance of Spring Boot app
20. CAP theorem. When to use MongoDB vs Cassandra vs Oracle
21. Explain your project – 2 lines business intent, detailed technical architecture/ HLD, your
contribution, process followed
22. Most difficult technical challenge faced in the projects.
23. HashMap vs ConcurrentHashMap internals
24. Implement priority queue
25. Implement blocking queue
26. Implement Singleton using double check lock. Why double check – detailed explanation.
Why instance must be volatile. How to guard Singleton against serialization, cloning, and
reflection
27. When to use protected access modifier… scenario?
28. JMS, Kafka, Microservices questions if you have experience in those. Questions are direct
and related to project and basic concepts
29. Merge two sorted lists into one sorted list- in best time complexity possible
30. Java Stream API to count number of integers in a list occurring multiple times. Also output
integer with maximum frequency.
31. Program to check if brackets are balanced in an arithmetic expression.
32. How to use profiles in Spring Boot?
33. Types of indexes in databases with internal data structure and working.
34. SQL queries performance tuning.
35. Views vs Materialized views. Could it be OLTP vs OLAP?
36. How Spring Actuator can be used?

A typical interview:

1. Core Java

a. ArrayList vs LinkedList, vector - when to use which of these

b. Hashmap, equals and hashcode, Collison, comparator (deeper understanding)

c. Immutability and making a custom class mutable (inner workings)

d. Synchronize Hashmap and Concurrent Hashmap

e. Thread and Executer service (Practical knowledge/Deeper understanding)

i. Lock levels and question around that

ii. Benefits of using Executor Service

f. Garbage Collection

i. Memory Partitions and benefits

ii. Major vs minor GC

g. Data Structures - implementation of a LRU Cache

2. Logic and problem solving

a. Estimate value of 2^24

b. In an array of integers, find out odd occurring integer in O(n) time. Given all numbers appear
even times except one integer.
c. Implement an org structure and give 2 APIs for getting all the managers and all the
employees.

d. Asking questions around the problem proactively, for a deeper understanding of the same so
as to develop an effective solution

3. Databases

a. Questions around Functions and Procedures

b. Queries using “group by”

c. Indexes

d. Joins

4. Communication

a. Ability to explain the thoughts clearly and be able to interact with team members across
multiple global locations

Microservices Questionnaire

1. Advantages of Microservices architecture?


2. What are the characteristics of a Good Microservice?
3. Design Principles of Microservices architecture?
4. Is it a good idea for Microservices to share a common database?
5. How independent micro services communicate with each other / Inter-service
communication mechanisms?
6. How will you handle distributed transactions? [2PC, Saga]
7. What is CAP theorem?
8. What is Saga pattern?
9. How will you migrate SOA (Service Orientation Architecture) or monolithic application to
Microservices architecture? Elaborate with example
10. What are the challenges you face while working Microservice Architectures?
11. What are the components/artifacts you will bring in from the spring cloud library to
build your own microservices based application?
12. Elaborate on monitoring in microservices architecture?
13. How logging will take place in microservices?
14. How will you manage fault tolerance?
15. How will you test your code in microservices?
16. How does TDD work in a microservices architecture?
17. What is service registry?
18. What is the gateway?
19. How will you implement authentication in a microservice?
20. How can one manage the graph of dependencies between microservices?
21. How will you deploy microservices / How to manage CI/CD?
22. How to secure microservices
23. what is 3Scale
24. what is open apigee
25. Authentication
26. Authorization
27. Auth2
28. Swagger
29. Microservices Design pattern
Spring boot questionnaire

 What are the Spring framework modules?


 What bean scopes are supported by Spring and what do they mean? Which is used by
default?
 What is dependency injection (DI)? What are the types of DI?
 What is Inversion of Control concept, how does Spring support IOC?
 Describe the Spring bean lifecycle.
 Which steps of beans lifecycle can be overridden or controlled?
 What is a Spring Application Context? What are some example usages of one?
 In the context of Spring, what is a stereotype/annotation?
 How do you load and inject properties into a Spring Bean?
 What are the different ways to configure a class as Spring Bean?
 What is Bean wiring? How does auto wiring work?
 What is spring boot?
 What are the benefits of spring boot?
 What is spring-boot-starter-parent?
 What is auto configuration and how it works?
 How to disable specific auto-configuration in spring boot?
 What are Spring Boot Starter Projects?
 How to monitor a spring boot application?
 How to disable Actuator endpoint security in Spring Boot?
 How to reload my changes on Spring Boot without having to restart server?
 Have you written Test cases using Spring Boot?
 What is the annotation to mark class as a unit test case in spring boot?
 How to implement security for Spring boot application?
 What is Spring Profiles? How do you implement it using Spring Boot?
 How to enable Spring Framework’s caching support
 Why do we need spring-boot-maven-plugin?
 How can I enable auto reload of my application with Spring Boot?
 What and Why Embedded Servers?
 How to generate a WAR file with Spring Boot?
 What is AOP? How to use it with Spring Boot?
 What is Transactional annotation
 How is Hibernate chosen as the default implementation for JPA without any
configuration?
 Example to showcase scratch development of Spring boot application to process CRUD
operations with all the layers eg. REST-Business Service-Repository/DAO?
 What happened if database driver dependency is not defined in pom.xml?
 Spring cloud
 Spring Rest
 Spring Batch
 Spring JDBC
 JPA/ Hibernate
 Spring AOP
 About Spring ioc
 About Spring configuration
 About Spring boot
 What is the benefit of spring boot
 What is the need and use of microservices
 About Hibernate
 About Spring data
 How you can create a Spring Boot Project?
 Maven or Gradle? how you will add the dependencies (jars)
 Which approach will you go for a project? Traditional way or Spring boot application and
justify?
 How you will create a Spring Service?
 How you will expose a service (By service they meant Rest Service).
 How to give back a different type of response back to the client? XML and JSON
 How you will set up the Database connection in spring boot?
 Question-related Spring Core/SpringBoot/Spring Microservices/extension microservices
 Understanding of Git, Git Hub, CICD Jenkins, Cloud deployment (AWS, PCF, RedHat)
 Java 8 features,
 Lambda, Stream
 Exception handling
 Collection

Database questions:

 Explain the different steps in DB design.


 What is normalization? Why do we need to do normalization? Explain 1NF, 2NF, 3NF with example.
The truth, - the key
the whole truth, and – partial dependency
nothing but the truth – transitive dependency

Remove redundancy.

Trade off – increase execution time of queries. (Joins)

The more you differentiate, the more you will have to integrate.

 When do we have to do denormalization of DB?


 Explain the different types of joins available in RDBMS. (anti join, semi join) ex: cross join
 What is primary key, foreign key?
 What is a trigger?
 What is the difference between a stored procedure and a function?
 Difference between DDL, DML and DCL.
 CAP theorem

Facebook Server Facebook Server


 Drivers and types


 Practise SQL from https://www.w3resource.com/sql-exercises/
 Write query to eliminate duplicate records.
http://www.orafaq.com/wiki/SQL_FAQ#How_does_one_eliminate_duplicates_rows_from_a_table.3F
(very good resource for commonly asked SQL questions.
 Top N Queries: https://oracle-base.com/articles/12c/row-limiting-clause-for-top-n-queries-12cr1
 http://www.orafaq.com/wiki/SQL_FAQ - Practise all FAQ.
 Correlated subquery: https://en.wikipedia.org/wiki/Correlated_subquery
 UNION vs UNION ALL https://sqlandplsql.com/2012/06/22/difference-between-union-and-union-all-
clause-oracle/
 DECODE vs CASE: http://www.aliencoders.org/content/decode-vs-case-oracle-sql/
 NVL vs NVL2 vs COALESCE: http://awads.net/wp/2006/01/27/nvl-nvl2-or-coalesce/
 Truncate vs Delete: https://stackoverflow.com/questions/3256242/pros-cons-of-truncate-vs-delete-
from
 Clustered vs Non-clustered index: http://www.geekinterview.com/talk/11589-clustered-index-
nonclustered-index.html
 Tuning a slow correlated subquery tips:
http://www.dba-oracle.com/t_tuning_correlated_subqueries_for_fast_speed.htm
 Other SQL performance tuning: https://www.toptal.com/sql/sql-database-tuning-for-developers
 Transaction ACID properties: https://en.wikipedia.org/wiki/ACID
 ISOLATION levels: http://www.oracle.com/technetwork/testcontent/o65asktom-082389.html
 Materialized Views: http://www.acehints.com/2011/08/oracle-views-vs-materialized-views.html

You might also like