Wednesday, October 12, 2022

Java Interview Preparation: Architect, Senior Developer, Full Stack Developer

Coding round 

System Design round: 
Core Java Basic

  1.  JDK, JRE , JVM (https://medium.com/@ervinitraj/all-about-jvm-java-virtual-machine-bdeecd6eaa1d)
  2.  Java Acrhitecture
  3.  JVM Architecture
  4.  Classloader and its types (https://www.digitalocean.com/community/tutorials/java-classloader)
  5.  Local variable, instance variable, static variable difference?[https://stackoverflow.com/questions/18605974/static-initialization-block-vs-constructor-java]
  6.  Why java is not pure object oriented language
  7.  Object Oriented vs Object Based language
  8. Memory[memory]
  9.  Constructor (super, this) [https://www.digitalocean.com/community/tutorials/constructor-in-java, https://www.quora.com/How-does-a-constructor-work-internally-in-Java]
  10.  Characteristics of OOP (Encapsulation, Abstraction , inheritance, polymorphism) [https://www.freecodecamp.org/news/java-object-oriented-programming-system-principles-oops-concepts-for-beginners/]
  11.  Types of Polymorphism(static vs dynamic or overloading vs overrriding vs operator overloading) [https://www.geeksforgeeks.org/polymorphism-in-java/]
  12.  Covariant Type and contravarient type [https://medium.com/@alxkm/understanding-variance-in-java-covariant-and-contravariant-types-explained-31d569f2c9af]
  13. Interface vs Abstract
  14. Interface: default method, static methods, private method, marker[https://medium.com/@reetesh043/default-private-and-static-methods-in-java-interfaces-fcfe60693730]
  15. Exception Handling(checked and unchecked)[https://www.digitalocean.com/community/tutorials/exception-handling-in-java]
  16. String concept : [https://www.digitalocean.com/community/tutorials/java-string , https://medium.com/@tecnicorabi/understanding-strings-in-java-immutability-internals-and-the-string-pool-368ecbac5d3b]
  17. String Constant pool: [https://www.digitalocean.com/community/tutorials/what-is-java-string-pool]
  18. StringBuilder and StringBuffer [https://www.geeksforgeeks.org/string-vs-stringbuilder-vs-stringbuffer-in-java/]
  19. Equals vs ==
  20. Equals and Hashcode [https://howtodoinjava.com/java/basics/java-hashcode-equals-methods/]
  21. Inner Class and types [https://medium.com/@pratik.941/in-depth-tutorial-on-inner-classes-in-java-77f81207a3fc]
  22. Garbage Collection: Strategy and Types     [ Types: {Serial, parallel, CMS, G1}, Strategy: oldGen, young gen, permgen] [https://newrelic.com/blog/best-practices/java-garbage-collection#toc-java-garbage-collection-types-strategies , https://stackify.com/what-is-java-garbage-collection/]
  23. Serialisation and Deserialisation[Serial&Deserial]
  24. Reflection [https://www.programiz.com/java-programming/reflection]
  25. final, finally, finalize[final-java]
  26. transient,volatile[https://naveen-metta.medium.com/understanding-transient-and-volatile-variables-in-java-2af7bc534bde]
  27. native, strictfp[https://meghnadwivedi.medium.com/native-keyword-in-java-b0a711def0b1]
  28. Java: passby value[passbyvalue]
  29. fail-fast, fail-safe [fail fast safe]
  30. Comparable, comparator[https://medium.com/@ganesh.shah/comparator-vs-comparable-java-8-940a83f53bd3]
  31. Functional Programming: Supplier, Consumer, Predicate, Function[functional program]
  32. Aggregation vs composition vs Association[https://www.scaler.com/topics/association-composition-and-aggregation-in-java/]
  33. Thread [Introductionwait notify
  34. Runnable, Callable, Future, Executor
  35. Synchronisation
  36. 1LserialversionUID
  37. Concurrency
  38. Collection framework


Parallelstream vs stream
Functional Interface - custom 
java8 Collectors.groupingBy, distinct(), parrallelStream()


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
  • HashMap [https://medium.com/javarevisited/internal-working-of-hashmap-in-java-97aeac3c7beb,     https://www.codingninjas.com/codestudio/library/implementation-of-hashmap   ]  it adds at first position when duplicate index,  HashTable, Concurrent HashMap [array of linkedlist]
  • HashSet [ https://medium.com/javarevisited/internal-working-of-hashset-in-java-e8b171fa3d41 ] 
  • LinkedHashMap [https://anmolsehgal.medium.com/java-linkedhashmap-internal-implementation-44e2e2893036 ] work as double linkedlist [array of doublinkedlist] 
  • LinkedHashSet  [https://javaconceptoftheday.com/how-linkedhashset-works-internally-in-java/]
  •  TreeMap: internally uses RB Tree [https://medium.com/xebia-engineering/treemap-internals-199e0e0050b5]
  •  TreeSet: The data structure for the TreeSet is TreeMap; it contains SortedSet  & NavigableSet interface to keep the elements sorted in ascending order and navigated through the tree
https://javaconceptoftheday.com/synchronized-hashmap-vs-hashtable-vs-concurrenthashmap-in-java/



Thread and synchronization


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



Executors framework [https://howtodoinjava.com/java/multi-threading/executor-service-example/]
 executors vs executor

Future vs CompletableFuture


volatile keyword

concurrentmodification exceptio
unsupported operation exception


SOLID principle

 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





  1. Creational Design pattern:  are concerned with the way of creating objects. 
    Singleton, Builder, Factory pattern, Abstract Fcatory
    https://www.baeldung.com/creational-design-patterns

  2. Structural Design pattern : These patterns explain how to assemble objects and classes into larger structures while keeping these structures flexible and efficient.
    Adopter, Decorator, Facade, Composite, Bridge
    https://www.baeldung.com/java-core-structural-patterns

  3. Behavioural Design pattern : are concerned with the interaction and responsibility of objects.
    Observer, Iterator, ChainOfResponsibility, Strategy,Command
    https://www.baeldung.com/java-behavioral-patterns-jdk



Microservice Design Pattern



SAGA pattern:



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.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
Transaction Management in Spring: ACID property 
Spring’s @Transactional annotation ( Declarative Transaction Management )

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 

  [OAuth 2.0 is the industry-standard protocol for authorization. OAuth 2.0 focuses on client developer simplicity while providing specific authorization flows for web applications, desktop applications, mobile phones, and living room devices.]

4.  OAuth 2 protocol flow diagram:
 
https://www.digitalocean.com/community/tutorials/an-introduction-to-oauth-2


5.  Access Token and its types [Bearer token & Sender constrained token]

6. OAuth Grant types

The most common OAuth grant types are listed below.

Legacy
Auth granttype [web apps]
https://developer.okta.com/blog/2018/04/10/oauth-authorization-code-grant-type
PKCE [mobile apps]
https://medium.com/identity-beyond-borders/auth-code-flow-with-pkce-a75ee203e242
Client Credentials [servcie to servcie , internally]
https://www.oauth.com/oauth2-servers/access-tokens/client-credentials/
          Device Flow [authentication in smart tv , amazon ccount]
          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/


reverse proxy vs forward proxy




API gateway






























































No comments:

Post a Comment

Interview Prep: Java full stack

 SOLID principle :  https://www.educative.io/answers/what-are-the-solid-principles-in-java Design Pattern:  Creational:  https://medium.com...