Core Java
Basic
- JDK, JRE , JVM
- Java Acrhitecture
- JVM Architecture
- Classloader and its types
- Local variable, instance variable, static variable difference?
- Why java is not pure object oriented language
- Object Oriented vs Object Based language
- Constructor (super, this)
- Characteristics of OOP (Encapsulation, Abstraction , inheritance, polymorphism)
- Types of Polymorphism(static vs dynamic or overloading vs overrriding)
- Covariant Type
- Interface vs Abstract
- Interface: default and static methods
- Exception Handling(checked and unchecked)
- String concept : String constant pool [https://study.com/academy/lesson/java-string-constant-pool-concept-mechanism.html]
- StringBuilder and StringBuffer
- Equals vs ==
- Equals and Hashcode
- Inner Class and types
- Garbage Collection: Strategy and Types [ Types: {Serial, parallel, CMS, G1}, Strategy: oldGen, young gen, permgen]
- Serialisation and Deserialisation
- Reflection
- final, finally, finalize
- transient,volatile
function, supplier, consumer, runnable, callable, comparable, comparator, fail-fast, fail-safe
Parallelstream vs stream
FunctionalInterface - custom
immutability and final classes
Memory: https://www.guru99.com/java-stack-heap.html
java8 Collectors.groupingBy, distinct(), parrallelStream()
try with resources
Aggregation vs composition vs Association
Collection Framework
https://dotnettutorials.net/lesson/java-collections-framework/
Sort hashmap with custom key object. hashmap has customer object as key then immutable object. Because of this reason string is preferred as key
Sort hashmap by values
synchronised hashmap vs concurrent hashmap
LinkedHashmap maintiains order
TreeMap maintains sorting order
Also, see internal working of following
https://javaconceptoftheday.com/synchronized-hashmap-vs-hashtable-vs-concurrenthashmap-in-java/
Thread and synchronization
https://dotnettutorials.net/lesson/multithreading-in-java/
types of synchronisation: static sync, sync block, sync method
Object: wait, notify, notifyAll. [Inter Thread communication]
Thread: yield, join. [https://howtodoinjava.com/java/multi-threading/difference-between-yield-and-join-in-threads-in-java/]
[The join() method of a Thread instance can be used to “join” the start of a thread’s execution to the end of another thread’s execution so that a thread will not start running until another thread has ended. If join() is called on a Thread instance, the currently running thread will block until the Thread instance has finished executing].
https://dotnettutorials.net/lesson/inter-thread-communication-in-java/
https://www.interviewbit.com/multithreading-interview-questions/
Example of inter thread communication
Threadpool example
Two thread accessing synchronise method
Cyclic Barrier vs CountDownLatch
Concurrency
https://www.baeldung.com/java-util-concurrent
https://howtodoinjava.com/series/java-concurrency/.
Executors framework [https://howtodoinjava.com/java/multi-threading/executor-service-example/]
executors vs executor
Future vs CompletableFuture
https://www.topcoder.com/thrive/articles/synchronization-and-object-lock-part-2
volatile keyword
concurrentmodification exceptio
unsupported operation exception
SOLID principle
https://www.educative.io/answers/what-are-the-solid-principles-in-java
Eg: Vechile, Bank
Liskov subsistition ::
Bad example
public class Bird{
public void fly(){}
}
public class Duck extends Bird{}
The duck can fly because it is a bird, but what about this:
public class Ostrich extends Bird{}
Ostrich is a bird, but it can't fly, Ostrich class is a subtype of class Bird, but it shouldn't be able to use the fly method, that means we are breaking the LSP principle.
Good example
public class Bird{}
public class FlyingBirds extends Bird{
public void fly(){}
}
public class Duck extends FlyingBirds{}
public class Ostrich extends Bird{}
Design Pattern in Java
- Creational Design pattern: are concerned with the way of creating objects.
Singleton, Builder, Factory pattern
https://www.baeldung.com/creational-design-patterns
- Structural Design pattern : These patterns explain how to assemble objects and classes into larger structures while keeping these structures flexible and efficient.
Adopter, Decorator, Composite, Bridge
https://www.baeldung.com/java-core-structural-patterns
- Behavioural Design pattern : are concerned with the interaction and responsibility of objects.
Strategy,Command,Observer, ChainOfResponsibility
https://www.baeldung.com/java-behavioral-patterns-jdk
https://refactoring.guru/design-patterns/catalog
https://www.digitalocean.com/community/tutorials/strategy-design-pattern-in-java-example-tutorial
https://www.digitalocean.com/community/tutorials/command-design-pattern
Microservice Design Pattern
https://www.tutorialspoint.com/microservices_design_patterns/microservices_design_patterns_decompose_by_business_capability.htm
SAGA pattern:
https://www.baeldung.com/cs/saga-pattern-microservices#:~:text=What%20Is%20Saga%20Architecture%20Pattern,back%20by%20a%20compensating%20transaction.
https://stackoverflow.com/questions/4127241/orchestration-vs-choreography
brownfield vs greenfield microservice app development
12 Factor App
https://www.theserverside.com/feature/How-to-build-a-Spring-Boot-12-Factor-app
https://www.baeldung.com/spring-boot-12-factor
Spring Framework
1. Spring IOC container(acheived by Dependency Injection)
2. Types of IOC Container [BeanFactory and ApplicationContext]
3. bean vs Component
4. Dependency Injection: Dependency injection enables you to turn regular Java classes into managed objects and to inject them into any other managed object. Using dependency injection, your code can declare dependencies on any managed object.A dependency injection is a strategy that is used to separate the creation of dependency objects from the class that needs them.
5. Types of Dependency Injection[2 types: constructor and method or field based DI]
6. Bean scopes [5 types: singleton, prototype, session,request, global session]
7. Dispatcher servlet and flow
8. Spring modules worked on?
9. Spring JPA, SpringAOP, Spring Batch,Spring Security,Springn cloud,Springreactive
10. Spring JDBC API
11. Spring reactive
12. @Controller, @RestController, @Service,@Repository(difference why we use difffernt annotation )
13. Spring swagger
14. How spring security added
15. how to read property
hibernate basics
bean lifecycle:
@PostConstruct
@PreDestroy
Hibernate and JPA
https://howtodoinjava.com/spring-mvc/contextloaderlistener-vs-dispatcherservlet/
spring with jwt
https://youtu.be/X80nJ5T7YpE
@EnableAutoConfiguration vs @Component
Asynchronour programming in spring boot:
https://dzone.com/articles/spring-boot-creating-asynchronous-methods-using-as
https://springhow.com/spring-async/
JPA Vs Hibernate
Following table summerises the differences between JPA and Hibernate.
Category | JPA | Hibernate |
---|
Type | JPA is a specification and defines the way to manage relational database data using java objects. | Hibernate is an implementation of JPA. It is an ORM tool to persist java objects into the relational databases. |
Package | JPA uses javax.persistence package. | Hibernate uses org.hibernate package. |
Factory | JPA uses EntityManagerFactory interface to get the entity manager to persist objects. | Hibernate uses SessionFactory interface to create session object which is then used to persist objects. |
CRUD Operations | JPA uses EntityManager interface to create/read/delete operation and maintains the persistence context. | Hibernate uses Session interface to create/read/delete operation and maintains the persistence context. |
Language | JPA uses JPQL (Java Persistence Query Language) as Object Oriented Query language for database operations. | Hibernate uses HQL (Hibernate Query Language) as Object Oriented Query language for database operations. |
Transaction Management in Spring: ACID property
https://www.marcobehler.com/guides/spring-transaction-management-transactional-in-depth
How to use Spring’s @Transactional annotation ( Declarative Transaction Management )
Now let’s have a look at what modern Spring transaction management usually looks like:
public class UserService {
@Transactional
public Long registerUser(User user) {
// execute some SQL that e.g.
// inserts the user into the db and retrieves the autogenerated id
// userDao.save(user);
return id;
}
}
How is this possible? There is no more XML configuration and there’s also no other code needed. Instead, you now need to do two things:
Make sure that your Spring Configuration is annotated with the @EnableTransactionManagement annotation (In Spring Boot this will be done automatically for you).
Make sure you specify a transaction manager in your Spring Configuration (this you need to do anyway).
And then Spring is smart enough to transparently handle transactions for you: Any bean’s public method you annotate with the @Transactional annotation, will execute inside a database transaction (note: there are some pitfalls).
So, to get the @Transactional annotation working, all you need to do is this:
@Configuration
@EnableTransactionManagement
public class MySpringConfig {
@Bean
public PlatformTransactionManager txManager() {
return yourTxManager; // more on that later
}
}
Now, when I say Spring transparently handles transactions for you. What does that really mean?
Armed with the knowledge from the JDBC transaction example, the @Transactional UserService code above translates (simplified) directly to this:
public class UserService {
public Long registerUser(User user) {
Connection connection = dataSource.getConnection(); // (1)
try (connection) {
connection.setAutoCommit(false); // (1)
// execute some SQL that e.g.
// inserts the user into the db and retrieves the autogenerated id
// userDao.save(user); <(2)
connection.commit(); // (1)
} catch (SQLException e) {
connection.rollback(); // (1)
}
}
}
This is all just standard opening and closing of a JDBC connection. That’s what Spring’s transactional annotation does for you automatically, without you having to write it explicitly.
This is your own code, saving the user through a DAO or something similar.
Authentication Framework
For security we use Spring Security framework (and also we must know JAAS also exists). There are many other as well.
1. Difference between authentication and authorisation
2. OAuth : standard authentication and authorisation framework or protocol.
3. OAuth1 vs OAuth 2
https://www.oauth.com/oauth2-servers/device-flow/token-request/
7. JWT Structure [https://jwt.io/introduction]. Explain how it is implemented in java
8. JWT vs Oauth 2.0 Access token. [JWT defines a token format while OAuth deals in defining authorization protocols. JWT is simple and easy to learn from the initial stage while OAuth is complex. OAuth uses both client-side and server-side storage while JWT must use only client-side storage. JWT has limited scope and use cases.]
9. OpenId Connect [There is one more way to combine JWT and OAUth2. You need to guide OAuth2 to issue two tokens. The first token should be access_token and the second token should be a JWT token featuring additional identity details. While you plan to adopt this way to combine JWT and OAuth2, you need to make sure that you’re using OpenID Connect.]
Also read SAML, SWT
Data Structure
bigocheatsheet.com
time complexity of arraylist, linkedlist , hashmap : CRUD operation
Tree :
https://towardsdatascience.com/8-useful-tree-data-structures-worth-knowing-8532c7231e8c
https://www.scaler.com/topics/binary-tree-implementation-in-java/
Graph:
https://www.simplilearn.com/tutorials/data-structure-tutorial/graphs-in-data-structure#types_of_graphs_in_data_structures
https://www.programiz.com/java-programming/examples/graph-implementation
traversal in graph:
BFS
DFS
https://www.geeksforgeeks.org/difference-between-bfs-and-dfs/
https://www.baeldung.com/java-graphs. How to implement
Sorting and Searching Algorithm
Searching : https://stackabuse.com/search-algorithms-in-java/
Sorting : https://www.tutorialspoint.com/data_structures_algorithms/sorting_algorithms.htm
https://www.codingninjas.com/codestudio/library/sorting-in-data-structure-categories--types
Sorting problem:
Merge Sort: https://www.geeksforgeeks.org/merge-sort/ [if confusion in value of k then use another link where it refers to p, https://www.programiz.com/java-programming/examples/merge-sort]
Bubblesort: https://www.javatpoint.com/bubble-sort-in-java
HeapSort: Min heap n max heap
React Interview question
VirtualDom vs Dom
Redux::: action , store, dispatcher, reducer [notebook]
webpack, babel
typescript scope
let const var
how to make call
React Virtual DOM and its internal
lifecycle of react : https://www.w3schools.com/react/react_lifecycle.asp
CORs for protection
webpack bundle file configuration
React vs Angular analysis
Higher order components
useRef
useMemo vs useCallback
Context API: use Context https://beta.reactjs.org/apis/react/useContext
useReducer
Typescript
reconciliation: The algorithm React uses to diff one tree with another to determine which parts need to be changed.
const Dashboard = () => {
const [tableData, setTableData] = useState();
const [showError, setShowError] = useState(false);
const [loading, setLoading] = useState(false);
useEffect(() => {
fetchListData();
}, [])
const fetchListData = async () => {
setLoading(true);
setShowError(false);
await axios.get("/ims/dashboard/",
{headers: {'Accept-Type': 'application/json'}})
.then((res) => {
setTableData(res.data);
setLoading(false);
})
.catch((err) => {
console.log(err)
setShowError(true);
setLoading(false);
});
}
return <>
{showError && <Alert />}
<CustomizedTables rows={tableData} isLoading={loading}/>
</>
}
export default Dashboard;
custom hook: https://www.w3schools.com/react/react_customhooks.asp
JavaScript is a dynamically typed language. In a dynamically typed language, the type of a variable is checked during run-time in contrast to a statically typed language, where the type of a variable is checked during compile-time.
In JavaScript, primitive data types are passed by value and non-primitive data types are passed by reference.
Functions that operate on other functions, either by taking them as arguments or by returning them, are called higher-order functions.
Memoization is a form of caching where the return value of a function is cached based on its parameters. If the parameter of that function is not changed, the cached version of the function is returned.
https://www.simplilearn.com/tutorials/reactjs-tutorial/reactjs-interview-questions
https://www.freecodecamp.org/news/var-let-and-const-whats-the-difference/
****************************************************************************************************************************************************************************************************************************************************************************************************************************************************
Performance Improvment in Microservices
https://www.jrebel.com/blog/performance-problems-with-microservices
https://dzone.com/articles/performance-patterns-in-microservices-based-integr
Security in microservices architecture
https://www.okta.com/resources/whitepaper/8-ways-to-secure-your-microservices-architecture/
https://owasp.org/www-pdf-archive/Microservice_Security.pdf
C's Of Security: code, container, cluster, and cloud/co-lo/ corporate datacenter.
Coding
force push code from backend to frontend : https://stackoverflow.com/questions/34388614/how-to-force-update-single-page-application-spa-pages
How to spin frontend standalone as microservice
Loadbalancer vs API gateway
Use another server instead of tomcat in spring
how to use cache and types of cache: local n remote cache Eg
Implementation of rabbitMQ
customer object as key in hashmap? condition : make it immutable
two instance object acccesing synchronied method: both can run at sametime. make it static
java stream API performance comparison with normal for loop
Java API gateway
Frontend App Tuning
Query Performance tuning : https://mode.com/sql-tutorial/sql-performance-tuning/
Partitioning Postgresql for storing data : https://hevodata.com/learn/postgresql-partitions/
Multistage docker file for making hosting react app in docker image with nginx server
CloudFare as entry point . Its A DNS service
Virtualisation vs Containerisation:
https://middleware.io/blog/containerization-vs-virtualization/
Proxy vs Reverse proxy vs Loadbalancer
Ingress Vs loadbalancer: https://www.baeldung.com/ops/kubernetes-ingress-vs-load-balancer
Example of event sourcing:
Event Sourcing is a pattern for storing data as events in an append-only log. This simple definition misses the fact that by storing the events, you also keep the context of the events; you know an invoice was sent and for what reason from the same piece of information.
Good examples for Event Sourcing are version control systems that stores current state as diffs.
Scaling of microservces
1. Horizontal scaling
2. Vertical scaling
Loadbalancer and consistent hashing
Http add security -> Https
flatMap in java : list of list to list , List::Stream
indexing in database, composite index, covering index
configuring security in API
Static memeber can be overloaded or overriden or inherited
Database
How to update millions of record in Db without loosing data
how Db instances remains in sync
how global variables maintain values across different nodes
how to perform sharding
How to limit no of request per second in spring boot.
How events are sent to MQ
How distributed caching works
Refresh token scope and how to update confiugration at runtime in spring boot
CorelationId in log4j.xml. https://plrogoman.wordpress.com/2015/05/13/log4j-adding-a-correlation-id-to-your-logs/
Concept of MDC in logging
HPA in k8s for autoscaling
Caching: write thru vs write back
Queue: Failure of message queue, RabbitMQ(lucene or inverting indexing), how indexes created.
loadbalalncer algorithms
OOPs Design Principle :: DRY, KISS, YAGNI