Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
The Complete Coding Interview Guide in Java

You're reading from   The Complete Coding Interview Guide in Java An effective guide for aspiring Java developers to ace their programming interviews

Arrow left icon
Product type Paperback
Published in Aug 2020
Publisher Packt
ISBN-13 9781839212062
Length 788 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Anghel Leonard Anghel Leonard
Author Profile Icon Anghel Leonard
Anghel Leonard
Arrow right icon
View More author details
Toc

Table of Contents (25) Chapters Close

Preface 1. Section 1: The Non-Technical Part of an Interview
2. Chapter 1: Where to Start and How to Prepare for the Interview FREE CHAPTER 3. Chapter 2: What Interviews at Big Companies Look Like 4. Chapter 3: Common Non-Technical Questions and How To Answer Them 5. Chapter 4: How to Handle Failures 6. Chapter 5: How to Approach a Coding Challenge 7. Section 2: Concepts
8. Chapter 6: Object-Oriented Programming 9. Chapter 7: Big O Analysis of Algorithms 10. Chapter 8: Recursion and Dynamic Programming 11. Chapter 9: Bit Manipulation 12. Section 3: Algorithms and Data Structures
13. Chapter 10: Arrays and Strings 14. Chapter 11: Linked Lists and Maps 15. Chapter 12: Stacks and Queues 16. Chapter 13: Trees and Graphs 17. Chapter 14: Sorting and Searching 18. Chapter 15: Mathematics and Puzzles 19. Section 4: Bonus – Concurrency and Functional Programming
20. Chapter 16: Concurrency 21. Chapter 17: Functional-Style Programming 22. Chapter 18: Unit Testing 23. Chapter 19: System Scalability 24. Other Books You May Enjoy

Questions and coding challenges

In this section, we'll cover 15 questions and coding challenges related to unit testing that are very popular in interviews. Let's begin!

Coding challenge 1 – AAA

Problem: What is AAA in unit testing?

Solution: The AAA acronym stands for [A]rrange, [A]ct, [A]ssert, and it represents an approach to structuring tests to sustain clean code and readability. Today, AAA is a testing pattern that's almost a standard across the industry. The following snippet of code speaks for itself:

@Test
public void givenStreamWhenSumThenEquals6() {
  // Arrange
  Stream<Integer> theStream = Stream.of(1, 2, 3);
  // Act
  int sum = theStream.mapToInt(i -> i).sum();
  // Assert
  assertEquals(6, sum);
}

Arrange section: In this section, we prepare or set up the test. For example, in the preceding code, we prepared a stream of integers where the elements are 1, 2, and...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime