TechByteByByte

QA / TESTING

QA Coding Questions

Practice frequently asked coding questions from real QA and test automation interviews, each with a clear, worked answer.

These questions were curated after going through 100+ sources โ€” LinkedIn posts, Medium articles, YouTube videos, and interview experiences shared by friends โ€” to reflect what's genuinely being asked in real QA/automation interviews.

Work through the questions in any order โ€” each one is self-contained.

01

Check if a Number is Even or Odd in Java

02

Check Leap Year in Java

InfosysWiproTech MahindraDeloitte
03

Check if a Vowel is Present in a String - Java

CapgeminiCognizantLTIMindtreeEPAM
04

Count Vowels in a String or Array of Strings - Java

TCSHCLTechIBMThoughtWorks
05

Count Non-Space Characters in a String - Java

WiproTech MahindraDeloittePublicis Sapient
06

Count Uppercase and Lowercase Letters in a String - Java

CognizantLTIMindtreeEPAMZensar
07

Swap Two Numbers With and Without a Temp Variable - Java

HCLTechIBMThoughtWorksAccenture
08

Swap Two Strings With and Without a Temp Variable - Java

Tech MahindraDeloittePublicis SapientInfosys
09

Find Max and Min in an Array - Java

LTIMindtreeEPAMZensarCapgemini
10

Sum of All Elements in an Integer Array - Java

IBMThoughtWorksAccentureTCS
11

Check if a List Contains Only Odd Numbers - Java

DeloittePublicis SapientInfosysWipro
12

Reverse a String Without Using Built-in Methods - Java

EPAMZensarCapgeminiCognizant
13

Check Whether a String is a Palindrome - Java

ThoughtWorksAccentureTCSHCLTech
14

Reverse Each Word in a Sentence While Preserving Word Order - Java

Publicis SapientInfosysWiproTech Mahindra
15

Count the Number of Words in a Sentence - Java

ZensarCapgeminiCognizantLTIMindtree
16

Check Whether All Characters in a String Are Unique - Java

AccentureTCSHCLTechIBM
17

Remove Spaces from a String - Java

InfosysWiproTech MahindraDeloitte
18

Remove All Occurrences of a Given Character from a String - Java

CapgeminiCognizantLTIMindtreeEPAM
19

Get Distinct Characters from a String - Java

TCSHCLTechIBMThoughtWorks
20

Generate Fibonacci Series up to N Terms - Java

WiproTech MahindraDeloittePublicis Sapient
21

Check if a Number is Prime - Java

CognizantLTIMindtreeEPAMZensar
22

FizzBuzz - Print 1 to 100 with Fizz/Buzz/FizzBuzz Rules - Java

HCLTechIBMThoughtWorksAccenture
23

Sum of Digits of a Number - Java

Tech MahindraDeloittePublicis SapientInfosys
24

Count Character Occurrences - Build a Frequency Map - Java

LTIMindtreeEPAMZensarCapgemini
25

Find the Second Largest Number in an Array - Java

IBMThoughtWorksAccentureTCS
26

Find the Third-Largest Distinct Number in an Array - Java

DeloittePublicis SapientInfosysWipro
27

Print Only Unique Values in an Array - Java

EPAMZensarCapgeminiCognizant
28

Remove Duplicates from an Integer Array - Java

ThoughtWorksAccentureTCSHCLTech
29

Move Zeroes to the End of an Array While Maintaining Order - Java

Publicis SapientInfosysWiproTech Mahindra
30

Check if Two Arrays Contain the Same Elements - Java

ZensarCapgeminiCognizantLTIMindtree
31

Find the Missing Number from an Array Containing 1 to N - Java

AccentureTCSHCLTechIBM
32

Rotate an Array Left or Right by K Positions - Java

InfosysWiproTech MahindraDeloitte
33

Find the Intersection of Two Arrays - Java

CapgeminiCognizantLTIMindtreeEPAM
34

Two Sum - Find a Pair of Numbers Whose Sum Equals a Target - Java

TCSHCLTechIBMThoughtWorks
35

Find the Maximum-Sum Contiguous Subarray (Kadane's Algorithm) - Java

WiproTech MahindraDeloittePublicis Sapient
36

Find the Maximum Average Subarray (Sliding Window) - Java

CognizantLTIMindtreeEPAMZensar
37

Find the Most Frequent / Majority Element in an Array - Java

HCLTechIBMThoughtWorksAccenture
38

Sort an Array Without Using Built-in Sorting Methods - Java

Tech MahindraDeloittePublicis SapientInfosys
39

Find Factorial Using Recursion - Java

LTIMindtreeEPAMZensarCapgemini
40

Reverse a Number / Check if a Number is a Palindrome - Java

IBMThoughtWorksAccentureTCS
41

Check Armstrong Number - Java

DeloittePublicis SapientInfosysWipro
42

Find the First Repeating Character in a String - Java

EPAMZensarCapgeminiCognizant
43

Find the Duplicate Words in a Sentence - Java

ThoughtWorksAccentureTCSHCLTech
44

Find the First Non-Repeating Element in an Integer Array - Java

Publicis SapientInfosysWiproTech Mahindra
45

Implement Binary Search and Linear Search - Java

ZensarCapgeminiCognizantLTIMindtree
46

Decimal to Binary Conversion (and Back) - Java

AccentureTCSHCLTechIBM
47

Find GCD/HCF of Two Numbers - Java

InfosysWiproTech MahindraDeloitte
48

Find the First Non-Repeating Character in a String - Java

CapgeminiCognizantLTIMindtreeEPAM
49

Count Duplicate Characters in a String - Java

TCSHCLTechIBMThoughtWorks
50

Find All Duplicate Characters in a String - Java

WiproTech MahindraDeloittePublicis Sapient
51

Remove Duplicate Characters from a String - Java

CognizantLTIMindtreeEPAMZensar
52

Check if Two Strings Are Anagrams (Sorting or Frequency Array) - Java

HCLTechIBMThoughtWorksAccenture
53

Count Occurrences of Substrings/Words in Text (Log/Data-Relevant) - Java

Tech MahindraDeloittePublicis SapientInfosys
54

Print a Matrix in Spiral Order - Java

LTIMindtreeEPAMZensarCapgemini
55

Sort a HashMap by Its Values - Java

IBMThoughtWorksAccentureTCS