Wednesday, October 12, 2022

Interview Preparation: Senior Developer, Full Stack Developer

Core Java Basic

  1.  JDK, JRE , JVM and architecture ( link)
  2.  Classloader and its types (link)
  3.  Java Args -X, -XX, -D link
  4. Java 8, 11, 17, 21 [LTS versions] best-link link link2
  5.  Java memory [young, old, meta] This is genrational memory mgmt  [link
  6. Memory managment in Java and GC[link
  7. Garbage collectors [ Types of GC:{Serial, parallel, CMS deprecated, G1GC[Default], ZGC, Shenandoah}] link
  8. G1GC(generational) vs ZGC(non generational memory mgmt, java 15) ?
  9. Thread Memory [thread memory
  10.  Local variable, instance variable, static variable difference?
  11.  Why java is not pure object oriented language
  12.  Object Oriented vs Object Based language
  13.  Constructor (super, this) [link1]
  14.  Characteristics of OOP (Encapsulation, Abstraction , inheritance, polymorphism) [link]
  15.  Composition(has-a, loose couple) vs Inheritance(is-a, tight coupled)[link]
  16. Aggregation vs composition vs Association[link]
  17.  Types of Polymorphism(static vs dynamic or overloading vs overrriding vs operator overloading) [link]
  18. Covariant Type and contravarient type [link]
  19. Interface vs Abstract
  20. Interface: default(java8) , private method(java9), static method(java9)  [link]
  21. Exception Handling(checked and unchecked link[link2]
  22. String Constant pool link
  23. StringBuilder and StringBuffer
  24. Equals vs == [link]
  25. Equals and Hashcode [link]
  26. Reflection [link]
  27. Deep cloning vs shallow cloning
  28. Atomic Integer, Atomic long, Atomic boolean, Atomic ref
  29. Record, sealed, var sealed record var
  30. Inner Class and types [link]
  31. Serialisation and Deserialisation [Serial&Deserial]
  32. 1LserialversionUID link
  33. enum enum
  34. final, finally, finalize[final-java]
  35. transient,volatile[link]
  36. native[linkstrictfp[redundant in java17]
  37. Java: passby value[passbyvalue]
  38. fail-fast, fail-safe [fail fast safe] [collection is fail fast]
  39. Process vs task link
  40. Thread [Introductionwait notify 
  41. Executor framework link
  42. ForkJoin vs ExecutorService link
  43. Runnable vs Callable (Thread)
  44. Future vs CompletableFuture(Thread result async)
  45. Functional Programming: Supplier, Consumer, Predicate, Function[functional program]
  46. Create singleton class while preventing reflection api link
  47. Comparable, comparator[linklink2
  48. Parallelstream vs stream link
  49. java8 flatmap [listoflist to list] link
  50. list to map in java 8+
  51. java8 stream().collect()::::: toMap,toSet link
  52. java8 Collectors [groupingby vs toMaplink
  53. Collectors partitionBy link
  54. Streams.sorted(), Collections.sort link
  55. Arrays.fill, Arrays.sort  link
  56. Character to int conversion and vice versa link
  57. Collections, Collectors, Arrays,Math,Character
  58. ASCII value of a=97, A=65;

Collection Framework

  • Basic Into link
  • HashTable [link] thread safe, method lock
  • HashMap link1, link2  {uses linkedlist, then RB tree, not threadsafe hashtable}
  • HashSet [link ]
  • LinkedHashMap [link ] work as double linkedlist [array of doublinkedlist], maintain order
  • LinkedHashSet [link]
  • ConcurrentHashmap [link] is an extension of hashtable with better synchronised version than hashtable[segment lock instead of methd or block lock]
  • TreeMap: internally uses RB Tree [link]
  • 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.
  • Why hashmap with custom key object immutable?? For sorting hashmap has customer object as key should be immutable object because of this reason string is preferred as key
  • Sort hashmap by values.link
  • Hashtable{method level locl} vs synchronisedhashMap{block level lock also supported} vs concurrenthashmap{segment lock} vs linkedhashmap vs treemap link
  • Heap data structure[min heap and max heap]
  • PriorityQueue is important data structure[default is min heap, use arraylist internally] link

 

Thread and synchronization
  • Basic Intro link with detail
  • Concurrency vs Parallelism [link
  • Types of synchronisation: static sync, sync block, sync method
  • Object: wait, notify, notifyAll.  [Inter Thread communication link]
  • Thread: yield, join link.  
  • Threadpool example link
  • Two thread accessing synchronise method
  • Cyclic Barrier vs CountDownLatch link

Concurrency
    • Basic link
    • Executors framework link
    • Executors vs executor
    • Concurrentmodification exception
    • Unsupported operation exception
    • Future vs CompletableFuture link



Association: Simple relationship; objects can exist independently.
Aggregation: A weak relationship where one object contains another but the contained object can exist independently.
Composition: A strong relationship where one object contains another, and the contained object cannot exist without the container.
Inheritance: A class inherits properties and behavior from another class.

********************************************************************************

Spring Boot Framework


  • Sync, Async, Reactive programming
  • Spring IOC container(ApplicationContext interface) link
  • Dependency Injection  types: constructor, setter, field based DI
  • Bean scopes link1  link2
  • Bean lifecyle link
  • Dispatcher servlet link
  • @Controller, @RestController, @Service,@Repository link
  • Lazy loading link
  • Spring multiple datasource link link2 link3
  • Load time invoking functionality link2 link1 
  • Spring webflux link link2 
  • How to create custom annotation in spring boot?
  • how to implement rate limiter in spring boot
  • How to implement security in spring boot?
  • Spring JPA link link2 [used for JDBC]
  • Spring R2dbc link link [prefered ]
  • Spring Webclient link
  • Spring transaction mgmt link
  • Spring batch processing link link2
  • Spring logging framework(logback is default) link
  • Spring exception handling link
  • Spring testing framework link
  • @Springbootapplication annotation  
     @EnableAutoConfiguration,@ComponentScan,@Configuration
  • Spring swagger [openapi documentation- latest] link
  • Spring redis link1  lettuce link 2
  • Spring kafka link
  • Spring AOP link
  • Spring boot security with JWT link
  • Spring security  intro basic  weblfux oauth2 jwt 
  • Put vs post vs patch link
  • Commandline runner vs Applicationrunner link
  • Spring elastic searchlink
HTTP status code 100, 101, 200x, 300x, 400x
How do you disable default Tomcat embedded server and  use jetty(spring boot), netty(webflux) and why?
if resources in microservice are underutilised, how should we customise http connection pool?
How do you setup monitoring of web application?What all stats you observe?
How do you implement distributed tracing and further trace  any request  which spans across multiple microservice?

Micrometer(health stats)
opentelemetry(tracing)
*********************************************************************************


Authentication & Authorisation Framework


  • Resource server, client server, Authorisation service 
  •  OAuth2 is an Authorisation framework whereas,
     OpenId is layer on top of oauth2 to provide authentication (Authentication + Authorisation ). 
  • OAuth Grant types:
  • JWT  [Its format of token used, can be used in Authentication and authorization, auth code , accesstoken are sent as jwt tokenlink. Other token can be opaque token. JWT is self contained token
  • Claims in JWT(registered, public, private)
  • Client side best practice for cookie link [Since we are trying to protect our application as much as possible from hacking, we must store our refresh token exclusively in an HttpOnly Cookie.]

    Note: 



Authentication Framework

 Authentication vs Authorisation

 Application in Microservice : 

https://medium.com/geekculture/securing-your-microservices-architecture-with-spring-boot-an-in-depth-guide-to-authentication-and-d4acd8cf7efb

https://medium.com/javarevisited/spring-boot-authorization-creating-an-authorization-server-for-your-microservices-50a3aefd6ce8


******************************************************************************

React and Redux


  • Hello world Concept example webpack example
  • React VirtualDom link
  • Virtual DOM vs Shadow DOM link
  • Reconciliation: diffy algo in fibre node
  • Higher order components link
  • hoisting link
  • let vs var link [hoisting happens in var]
  • API call (axios) link
  • Webpack link link2
  • Babel link  
  • useMemo, useCallback, useContext link
  • Redux::: action , store, dispatcher, reducer [useReducer] Explaination
  • CORs for protection
  • Testing framework for FE testinglib link enzyme
  • React vs Angular vs vue link
  • Typescript link
  • Microfrontend design link Eg:Module federation, single-spa
  • Def between useRef and useState link [useref doesnt cause re rerendering of page]
  • useMemo vs useCallback [useCallback hook memoizes function itself, not its return value like use memo]
  • type vs interface in typescript
  • interface vs class
    Testing framework FE
    • Jest: Best for unit testing and snapshot testing with easy configuration
    • Mocha: Best for flexible, customizable test setups with asynchronous support
    • Enzyme: Best for testing React component internals with shallow and full rendering
    • TestCafe: Best for cross-browser testing and end-to-end testing with simple setup
    • Jasmine: Best for behavior-driven development (BDD), focusing on simplicity
    • Chai: Best for expressive assertions in tests using BDD/TDD style
    • Cypress: Best for fast, reliable end-to-end testing with real-time browser interaction
    • Puppeteer: Best for headless browser automation and UI testing
    • React Testing Library: Best for testing React components through user interactions
    • Sinon: Best for mocking, spying, and stubbing external dependencies in tests
    • Nightwatch.js: Best for simple end-to-end testing with WebDriver integration
    • QUnit: Best for straightforward unit testing, especially in legacy projects
    • Storybook: Best for visually testing and documenting UI components in isolation
    • Ava: Best for fast, concurrent testing with minimal configuration
    • Detox: Best for end-to-end testing of mobile apps, particularly React Native, with fast test execution.
Note- The algorithm React uses to diff one tree with another to determine which parts need to be changed also k/a reconciliation. .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.
 
   React virtual DOM uses Fibre node as internal data structure. Its a tree of single linkedlist node
 npx webpack --env prod

 

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

SQL 

  • Groupby and having  link
  • Explain the differences between SQL and NoSQL databases.
  • Types of join link
  • SQL vs PSQL vs TSQL link
  • Unique key vs Primary key
  • Where vs Having in sql
  • Delete, truncate, drop [Drop removes table structure as well, truncate for all data]
  • SQL INTO
  • Nth highest salarylink
  • On delete cascade
  • How do you optimize SQL queries? link1 link2
  • How do u handle transaction in distributed system [SAGA, 2PC]
  • How do you prevent SQL injection link
  • Concept of sharding link
  • Concept of partitioning link
  • SQL concept quesn link
  • SQL query query interview
  • SQL query to find last 3 month data 
  • JOIN is a shorthand for INNER JOIN in PostgreSQL
  • How to choose right DB ? link

SELECT
FROM
WHERE
GROUP BY
HAVING
ORDER BY



Question:

You are given 2 database table. First table named as 'goals' with fields as goal_id, player_id, team_id, goal_time.

Second table names as 'teams' with field name as team_id, team_name.

Write a sql query to fetch the name of all teams that scored atleast one goal within 30sec of time and also corresponding count count of goals with respect to teamYou are given 2 database table. First table named as 'goals' with fields as goal_id, player_id, team_id, goal_time.

Second table names as 'teams' with field name as team_id, team_name.

Write a sql query to fetch the name of all teams that scored atleast one goal within 30sec of time and also corresponding count count of goals with respect to team . Also show result in order of highest goal to lowest in descending order


Ans:

SELECT
t.team_name,
COUNT(g.goal_id) AS goal_count
FROM
goals g
JOIN
teams t ON g.team_id = t.team_id
WHERE
g.goal_time <= 30
GROUP BY
t.team_name
HAVING
COUNT(g.goal_id) >= 1
ORDER BY
goal_count DESC;




SELECT column1, column2, ... INTO new_table_name FROM existing_table WHERE condition;

SELECT employees.emp_name, departments.dept_name FROM employees JOIN departments ON employees.dept_id = departments.dept_id; 


Note:
Managing large-scale databases for performance involves various strategies, including proper indexing, partitioning, query optimization, hardware optimization, and caching. Monitoring and fine-tuning the database is crucial to ensure optimal performance as data volumes grow.

Ensuring data availability and disaster recovery relies on the implementation of vital backup and recovery strategies. These strategies encompass various methods, such as full backups, differential backups, transaction log backups, and regular testing of restoration procedures.

NoSQL databases are non-relational databases designed for handling large volumes of unstructured or semi-structured data. They interact with SQL databases through various integration methods, such as data pipelines, ETL processes, and API-based data transfers

Advanced optimization techniques for SQL queries include using query hints, indexing strategies, query rewriting, and understanding the query execution plan. Profiling tools and performance monitoring are essential for identifying and resolving performance bottlenecks

The INTO clause creates a new table, not just inserts data into an existing one 

*******************************************************************************

Security in Web Application



*************************************************

SOLID principle


Single Responsibility Principle

Each class should be responsible for a single part or functionality of the system

Open-Closed Principle

Software components should be open for extension, but not for modification.

Liskov Substitution Principle

Objects of a superclass should be replaceable with objects of its subclasses without breaking the system.

Interface Segregation Principle

No client should be forced to depend on methods that it does not use.

Dependency Inversion Principle

High-level modules should not depend on low-level modules, both should depend on abstractions.

Explain with Eg: Vechile, Bank link
                                          

*************************************************


Design Pattern in Java(GOF pattern) 

Design patterns are typical solutions to commonly occurring problems in software design. They are like pre-made blueprints that you can customize to solve a recurring design problem in your code. Usage examples in java  link 

  1. Creational Design pattern:  are concerned with the way of creating objects.
    Singleton, Builder, Factory pattern, Abstract Fcatory link link2

  2. Structural Design patternThese patterns explain how to assemble objects and classes into larger structures while keeping these structures flexible and efficient.
    Adopter, Decorator, Facade, Composite, Bridge, flyweight design pattern  link

  3. Behavioural Design patternare concerned with the interaction and responsibility of objects.
    Observer, Iterator, ChainOfResponsibility, Strategy, Command link

     Extralink





Microservice Design Pattern

Microservices is an architectural style for building applications as a collection of independent services. Each service is built and deployed independently, and can be scaled independently



use chatgpt directly to study about all

     

*************************************************
12 factor Apps




*************************************************

System Design round

************************************************


Additional Topic Note:

  • Architect Interview javafungus
  • Data Engineering javafungus
  • Databases javafungus
  • Reverse proxy vs forward proxy
  • Brownfield vs greenfield microservice app development
  • KISS, DRY, SOLID, YAGNI link
  • Code review link
  • Component Cohesion & Coupling link
  • Implement OAuth 2.0 authentication for a Spring Boot REST API using JWT tokens

  • Name any recent cyberattack you heard of






























































Web application Security and underlying concepts

Let's break down how to learn about web application certificates and the underlying security concepts. Here's a suggested order and ...