Software Development Engineer

50+ Software Development Engineer Interview Questions and Answers for Freshers

Updated 28 Nov 2024

Popular Companies

search-icon

Q1. Given two words, find the similarity between them. You have to develop your own sense of similarity here. Normalize length of LCS by the total length of the string.

Ans.

The question asks to find the similarity between two words by normalizing the length of the longest common subsequence (LCS) by the total length of the string.

  • Implement a function that takes two words as input

  • Find the length of the longest common subsequence (LCS) between the two words

  • Normalize the length of LCS by dividing it by the total length of the string

  • Return the normalized similarity value

Q2. How would you find least common ancestor of two nodes in a binary tree?

Ans.

To find least common ancestor of two nodes in a binary tree, traverse the tree from root to the nodes and store the paths. Then compare the paths to find the common ancestor.

  • Traverse the binary tree from root to the two nodes and store the paths

  • Compare the paths to find the common ancestor

  • If the binary tree is a BST, compare the values of the nodes to find the common ancestor

  • If one of the nodes is the ancestor of the other, return the ancestor node

Q3. Implement the "People you may know" feature of facebook with code. Use BFS and counter (for mutual friends).

Ans.

Implement Facebook's 'People you may know' feature using BFS and mutual friend counter.

  • Create a graph of users and their friends

  • Perform BFS on the graph starting from the user in question

  • For each friend of the user, increment a counter for their mutual friends

  • Sort the list of potential friends by mutual friend count

  • Exclude already connected friends and suggest top potential friends

Q4. How would you identify two nodes that have been swapped in a binary search tree?

Ans.

To identify swapped nodes in a binary search tree, we need to perform an inorder traversal and compare adjacent nodes.

  • Perform an inorder traversal of the binary search tree

  • Compare each node with its adjacent node

  • If a node is smaller than its previous node, mark it as a swapped node

  • If two nodes are swapped, swap their values to restore the original binary search tree

Are these interview questions helpful?

Q5. Given a binary tree, return doubly linked list of all the nodes at each level.

Ans.

The function takes a binary tree as input and returns a doubly linked list of all the nodes at each level.

  • Use a breadth-first search (BFS) algorithm to traverse the binary tree level by level.

  • For each level, create a doubly linked list and add the nodes to it.

  • Connect the doubly linked lists of each level to form the final result.

Q6. 5) Find out the heavier ball from 8 identical ball of which one is heavier using only a balance weighting machine in least number of trys

Ans.

Find the heavier ball from 8 identical balls using a balance weighting machine in least number of tries.

  • Divide the balls into 3 groups of 3, 3, and 2 balls.

  • Weigh the first two groups against each other.

  • If they balance, the heavier ball is in the remaining group of 2 balls.

  • If one group is heavier, weigh two balls from that group against each other.

  • If they balance, the heavier ball is the remaining ball.

  • If one ball is heavier, that is the heavier ball.

Share interview questions and help millions of jobseekers 🌟

man-with-laptop

Q7. Write code for designing the ADT (Abstract Data Type) for all the classes that might be required to represent the game of chess

Ans.

Design ADT for chess game classes

  • Create classes for pieces (king, queen, etc.), board, player, game

  • Use inheritance to represent different types of pieces

  • Implement methods for moving pieces, checking for checkmate, etc.

Q8. How would you optimize it for a binary search tree?

Ans.

Optimizing for binary search tree

  • Ensure the tree is balanced to maintain O(log n) search time

  • Implement efficient insertion and deletion algorithms

  • Use in-order traversal for sorted output

  • Consider using AVL or Red-Black trees for self-balancing

  • Avoid using recursion for large trees to prevent stack overflow

Software Development Engineer Jobs

GPU Software Development Engineer 4-9 years
Intel Technology India Pvt Ltd
4.3
Bangalore / Bengaluru
Sr Software Dev Engineer, Amazon 5-10 years
Amazon India Software Dev Centre Pvt Ltd
4.1
Bangalore / Bengaluru
Sr Software Dev Engineer, Amazon Tax Services 5-10 years
Amazon India Software Dev Centre Pvt Ltd
4.1
Bangalore / Bengaluru

Q9. in an integer array where element represent stock price and index represent days how to detect the best day to buy and best day to sell in O(N)

Ans.

To detect the best day to buy and sell stock in an integer array representing stock prices and days in O(N).

  • Iterate through the array and keep track of the minimum price seen so far.

  • Calculate the profit by subtracting the current price from the minimum price.

  • Update the maximum profit and best buy/sell days accordingly.

  • Return the best buy and sell days to maximize profit.

Q10. Write code for the subtitle syncing application you talked about, not the entire thing, just the crux of it.

Ans.

Code for subtitle syncing application

  • Create a function to parse subtitle file and extract time stamps

  • Create a function to parse video file and extract time stamps

  • Calculate time difference between subtitle and video time stamps

  • Adjust subtitle time stamps accordingly

  • Output synced subtitle file

Q11. 1 - where is bean annotation used in springboot ?... In class or method

Ans.

Bean annotation is used in Spring Boot on class or method to indicate that a method produces a bean to be managed by the Spring container.

  • Bean annotation is used on methods within a class to indicate that the method produces a bean to be managed by the Spring container.

  • It can also be used at the class level to indicate that the class itself is a Spring bean.

  • For example, @Bean annotation can be used on a method that creates and returns a DataSource bean in a configuration clas...read more

Q12. Check the given sentence is palindrome or not by taking input by user.

Ans.

The program checks if a given sentence is a palindrome or not.

  • Prompt the user to input a sentence

  • Remove all spaces and punctuation from the sentence

  • Reverse the sentence and compare it with the original sentence to check for palindrome

Q13. Find a string in a 2D character matrix in any order(horizontal/vertical/diagonal)

Ans.

Search for a string in a 2D character matrix in any direction

  • Iterate through each cell of the matrix

  • For each cell, check all possible directions for the string

  • If found, return the starting and ending coordinates of the string

Q14. what is polymorphism and interface , what is difference between interface and abstract class

Ans.

Polymorphism allows objects of different classes to be treated as objects of a common superclass. Interface is a contract that defines a set of methods that a class must implement.

  • Polymorphism allows for flexibility in programming by enabling a single interface to be used to represent multiple types of objects

  • Interfaces in Java are similar to abstract classes, but they cannot contain any implementation code

  • Abstract classes can have both abstract and concrete methods, while in...read more

Q15. which access modifier to restrict interface method access to only derived or implemented classes

Ans.

Protected access modifier restricts interface method access to only derived or implemented classes.

  • Use 'protected' access modifier to restrict access to only derived or implemented classes

  • Protected members are accessible within the same package or by subclasses

  • Example: 'protected void methodName() {}' in an interface

Q16. 1) Time complexity of binary search for array and linked list

Ans.

Binary search has O(log n) time complexity for arrays and O(n) for linked lists.

  • Binary search is efficient for arrays due to their random access nature.

  • Linked lists require sequential traversal, making binary search inefficient.

  • For arrays, the time complexity is O(log n) as the search space is halved with each iteration.

  • For linked lists, the time complexity is O(n) as all nodes must be visited to find the target.

  • Binary search can be implemented recursively or iteratively.

Q17. Find one string in another big string without inbuild function, what if bigger string is too big, complexity

Ans.

Use a sliding window approach to search for a substring in a larger string without using built-in functions.

  • Iterate through the larger string using a window of the size of the substring to search for.

  • Compare the characters in the window with the substring to check for a match.

  • Move the window one character at a time until the end of the larger string is reached.

  • Time complexity is O(n*m) where n is the length of the larger string and m is the length of the substring.

Q18. Write the artificial intelligence logic in code for your Chess representation

Ans.

AI logic for Chess representation

  • Implement minimax algorithm with alpha-beta pruning

  • Use evaluation function to assign values to board positions

  • Implement move ordering to improve efficiency

  • Use transposition tables to store previously evaluated positions

  • Implement iterative deepening to improve search depth

Q19. What is Diff between static and final keyword in java

Ans.

Static keyword is used to create class-level variables and methods, while final keyword is used to make a variable constant.

  • Static keyword is used to create variables and methods that belong to the class itself, rather than to any specific instance of the class.

  • Final keyword is used to make a variable constant and cannot be changed once it has been assigned a value.

  • Static variables are shared among all instances of a class, while final variables are unique to each instance.

Q20. Find a palindrome, longest possible palindrome, find remainder without using modulus operator

Ans.

Answering questions on finding palindromes and remainders without modulus operator.

  • To find a palindrome, compare the first and last characters of the string and move towards the center until they meet or the string is not a palindrome.

  • To find the longest palindrome, iterate through all possible substrings and check if they are palindromes.

  • To find remainder without modulus operator, use repeated subtraction until the dividend is less than the divisor.

Q21. how does one services interact with other in microservice

Ans.

Microservices interact with each other through APIs, messaging, or events.

  • Microservices communicate with each other through APIs, which can be synchronous or asynchronous.

  • Messaging systems like RabbitMQ or Kafka can be used for communication between microservices.

  • Events can be used for loosely coupled communication between microservices.

  • Service discovery mechanisms like Eureka or Consul help microservices locate and communicate with each other.

  • API gateways can be used to mana...read more

Q22. Swap 2 numbers without using 3rd variable

Ans.

Swap 2 numbers without using 3rd variable

  • Use addition and subtraction

  • Use multiplication and division

  • Use bitwise XOR operation

Q23. in an integer array find the next greatest number for all and display in O(N)

Ans.

Find the next greatest number for each integer in an array in O(N) time complexity.

  • Iterate through the array from right to left

  • Use a stack to keep track of potential next greatest numbers

  • Pop elements from the stack that are less than the current element and update their next greatest number to the current element

  • Push the current element onto the stack

  • Repeat until all elements have a next greatest number

Q24. 3) Find depth of binary tree through recursion and iteration

Ans.

Find depth of binary tree through recursion and iteration

  • Recursively traverse left and right subtrees and return the maximum depth

  • Iteratively traverse the tree using a stack or queue and keep track of the depth

  • Depth of an empty tree is 0

  • Depth of a tree with only one node is 1

Q25. What is singleton class, write a usecase through code

Ans.

Singleton class is a class that can only have one instance created throughout the application.

  • Singleton class restricts the instantiation of a class to one object.

  • It is often used for logging, caching, thread pools, database connections, etc.

  • Example: Java implementation of Singleton class -

  • public class Singleton { private static Singleton instance; private Singleton() {} public static Singleton getInstance() { if(instance == null) { instance = new Singleton(); } return instan...read more

Q26. Fibonacci series with and without recursion

Ans.

Answering Fibonacci series with and without recursion

  • Fibonacci series is a sequence of numbers where each number is the sum of the two preceding ones

  • Recursion method involves calling the function within itself

  • Non-recursive method involves using a loop to calculate the series

  • Recursive method is slower and can cause stack overflow for large inputs

  • Non-recursive method is faster and more efficient for large inputs

Q27. what is diff between jvm, jre, jdk

Ans.

JVM is the Java Virtual Machine that executes Java bytecode. JRE is the Java Runtime Environment that includes JVM and libraries. JDK is the Java Development Kit that includes JRE and development tools.

  • JVM is the virtual machine that runs Java bytecode and provides a runtime environment for Java programs.

  • JRE includes JVM along with libraries and other components necessary to run Java applications.

  • JDK is a development kit that includes JRE and development tools such as compile...read more

Q28. height of the binary tree, factorial code in python

Ans.

Calculate the height of a binary tree and implement factorial code in Python.

  • To calculate the height of a binary tree, you can use a recursive approach where you find the height of the left and right subtrees and return the maximum height plus one.

  • For factorial code in Python, you can use a recursive function that multiplies the current number with the factorial of the previous number until reaching 1.

  • Example for calculating the height of a binary tree: def height(node): if n...read more

Q29. 2) Construct tree from inorder and post order list

Ans.

Construct a tree using inorder and postorder traversal lists.

  • The last element of the postorder list is the root of the tree.

  • Find the root in the inorder list and split the list into left and right subtrees.

  • Recursively construct the left and right subtrees using the corresponding sublists.

  • Return the root node.

  • Time complexity: O(n^2) in worst case, O(nlogn) on average.

Q30. 4) Find intersection of two arrays

Ans.

Intersection of two arrays is the common elements present in both arrays.

  • Sort both arrays and use two pointers to compare elements.

  • Use a hash set to store elements of one array and check for presence in the other array.

  • If arrays are already sorted, use binary search to find common elements.

Q31. DBMS QUERIES third maximum salary

Ans.

To find third maximum salary in DBMS, we can use the ORDER BY and LIMIT clauses.

  • Use ORDER BY to sort the salaries in descending order

  • Use LIMIT to select the third highest salary

  • Example: SELECT salary FROM employees ORDER BY salary DESC LIMIT 2,1

Q32. What is pointer ?

Ans.

A pointer is a variable that stores the memory address of another variable.

  • Pointers are used to manipulate memory directly.

  • They can be used to pass large data structures to functions without copying them.

  • Pointers can be used to create dynamic data structures like linked lists and trees.

  • They can also be used to access hardware directly.

  • Examples of pointer types include int*, char*, and void*.

Q33. how hashmap internally worked

Ans.

HashMap internally uses an array of linked lists to store key-value pairs, with keys hashed to determine the index.

  • HashMap uses hashing to determine the index of key-value pairs in the array.

  • Each index in the array can store multiple key-value pairs in a linked list.

  • When a key is inserted, its hash code is used to find the appropriate index in the array.

  • If multiple keys hash to the same index, they are stored in a linked list at that index.

  • HashMap dynamically resizes the arra...read more

Q34. what is Springboot rest api

Ans.

Spring Boot is a framework for building Java-based web applications with minimal configuration.

  • Spring Boot simplifies the process of creating standalone, production-grade Spring-based applications.

  • It provides a range of features like embedded servers, auto-configuration, and production-ready metrics.

  • Spring Boot allows developers to quickly set up and run RESTful web services using annotations and minimal XML configuration.

Q35. String is immutable or mutable in java

Ans.

String is immutable in Java

  • Immutable means once created, the value cannot be changed

  • String class in Java is final and cannot be extended

  • Any operation on a string creates a new string object

Q36. Print series of prime numbers

Ans.

Print series of prime numbers

  • Start with 2 as the first prime number

  • Check if each number greater than 2 is divisible by any number less than it

  • If not, add it to the list of prime numbers

  • Continue until desired number of primes are found

Q37. What is multi threading

Ans.

Multi threading is the ability of a program to perform multiple tasks concurrently.

  • It allows for efficient use of CPU resources

  • Threads share the same memory space

  • Synchronization is required to avoid race conditions

  • Examples include web servers handling multiple requests simultaneously

Frequently asked in,

Q38. What is polymorphism?

Ans.

Polymorphism is the ability of a function or method to behave differently based on the object it is acting upon.

  • Polymorphism allows objects of different classes to be treated as objects of a common superclass.

  • It enables a single interface to represent multiple data types.

  • Examples include method overloading and method overriding in object-oriented programming.

Frequently asked in, ,

Q39. Reverse a linked-list

Ans.

Reverse a linked-list

  • Iterate through the linked-list and change the direction of the pointers

  • Keep track of the previous, current and next nodes

  • Set the head of the linked-list to the last node after reversing

Frequently asked in,

Q40. Which are the tcs client

Ans.

TCS has a wide range of clients across various industries including banking, healthcare, retail, and technology.

  • TCS clients span industries such as banking, healthcare, retail, and technology

  • Some examples of TCS clients include Citibank, Philips, Walmart, and Microsoft

  • TCS provides services to clients globally, serving companies of all sizes

Q41. Write a couple of sql queries

Ans.

SQL queries to demonstrate proficiency in database querying

  • SELECT * FROM table_name WHERE condition;

  • SELECT column1, column2 FROM table_name WHERE condition;

Q42. What is abstraction?

Ans.

Abstraction is the concept of hiding complex implementation details and showing only the necessary information to the user.

  • Abstraction allows developers to focus on the essential features of an object or system without getting bogged down in unnecessary details.

  • It helps in reducing complexity and improving efficiency by providing a simplified view of the system.

  • For example, in object-oriented programming, abstract classes and interfaces are used to define a blueprint for othe...read more

Frequently asked in, ,

Q43. find cycle in linkedlist

Ans.

Detect cycle in a linked list

  • Use two pointers approach - slow and fast pointers

  • If there is a cycle, the fast pointer will eventually catch up to the slow pointer

  • Check if the fast and slow pointers meet at some point to detect the cycle

Q44. Print odd even nodes in tree

Ans.

Print odd even nodes in tree

  • Traverse the tree using depth-first search (DFS)

  • Maintain a variable to track the level of each node

  • Print nodes based on whether their level is odd or even

Q45. OOP concepts with examples

Ans.

OOP concepts include inheritance, encapsulation, polymorphism, and abstraction.

  • Inheritance: Allows a class to inherit properties and behavior from another class. Example: Animal class can be inherited by Dog class.

  • Encapsulation: Bundling data and methods that operate on the data into a single unit. Example: Using private variables and public methods in a class.

  • Polymorphism: Ability for objects to be treated as instances of their parent class. Example: Animal class can have a ...read more

Q46. Create a server without express

Ans.

Creating a server without using Express framework

  • Use Node.js built-in 'http' module to create a server

  • Listen for incoming requests on a specific port

  • Handle different routes and methods using 'http' module

Q47. Kth largest element kf heap

Ans.

Finding the Kth largest element in a heap.

  • Use a max heap to store the elements in the array.

  • Remove the largest element K times to find the Kth largest element.

  • Time complexity is O(K log N) where N is the number of elements in the heap.

Q48. Merge interval greedy problem

Ans.

Merge overlapping intervals to create a new set of non-overlapping intervals.

  • Sort the intervals based on the start time.

  • Iterate through the intervals and merge overlapping intervals.

  • Return the merged intervals as the final result.

Q49. Talk about java

Ans.

Java is a popular programming language known for its platform independence and object-oriented approach.

  • Java is widely used for developing desktop, web, and mobile applications.

  • It follows the 'write once, run anywhere' principle, allowing code to be executed on any platform with a Java Virtual Machine (JVM).

  • Java supports multithreading, exception handling, and automatic memory management through garbage collection.

  • It has a vast standard library and a large community of develo...read more

Q50. Hard Stock sell problem

Ans.

The hard stock sell problem involves determining the best time to sell stocks to maximize profit.

  • Consider using dynamic programming to solve this problem efficiently.

  • Keep track of the minimum stock price seen so far and calculate the maximum profit that can be made by selling at each day.

  • The final answer will be the maximum profit that can be made by selling at the last day.

1
2
Next
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Interview experiences of popular companies

3.7
 • 10k Interviews
3.9
 • 7.8k Interviews
4.1
 • 4.9k Interviews
3.6
 • 3.6k Interviews
4.0
 • 1.3k Interviews
4.4
 • 812 Interviews
3.5
 • 188 Interviews
View all

Calculate your in-hand salary

Confused about how your in-hand salary is calculated? Enter your annual salary (CTC) and get your in-hand salary

Software Development Engineer Interview Questions
Share an Interview
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter