HDFC Bank Interview Preparation

55+ SQL, Java, Spring Boot, Banking domain questions with complete code solutions for fintech freshers.

QuestionAnswerCategory
Q1. Write query to find duplicate records in table.Use GROUP BY with HAVING clause to filter groups with count > 1.
SELECT column1, COUNT(*) 
FROM table_name 
GROUP BY column1 
HAVING COUNT(*) > 1;
Coding
Q2. Difference between PRIMARY KEY and UNIQUE constraint.PRIMARY: not null, only one per table. UNIQUE: allows null, multiple allowed. Primary keys are indexed automatically.Technical
Q3. Write query for nth highest salary.Use OFFSET with ORDER BY DESC, or LIMIT with variable.
SELECT DISTINCT salary FROM employees 
ORDER BY salary DESC 
LIMIT 1 OFFSET n-1;
Coding
Q4. What are INNER, LEFT, RIGHT, FULL OUTER JOINs?INNER: common rows. LEFT: all from left + matching right. RIGHT: all from right + matching left. FULL: all rows.Technical
Q5. Query to find employees without matching department.Use LEFT JOIN with WHERE condition checking NULL in right table.
SELECT e.* FROM employees e 
LEFT JOIN departments d ON e.dept_id = d.id 
WHERE d.id IS NULL;
Coding
Q6. What is KYC and AML?KYC (Know Your Customer): identity verification. AML (Anti-Money Laundering): detect suspicious transactions.Technical
Q7. Explain CASA account.CASA: Current Account Savings Account. Combines benefits of current and savings accounts for businesses.Technical
Q8. What is Spring Boot?Framework for building production-ready applications with minimal configuration. Auto-configuration, embedded servers.Technical
Q9. Explain MVC pattern.Model: data. View: presentation. Controller: logic. Separates concerns for maintainability.Technical
Q10. What is dependency injection?Pattern where objects' dependencies injected at runtime, not created inside. Improves testability and flexibility.Technical
Q11. Two Sum problem.Use hashmap to store complements. O(n) time complexity.
def two_sum(nums, target):
    seen = {}
    for i, num in enumerate(nums):
        if target - num in seen:
            return [seen[target - num], i]
        seen[num] = i
    return []
Coding
Q12. Reverse a string.Simple string slicing or iterate backwards.
# Method 1: Slicing
s = "hello"
print(s[::-1])  # "olleh"

# Method 2: Iteration
def reverse(s):
    return ''.join(reversed(s))
Coding
Q13. Check if string is palindrome.Compare string with its reverse or use two pointers.
def is_palindrome(s):
    s = s.replace(" ", "").lower()
    return s == s[::-1]
Coding
Q14. What are final, finally, finalize?final: prevent modification. finally: cleanup block. finalize: garbage collection method.Technical
Q15. Difference between DELETE and TRUNCATE.DELETE: slower, triggers fire, can rollback. TRUNCATE: faster, no triggers, identity reset.Technical
Q16. Find maximum element in array.Iterate through array, track maximum value.
def find_max(arr):
    return max(arr) if arr else None
Coding
Q17. Write query using subquery.Nested SELECT statement inside main query.
SELECT * FROM employees 
WHERE salary > (SELECT AVG(salary) FROM employees);
Coding
Q18. Count occurrences of character.Use dictionary/counter or count method.
s = "hello"
print(s.count('l'))  # 2
Coding
Q19. What is static keyword?Static variables/methods belong to class, not instance. Shared across all objects.Technical
Q20. Remove duplicates from array.Use set() for unique elements or two-pointer for sorted array.
def remove_duplicates(arr):
    return list(set(arr))
Coding
Q21. What is EMI?Equated Monthly Installment: fixed payment amount for loan repayment over specified period.Technical
Q22. Indexing in databases.Creates data structure for faster retrieval. Trade-off: faster reads, slower writes, more storage.Technical
Q23. Merge two sorted arrays.Use two pointers to compare and merge.
def merge(arr1, arr2):
    result = []
    i = j = 0
    while i < len(arr1) and j < len(arr2):
        if arr1[i] <= arr2[j]:
            result.append(arr1[i])
            i += 1
        else:
            result.append(arr2[j])
            j += 1
    result.extend(arr1[i:])
    result.extend(arr2[j:])
    return result
Coding
Q24. Interface vs Abstract class.Interface: all abstract (Java 8+: default methods). Abstract: mix abstract and concrete.Technical
Q25. VIEWS in SQL.Virtual table created from query. No separate storage. Used for security and simplifying complex queries.Technical
Q26. Anagram check.Sort both strings and compare, or use character frequency.
def is_anagram(s1, s2):
    return sorted(s1) == sorted(s2)
Coding
Q27. What is Core Banking System?Central repository for customer data, transactions, accounts. Examples: Finacle, Flexcube.Technical
Q28. What is OOP?Object-Oriented Programming: objects, classes, inheritance, polymorphism, encapsulation, abstraction.Technical
Q29. Fibonacci series.Each number = sum of previous two. F(0)=0, F(1)=1.
def fibonacci(n):
    a, b = 0, 1
    fib = []
    for _ in range(n):
        fib.append(a)
        a, b = b, a + b
    return fib
Coding
Q30. Stored procedures.Pre-compiled SQL code stored in database. Improves performance, security, reusability.Technical
Q31. Prime number check.Check if divisible by any number 2 to sqrt(n).
def is_prime(n):
    if n < 2:
        return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0:
            return False
    return True
Coding
Q32. Strings are immutable in Java?Yes, String objects cannot be modified. String + creates new object. Use StringBuilder for mutable strings.Technical
Q33. Factorial calculation.Product of all positive integers ≤ n. Iterative or recursive approach.
def factorial(n):
    if n < 0:
        return -1
    if n == 0:
        return 1
    return n * factorial(n - 1)
Coding
Q34. UNION vs UNION ALL.UNION: distinct rows, removes duplicates. UNION ALL: all rows including duplicates.Technical
Q35. What is digital banking?Banking through online/mobile platforms. Includes fund transfers, bill payments, loans, investments.Technical
Q36. Sort array using bubble sort.Compare adjacent elements, swap if wrong order. Repeat until sorted.
def bubble_sort(arr):
    n = len(arr)
    for i in range(n):
        for j in range(n - i - 1):
            if arr[j] > arr[j + 1]:
                arr[j], arr[j + 1] = arr[j + 1], arr[j]
    return arr
Coding
Q37. HashMap vs Hashtable.HashMap: non-synchronized, faster. Hashtable: synchronized, thread-safe, legacy.Technical
Q38. Binary search implementation.Divide search interval in half repeatedly on sorted array.
def binary_search(arr, target):
    left, right = 0, len(arr) - 1
    while left <= right:
        mid = (left + right) // 2
        if arr[mid] == target:
            return mid
        elif arr[mid] < target:
            left = mid + 1
        else:
            right = mid - 1
    return -1
Coding
Q39. TRIGGER in database.Automatic action executed before/after INSERT, UPDATE, DELETE events on table.Technical
Q40. Tell me about yourself.Education, projects, internships, relevant skills, why banking interested you.HR
Q41. Why HDFC Bank?Strong reputation, fintech innovation, career growth, customer-centric approach.HR
Q42. Your strengths.Analytical thinking, attention to detail, teamwork, problem-solving, quick learner.HR
Q43. Weaknesses.Perfectionist (learning to prioritize), sometimes hesitant (building confidence).HR
Q44. Handling pressure and deadlines.Prioritize tasks, break into smaller chunks, communicate, remain calm and focused.HR
Q45. Team experience example.Use STAR method. Project, roles, communication, collaboration, results achieved.HR
Q46. Have you worked with databases?Mention SQL projects, CRUD operations, optimization, data integrity experience.HR
Q47. Salary expectations.Research banking sector salary. Give range with flexibility based on location.HR
Q48. Any questions for us?Ask about team, tech stack, banking domain exposure, career growth, training.HR
Q49. Linear search implementation.Traverse array sequentially, return index when found.
def linear_search(arr, target):
    for i, val in enumerate(arr):
        if val == target:
            return i
    return -1
Coding
Q50. What is NPA?Non-Performing Asset: loan where interest/principal not paid for 90+ days.Technical
Q51. Normalization forms.1NF: atomic values. 2NF: no partial dependency. 3NF: no transitive dependency. BCNF: every determinant is candidate key.Technical
Q52. GCD/LCM calculation.GCD: Euclidean algorithm. LCM = (a*b)/GCD(a,b).
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return (a * b) // gcd(a, b)
Coding
Q53. String reversal without built-in.Use loop to build reversed string or use recursion.
def reverse_string(s):
    reversed_str = ""
    for char in s:
        reversed_str = char + reversed_str
    return reversed_str
Coding
Q54. Encapsulation principle.Bundling data and methods. Hide internal details. Use getters/setters for access control.Technical
Q55. Why should we hire you?Strong technical foundation, banking interest, team player, quick learner, committed to growth.HR