Knowledge Transfer

Ethickfox kb page with all notes


Project maintained by ethickfox Hosted on GitHub Pages — Theme by mattgraham

https://github.com/enhorse/java-interview

[!info] Top 133 Java Interview Questions Answers for 2 to 5 Years Experienced Programmers
A blog about Java, Programming, Algorithms, Data Structure, SQL, Linux, Database, Interview questions, and my personal experience.
https://javarevisited.blogspot.com/2015/10/133-java-interview-questions-answers-from-last-5-years.html#axzz87MBt6KUn

Java

Core

Core

Generics

Java8

JVM

Java_Versions

Concurrency

Thread API

Executors

Synchronization

Atomic

Collections

Locks

JMM

Issues

producerconsume

Collections

Untitled

**Collection**: An interface representing an unordered "bag" of items, called "elements". The "next" element is undefined (random).

Build Tools

Maven

Gradle

Spring

Spring Core

Spring Core

Spring AOP

Spring Boot

Boot

Spring Boot is essentially a framework for rapid application development built on top of the Spring Framework. With its auto-configuration and embedded application server support

Features:

Difference with Spring

Spring Boot makes configuring a Spring application a breeze.

Here are two of the most important benefits Spring Boot brings in:

Starters

There are more than 50 starters at our disposal. Here, we’ll list the most common:

Auto-configuration

SpringBootApplication annotation can be used to enable those three features, that is:

Applications using DevTools restart whenever a file on the classpath changes. This is a very helpful feature in development, as it gives quick feedback for modifications.

Spring Boot Actuator can expose operational information using either HTTP or JMX endpoints. But most applications go for HTTP, where the identity of an endpoint and the /actuator prefix form a URL path.

Here are some of the most common built-in endpoints Actuator provides:

Spring MVC supports:

Spring WebFlux supports:

Spring Data

Spring MVC

MVC

Spring Security

Spring- Spring Security

[!info] Spring Security Custom Logout Handler | Baeldung
Learn how to implement a Custom Logout Handler using Spring Security.
https://www.baeldung.com/spring-security-custom-logout-handler

[!info]

https://www.interviewbit.com/spring-security-interview-questions/?utm_source=pocket_saves

46.png

Spring Tests

[!info] Testing in Spring Boot | Baeldung
Learn about how the Spring Boot supports testing, to write unit tests efficiently.
https://www.baeldung.com/spring-boot-testing

Integratrion tests

When running integration tests for a Spring application, we must have an ApplicationContext.

@SpringBootTest - creates an ApplicationContext from configuration classes indicated by its classes attribute. In case the classes attribute isn’t set, Spring Boot searches for the primary configuration class.The search starts from the package containing the test until it finds a class annotated with @SpringBootApplication  or @SpringBootConfiguratio

Spring Cloud

[!info]

https://www.interviewbit.com/spring-interview-questions/?sign_up_medium=ib_article_auth_blocker

[!info] Top Spring Framework Interview Questions | Baeldung
A quick discussion of common questions about the Spring Framework that might come up during a job interview.
https://www.baeldung.com/spring-interview-questions

[!info] bliki: Inversion Of Control
a bliki entry for Inversion Of Control
http://martinfowler.com/bliki/InversionOfControl.html

../Java/Frameworks/Spring/Spring

https://www.baeldung.com/spring-interview-questions#:~:text=• Java Concurrency Interview Questions (%2B Answers)

Algorithms

[!info] Explore - LeetCode
LeetCode Explore is the best place for everyone to start practicing and learning on LeetCode.
https://leetcode.com/explore/interview/card/cheatsheets/720/resources/4725/

[!info] Core Java Interview Questions and Answers (2024) - InterviewBit
Learn and Practice on almost all coding interview questions asked historically and get referred to the best tech companies
https://www.interviewbit.com/java-interview-questions/#java-program-to-check-palindrome-string-using-recursion

Sorting algorithms

All major programming languages have a built-in method for sorting. It is usually correct to assume and say sorting costs O(n * logn) is the number of elements being sorted. For completeness, here is a chart that lists many common sorting algorithms and their completeness.

Untitled3.png

Sorting

Search algorithms

Search

Data Structures

43.png

Here's an example of a task:

Question: what will be returned as a result?

class Pojo{
private String value;
private Integer length;

public String getValue(){
return value;
}

public void setValue(String value){
this.value = value;
}

//getter, setter for length

public static void main(String[] args){
Map<Pojo, Integer> map = new HashMap();
Pojo key = new Pojo();
key.setValue("abc");
map.put(key, 1);
key.setLength(3);
Integer result = map.get(key);
System.out.println(result);
}
}

|

This question is quite simple but extensive. Candidates of any seniority level will find something to offer as an answer.

Candidates frequently think that the answer to this task is "1". Their argument: hashcode equals is not overridden and will be used from the basic class, Object, which doesn't have mentioned fields. In response to this answer, the interviewer may ask: how can we change the Pojo class so that this code works for us on the client-side?

Most candidates suggest defining equals and hashcode. Once we have defined equals and hashcode, we will always get "null". Null will be returned just because we changed the Length and an Object is mutable.

Though it's not a difficult question, some candidates need to iterate over the code, go through all the points, calculate, and see that hashcode will get modified and we will not find an Object.

This leads to the problem of immutability, and the goal of identifying the ways to safely use Pojo. A candidate might suggest using finals at the beginning, because there is no access modifier.

final class Pojo{
private String value;
private Integer length;

public String getValue(){
return value;
}

public void setValue(String value){
this.value = value;
}

//getter, setter for length
//hascode and equals

public static void main(String[] args){
Map<Pojo, Integer> map = new HashMap();
Pojo key = new Pojo();
key.setValue("abc");
map.put(key, 1);
key.setLength(3);
Integer result = map.get(key);
}
}

When this class becomes immutable, the task can be slightly changed: Instead of the string value, let's insert a mutable Object, for example, Date or another mutable class. Then the questions are: what will happen now, how will this work, and is there any problem?

The candidate may suggest using either copying or cloning. If so, it might be a good idea to play around with cloning and exceptions as necessary. Cases are different and candidates may resolve this task differently as well.

final class Pojo{
private final Date value;
private final Integer length;

public Pojo(Date value, Integer length) {
this.value = value;
this.length = length;
}
public Date getValue(){
return value; 
}

//getter for length, equals, hashcode 

public static void main(String[] args){
Map<Pojo, Integer> map = new HashMap();
Pojo key = new Pojo(new Date(), 3);
map.put(key, 1);
key.getValue().setTime(123);
Integer result = map.get(key);
}
}

This is how the interviewer may cover data structures using the example of HashMap, which is probably the most commonly used. If a candidate is open to talking about algorithmic problems, the interviewer may suggest taking a look at the nuances of HashMap.

In any case, any advanced Java interview questions within a practical task are designed to respond to a candidate's experience and interest. The interviewer's aim is not so much to spot knowledge gaps as it is to reveal areas that a candidate is interested in and evaluate the depth and breadth of their knowledge.

Interviewers say that a readiness to get to the code is one of the key skills to check. This helps to assess how a candidate may deal with an unknown problem or a new task moving forward.

Algorithms

Architecture

Web Architecture

Something very important to know about is Microservices. There are many frameworks out there that will help you build, deploy, monitor and interact with Microservices. Master at least one REST framework (Spring Boot, Play, DropWizard etc.). Make sure you are aware of concepts like scaling and resilience, event-driven architectures, and asynchronous logging, as well as having a conceptual understanding of REST. Having said that, know at least the basics about containers (e.g. Docker), clouds (e.g. AWS), build systems, and continuous delivery.

[!info] Microservices vs. monolithic architecture | Atlassian
While a monolithic application is a single unified unit, a microservices architecture is a collection of smaller, independently deployable services.
https://www.atlassian.com/microservices/microservices-architecture/microservices-vs-monolith

[!info] Backend Developer Roadmap: What is Backend Development?
Learn what backend development is, what backend developers do and how to become one using our community-driven roadmap.
https://roadmap.sh/backend

[!info] Correctness (computer science)
In theoretical computer science, an algorithm is correct with respect to a specification if it behaves as specified.
https://en.wikipedia.org/wiki/Correctness_(computer_science)

[!info] UsingAndAvoidingNullExplained
Google core libraries for Java.
https://github.com/google/guava/wiki/UsingAndAvoidingNullExplained

Performance

Message Queues

Producers and consumers are decoupled via brokers, and this enables scalability.

[!info] Top 50 Kafka Interview Questions And Answers for 2024
In this article, we have compiled over 50 most frequently asked Kafka interview questions that can help you crack your next Kafka interview.
https://www.simplilearn.com/kafka-interview-questions-and-answers-article

[!info] Asynchronous Messaging Patterns
Asynchronous messaging enables applications to decouple from one another to improve performance, scalability, and reliability.
https://blogs.mulesoft.com/migration/asynchronous-messaging-patterns/

Possible issues

There are two important considerations in the message delivery platforms:

Produces failures can lead to some issues:

There can be a network failure between the producer and broker:

Similarly, broker failures can also cause data duplication:

There may be a failure during writing data to the disk from the in-memory state leading to data loss.

There can be network failure between the broker and the consumer:

Cloud

[!info]

https://elearn.epam.com/courses/course-v1:EPAM+CFT+0321/courseware/e2add7797cf944cda726ac147df1387e/e2140d2efb6b44919b4fae31606f5e1a/3?tpa_hint=oa2-prod-elearn-iam

Environment

Git

When it’s not possible to merge two branches because of conflicts, developers have two options: merging or rebasing. A rebase may be needed when reserving a clean Git history is important. Rebasing means to move the base of a branch on top of the leaf of another. Instead of having branches intersect multiple times, you can have a clean Git history, as long as everyone follows the golden rule of rebasing: never rebase a public branch.

Stashing is a powerful tool to put aside code that you just wrote, without pushing it to any remote tracked branch. While it’s possible to create multiple stashes at once by giving them different names, it’s usually better to not have more than one stash, as things can become complex to restore. Is there any difference between creating a local git branch and a git stash?

[!info] Documentation | Terraform | HashiCorp Developer
Documentation for Terraform, including Terraform CLI, Terraform Cloud, and Terraform Enterprise.
https://developer.hashicorp.com/terraform/docs

[!info] DevOps Roadmap: Learn to become a DevOps Engineer or SRE
Learn to become a modern DevOps engineer by following the steps, skills, resources and guides listed in our community-driven roadmap.
https://roadmap.sh/devops

Security

System Design

Я принес. Подготовка к system design собеседованиям

Собеседования по system design – это стандартная практика в многих бигтехах и у тех, кто под них мимикрирует. И прохождение этих собеседований является отдельным навыком, требующим подготовки.

Это я вам точно скажу на своем опыте: в прошлом году не готовился особо и провалил несколько таких собесов, а в этом готовился и успешно прошел несколько таких собесов. Некоторые из пройденных были даже в тех же компаниях, в которых провалил в прошлом году.

Перейдем к материалам.

Серия видеозаписей, подробно объясняющих, что и как делать:

https://www.youtube.com/watch?v=Cth-B4r_pf4

https://www.youtube.com/watch?v=Be7INI_U6GY

https://www.youtube.com/watch?v=jUbOm0B-eKQ

https://www.youtube.com/watch?v=Wh5Ya6UFG1k

Статьи:

https://stefaniuk.website/tags/system-design/

https://github.com/donnemartin/system-design-primer/

https://habr.com/ru/companies/avito/articles/753248/

https://github.com/vitkarpov/coding-interviews-blog-archive\#system-design

https://habr.com/ru/companies/yandex/articles/564132/

Книги:

https://www.litres.ru/book/martin-kleppman-1733/vysokonagruzhennye-prilozheniya-programmirovanie-mass-39100996/

https://www.litres.ru/book/aleks-suy/system-design-podgotovka-k-slozhnomu-intervu-67193183/

Смотрите видео, читайте и конспектируйте статьи и книги. Для пущей уверенности мо

Code quality

Clean Code

Patterns

Design Patterns

Microservices Patterns

Design and Development Principles

  1. System Design Exercise 1 (30 minutes):
  1. Algorithms and Data Structures (15 minutes):

    • Pose questions related to algorithms and data structures including both time and space complexities.
    • Evaluate problem-solving skills and understanding of core concepts. (ask about use cases)
  2. Programming Languages (15 minutes):

    • Assess the candidate's proficiency in relevant programming languages.
    • Focus on knowing and understanding:
      • Object-Oriented Programming (OOP): (principles of OOP, including encapsulation, inheritance, and polymorphism)
      • Collections: (List, Set, and Map, their implementation and internal structure)
      • Multithreading and Concurrency: (threads management, synchronization, and concurrent programming concepts)
      • Java Memory Management: (GC**:** types, how they work, Memory Leaks)
      • Functional Programming: (key concepts and characteristics, use-cases )
  3. Coding Exercise 1 (15 minutes):

    • Present a coding task that should be solved using Java 8+ approaches (encourage to use Stream, Functional Interface, Method reference, Lambda and ask about implementation details)
    • Allow the candidate to work through the problem, explaining their thought process.
    • Please encourage them to write code following Clean Code principles or ask them to review their code and improve.
  4. Coding Exercise 2( 30 minutes):

    1. Present a coding task related to the role(A3 medium, A4 hard) Note: Adjust the complexity of the task based on their performance. If the candidate is demonstrating a strong understanding, consider introducing more challenging aspects. On the other hand, if they are facing difficulties, feel empowered to simplify the task to ensure a fair evaluation.
    2. Allow the candidate to work through the problem, explaining their thought process.
    3. Please encourage them to write code following Clean Code principles or ask them to review their code and improve. What needs to be changed to ensure this code is ready for production?
    4. https://videoportal.epam.com/video/wJWrlKY1

    Untitled 12 13.png

    • [ ] Design and Development Principles

      75.png

    • [ ] Architectural Patterns

      73.png

Sample 1: URL Shortening Service

Problem: Design a URL shortening service like Bitly.

Solution:

Sample 2: Social Media Feed System

Problem: Design a system to generate and display a user's social media feed.

Solution:

Sample 3: Online Marketplace

Problem: Design an online marketplace where users can buy and sell products.

Solution:

These sample problems and solutions cover a range of difficulty levels and demonstrate both algorithmic problem-solving skills and system design considerations. Keep in mind that real-world scenarios may involve more complexity and trade-offs.

REST

Patterns

Hibernate 1

Kafka

Microservices_Design_Patterns

Microservices_Architecture

Relational Databases

https://www.geeksforgeeks.org/explain-in-sql/

[!info] Essential SQL Interview Questions | Toptal®
Know what to ask.
https://www.toptal.com/sql/interview-questions?utm_source=pocket_saves

Data storage / Data model design

SQL

Testing

Testing Basics

Mockito

Infrastructure

CI/CD

What deployment strategies have you worked with?

Configuration Management Tools

What software configuration management tools have you used?

We use k8s with helm and argocd. We change configuration file and when changes are commited gitlab ci job deploys them to the environment

Jenkins

Networking

Containerisation

Docker

K8s

Message Brockers

Kafka

Kubernetes

Docker

CI-CD

General

Practical

class Person { 
    Gender gender; 
    String name; 

    public Gender getGender() { 
        return gender; 
    } 

    public String getName() { 
        return name; 
    } 
} 

enum Gender {MALE, FEMALE, OTHER} 

//Get the list of uppercase names of all the “FEMALE” people in the list of persons.   


public List<String> getFemaleNames(List<Person> persons){
	List<String> femaleNames = new ArrayList<>();

	if(persons!=null){
		filteredPersonCollection = personCollection.stream()
			.filter(person -> person!=null && person.getName() !=null && Gender.FEMALE == person.getGender())
			.map(person -> person.getName().toUpperCase())
			.collect(Collectors.toList());
	}

	return femaleNames;
}

Management

Frontend

[!info] React Developer Roadmap: Learn to become a React developer
Community driven, articles, resources, guides, interview questions, quizzes for react development.
https://roadmap.sh/react

[!info] JavaScript Developer Roadmap: Step by step guide to learn JavaScript
Community driven, articles, resources, guides, interview questions, quizzes for javascript development.
https://roadmap.sh/javascript

[!info] Full Stack Developer Roadmap
Learn to become a modern full stack developer using this roadmap.
https://roadmap.sh/full-stack

Questions

When to use composition, when inheritance

What is the point of static and default methods in interface?

What will happin if we inherit interfaces with the same default methods

https://stackoverflow.com/questions/22685930/implementing-two-interfaces-with-two-default-methods-of-the-same-signature-in-ja

How many threads are created for parallel streams?

Number of CPU cores

Distinct by id in stream

Function<Function<Car,Long>,Predicate<Car>> distinctById = (keyExtractor) -> {
    Set<Object> seen = new HashSet<>();
    return item -> seen.add(keyExtractor.apply(item));
};
timecardChanges.stream()
        .filter(distinctById.apply(change -> change.getId()))
        .collect(Collectors.toList());