Software Engineer

1000+ Software Engineer Interview Questions and Answers for Freshers

Updated 25 Feb 2025
search-icon

Q151. if I give you a box full of pencils..in how many ways can you use it

Ans.

There are numerous ways to use a box full of pencils depending on the context and purpose.

  • Pencils can be used for writing, drawing, sketching, coloring, shading, and more.

  • They can be used for artistic purposes, schoolwork, office work, or personal use.

  • Pencils can also be used as a tool for measurement, as a makeshift stylus, or even as a musical instrument.

  • The number of ways to use a box full of pencils is virtually limitless and depends on the creativity and imagination of t...read more

Q152. Remove String from Linked List Problem

You are provided with a singly linked list where each node contains a single character, along with a string 'STR'. Your task is to remove all occurrences of the string 'ST...read more

Q153. Sum Tree Conversion

Convert a given binary tree into its sum tree. In a sum tree, every node's value is replaced with the sum of its immediate children's values. Leaf nodes are set to 0. Finally, return the pre...read more

Q154. DFS Traversal Problem Statement

Given an undirected and disconnected graph G(V, E), where V is the number of vertices and E is the number of edges, the connections between vertices are provided in the 'GRAPH' m...read more

Are these interview questions helpful?

Q155. Expression Equality Checker

Given two strings representing expressions in variables, determine if they are equivalent. Return 'YES' if the expressions are identical and 'NO' if they are different. Each expressi...read more

Q156. Leap Year Checker

Determine if a given year, represented as an integer 'N', is a leap year.

A leap year is defined as a year with 366 days, unlike a normal year which has 365 days.

Input:

The initial input line...read more

Share interview questions and help millions of jobseekers 🌟

man-with-laptop

Q157. Scramble String Problem Statement

You are given an integer 'N' and two strings S and R, each having the size N. Determine if you can scramble string S to obtain string R using specified operations.

Your task is...read more

Q158. Sort String with Alternate Lower and Upper Case

Given a string STR containing both lowercase and uppercase letters, the task is to sort the string so that the resulting string contains uppercase and lowercase l...read more

Software Engineer Jobs

Software Engineer- Golang/Kubernetes 3-7 years
Red Hat India Pvt Ltd
4.3
Bangalore / Bengaluru
Software Engineer 2-5 years
Red Hat India Pvt Ltd
4.3
Pune
Software Engineer 1-3 years
Red Hat India Pvt Ltd
4.3
Pune

Q159. Valid Parentheses Problem Statement

Given a string 'STR' consisting solely of the characters “{”, “}”, “(”, “)”, “[” and “]”, determine if the parentheses are balanced.

Input:

The first line contains an integer...read more

Q160. what's difference between server.transfer and Response.redirect

Ans.

Difference between server.transfer and Response.redirect

  • Server.Transfer transfers control to another page on the server without the client knowing

  • Response.Redirect sends a message to the client to redirect to another page

  • Server.Transfer is faster and more efficient than Response.Redirect

  • Server.Transfer can only be used within the same application, while Response.Redirect can be used to redirect to any URL

Q161. What are locks? If you have non pre-emptive uni processor system, is there any need of lock. (He himself was confused about what he was asking & my questions made him more confused, So in end he said lets leave...

read more
Ans.

Locks are synchronization mechanisms used to control access to shared resources in multi-threaded environments.

  • Locks prevent multiple threads from accessing shared resources simultaneously.

  • They ensure that only one thread can access a shared resource at a time.

  • Locks help in preventing race conditions and maintaining data integrity.

  • They can be implemented using various techniques such as mutexes, semaphores, or monitors.

  • In a non pre-emptive uni processor system, where only one...read more

Q162. Excel Column Number Conversion

Given a column title as it appears in an Excel sheet, your task is to return its corresponding column number.

Example:

Input:
S = "AB"
Output:
28
Explanation:

The sequence is as f...read more

Q163. Orange Rotting Problem Statement

Consider a grid containing oranges. Each cell in this grid can hold one of three integer values:

  • Value 0: Represents an empty cell.
  • Value 1: Represents a fresh orange.
  • Value 2:...read more
Ans.

The task is to determine the minimum time required for all fresh oranges to become rotten in a grid.

  • Create a queue to store the rotten oranges and their time of rotting.

  • Iterate through the grid to find the initial rotten oranges and add them to the queue.

  • Perform BFS by popping each rotten orange from the queue, rot adjacent fresh oranges, and add them to the queue with updated time.

  • Continue until the queue is empty, keeping track of the maximum time taken to rot all oranges.

  • I...read more

Q164. What is the role of virtual memory if there is no swap space...(Interviewer was So knowledgeable about memory management that We spent 1 hour out of 1.45 hour on discussing virtual memory only.. :-o )

Ans.

Virtual memory allows the operating system to use disk space as an extension of RAM when there is no swap space.

  • Virtual memory allows programs to use more memory than physically available.

  • It provides a way to manage memory efficiently by swapping data between RAM and disk.

  • Without swap space, virtual memory cannot be used effectively.

  • Virtual memory helps in running large programs and multitasking.

  • It allows for memory protection and isolation between processes.

Q165. Bit Set Problem Statement

You are provided with a string, termed as DIGIT_PATTERN, which consists solely of digits. The objective is to identify the first digit that repeats in the sequence. If there's no repea...read more

Ans.

Identify the first repeating digit in a given string of digits.

  • Iterate through the string and keep track of seen digits using a set.

  • Return the first digit that repeats, or -1 if no digit repeats.

  • Time complexity: O(n), where n is the length of the input string.

Q166. 0-1 Knapsack Problem Statement

A thief is robbing a store and can carry a maximal weight 'W' in his knapsack. There are 'N' items, where the i-th item has a weight 'wi' and value 'vi'. Consider the maximum weig...read more

Q167. How would you scale up your application ?,if it fails on one instances how would you know where did it fail, explain has a relationship with real world example and write a code in java representative of the sam...

read more
Ans.

To scale up application, use load balancers and monitor logs to identify failures.

  • Use load balancers to distribute traffic across multiple instances

  • Monitor logs to identify where the failure occurred

  • Implement fault tolerance and redundancy to prevent future failures

  • Use auto-scaling to automatically add or remove instances based on traffic

  • Real-world example: Amazon Web Services (AWS) uses load balancers and auto-scaling to handle millions of requests

  • Code example: Use try-catch...read more

Q168. Which data structure inserts and deletes in O(1) time and is it possible to create a data structure with insertion, deletion and search retrieval in O(1) time

Ans.

Hash table. No, it is not possible to create a data structure with all operations in O(1) time.

  • Hash table uses a hash function to map keys to indices in an array.

  • Insertion and deletion can be done in O(1) time on average.

  • Search retrieval can also be done in O(1) time on average.

  • However, worst-case scenarios can result in O(n) time complexity.

  • It is not possible to create a data structure with all operations in O(1) time.

Q169. Find Duplicates in an Array

Given an array ARR of size 'N', where each integer is in the range from 0 to N - 1, identify all elements that appear more than once.

Return the duplicate elements in any order. If n...read more

Ans.

Find duplicates in an array of integers within a specified range.

  • Iterate through the array and keep track of the count of each element using a hashmap.

  • Identify elements with count greater than 1 as duplicates.

  • Return the duplicate elements as the output.

  • Handle edge cases like empty array or no duplicates found.

Frequently asked in,

Q170. How you will find the smallest of 4 numbers without using >.< and min function using java

Ans.

Finding smallest of 4 numbers without using >.< and min function in Java.

  • Initialize a variable with the first number

  • Compare it with the remaining numbers using if-else statements

  • If a smaller number is found, update the variable

  • Repeat until all numbers are compared

  • The final value of the variable will be the smallest number

Q171. Maximise the OR Sum Problem Statement

You are provided with two arrays of positive integers. The goal is to select two sub-arrays of the same length, one from each of the provided arrays, such that the sum of t...read more

Q172. The ages of Raj and Sakshi are in the ratio of 8:7 and on adding their ages we get 60. Determine the ratio of their ages after 6 years.

Ans.

Ratio of ages of Raj and Sakshi is 8:7 and their sum is 60. Find their ratio after 6 years.

  • Let the ages of Raj and Sakshi be 8x and 7x respectively

  • Their sum is 60, so 15x = 60

  • Hence, x = 4

  • After 6 years, Raj's age will be 8x+6 and Sakshi's age will be 7x+6

  • The ratio of their ages after 6 years will be (8x+6):(7x+6)

Q173. Running Median Problem

Given a stream of integers, calculate and print the median after each new integer is added to the stream.

Output only the integer part of the median.

Example:

Input:
N = 5 
Stream = [2, 3,...read more

Q174. Which coding language are you comfortable with?

Ans.

I am comfortable with multiple coding languages including Java, Python, and C++.

  • Proficient in Java, Python, and C++

  • Experience with web development languages such as HTML, CSS, and JavaScript

  • Familiarity with scripting languages like Bash and PowerShell

  • Comfortable with SQL and NoSQL databases

  • Knowledge of machine learning libraries like TensorFlow and Keras

Q175. 3. Given a sorted array from 1 to n like 1,2,3 _ n there might be one number that is repeated so we return true if the array has a repeated number or return false if the array don't have a repeated number

Ans.

Check if a sorted array from 1 to n has a repeated number.

  • Iterate through the array and check if the current element is equal to the next element.

  • If yes, return true. If no, continue iterating.

  • If the loop completes without finding a repeated element, return false.

Q176. What are the uses of OOPS?

Ans.

OOPS is used for creating modular, reusable and maintainable code.

  • Encapsulation: Hiding implementation details and exposing only necessary information.

  • Inheritance: Reusing code and creating a hierarchy of classes.

  • Polymorphism: Using a single interface to represent multiple types of objects.

  • Abstraction: Simplifying complex systems by breaking them down into smaller, more manageable parts.

  • Examples: Java, C++, Python, Ruby, etc.

Q177. What is normalization and what are the different forms of normalization?

Q178. Write the code for rearranging the array in consecutive pair multiplication. For example consider an array with 10 element A0, A1, A2......A9. The resultant array will be A0*A1, A1*A2, A2*A3, and so on. The fin...

read more
Ans.

Rearrange array in consecutive pair multiplication in descending order.

  • Create a new array to store the multiplied values

  • Use a loop to iterate through the original array and multiply consecutive pairs

  • Write a compare function to sort the new array in descending order

Q179. Difference between single and doubly linked list?Why do we prefer doubly over single linked list?

Ans.

Single linked list has one pointer while doubly linked list has two. Doubly linked list is preferred for easier traversal in both directions.

  • Single linked list has only one pointer which points to the next node while doubly linked list has two pointers which point to the next and previous nodes.

  • Doubly linked list allows for easier traversal in both directions, while single linked list only allows for traversal in one direction.

  • Doubly linked list requires more memory due to th...read more

Q180. DSA - Nth Fibonacci no with memoization, Find duplicate node in Linked list, Binary tree DSA questions, Project based tech questions, OOPS, Puzzle

Ans.

Interview questions for Software Engineer position covering DSA, project-based tech questions, OOPS, and puzzle.

  • Be prepared to answer DSA questions such as finding the Nth Fibonacci number with memoization, finding duplicate nodes in a linked list, and binary tree DSA questions.

  • Expect project-based tech questions that may require you to explain your approach to solving a particular problem.

  • Brush up on OOPS concepts and be ready to apply them to real-world scenarios.

  • Be prepare...read more

Q181. what do you know about latest technologi in market,have you any idea about AI(Artificial Intelligence), tell me about about AI and where AI used

Ans.

AI is a technology that enables machines to learn from experience and perform tasks that typically require human intelligence.

  • AI is used in various industries such as healthcare, finance, and transportation

  • AI can be used for natural language processing, image recognition, and predictive analytics

  • Examples of AI include virtual assistants like Siri and Alexa, self-driving cars, and fraud detection systems

  • AI has the potential to revolutionize industries and improve efficiency an...read more

Q182. there is an infinite stair case and there are n rounds. in i'th round we can jump i steps at one or discard them. it is given that k'th step is broken , find the max height we can reach with out stepping on the...

read more
Ans.

Given an infinite staircase with a broken kth step, find the maximum height we can reach in n rounds of jumping i steps.

  • We can start by jumping the maximum number of steps in each round until we reach the broken step.

  • After reaching the broken step, we can discard the i steps that would land us on the broken step and jump the remaining steps.

  • We can continue this pattern until we reach the maximum height we can reach without stepping on the broken step.

Q183. Given a square with side L and a circle is inscribed in it. Find the area in the square except the circle. (Pretty simple apti question)

Ans.

Area of square except inscribed circle

  • Find area of square

  • Subtract area of circle from square

  • Area of square = L^2, Area of circle = pi*(L/2)^2

  • Answer = L^2 - pi*(L/2)^2

Q184. What can you tell me about the Software Development Life Cycle (SDLC), specifically regarding Black Box and White Box testing?
Ans.

Software testing is the process of evaluating a software item to detect differences between given input and expected output.

  • Software testing ensures that the software is bug-free and meets the requirements

  • It involves various types of testing such as functional, performance, security, etc.

  • Testing can be done manually or through automation tools like Selenium, Appium, etc.

Q185. 9. If you need to perform a lot of insertion and delete operations then which Data Structure will you use?

Ans.

I would use a Linked List data structure for frequent insertion and deletion operations.

  • Linked Lists have constant time complexity for insertion and deletion operations.

  • Arrays have a linear time complexity for these operations.

  • Doubly Linked Lists allow for efficient deletion of nodes.

  • Examples of use cases include implementing a queue or stack.

Q186. Do you know about sorting algorithms? What are the types of sorting algorithms? Write them,

Ans.

Sorting algorithms are used to arrange data in a specific order. There are various types of sorting algorithms.

  • Types of sorting algorithms include: bubble sort, selection sort, insertion sort, merge sort, quick sort, heap sort, counting sort, radix sort, and bucket sort.

  • Bubble sort compares adjacent elements and swaps them if they are in the wrong order.

  • Selection sort selects the smallest element and swaps it with the first element, then selects the second smallest and swaps ...read more

Q187. 1. What is a linked list, its advantages and representation

Ans.

A linked list is a data structure that consists of a sequence of nodes, where each node contains a reference to the next node.

  • Advantages of linked list:

  • - Dynamic size: Linked lists can grow or shrink as needed.

  • - Efficient insertion and deletion: Adding or removing elements from a linked list is faster than an array.

  • - Flexibility: Linked lists can be easily modified and reorganized.

  • Representation of a linked list:

  • - Each node contains data and a reference to the next node.

  • - The...read more

Q188. 3. Describe the complete boot up process of a typical machine. 4. Write an assembly program to perform multiplication of 2 numbers without using the MUL operator. 5. C code for inserting into a BST + pen and pa...

read more
Ans.

The boot up process of a typical machine involves several stages, including power-on, BIOS initialization, bootloader loading, kernel loading, and initialization of the operating system.

  • The boot up process starts with the power-on of the machine.

  • The BIOS (Basic Input/Output System) is initialized, which performs a series of hardware checks and initializes the system components.

  • The bootloader is loaded, which is responsible for loading the operating system.

  • The kernel of the op...read more

Q189. Replace 0's in Matrix

Given a matrix in which every element is either 1 or 0, modify the matrix so that each 0 is replaced with a 1 if it is surrounded by 1s on all four sides (above, below, left, and right). C...read more

Q190. What do you think is an area of improvement for you?

Ans.

I need to improve my time management skills.

  • Prioritize tasks based on urgency and importance

  • Set realistic deadlines and stick to them

  • Avoid multitasking and focus on one task at a time

  • Use tools like calendars and to-do lists to stay organized

Q191. Write a code to delete a node from singly linked list where you will be given head and offset of the node to be deleted

Ans.

Code to delete a node from a singly linked list given the head and offset of the node.

  • Traverse the linked list until the node at the given offset is reached.

  • Update the next pointer of the previous node to skip the node to be deleted.

  • Free the memory occupied by the node to be deleted.

Q192. a function returns a float ,the float value may also indicate error/failure in the function.How will u implement it?

Ans.

To indicate error/failure in a function that returns a float, use a special value or an additional parameter.

  • Use a special value like NaN or a negative value to indicate error/failure.

  • Alternatively, add an additional parameter to the function to return an error code or message.

  • Handle the error/failure condition appropriately in the calling code.

Q193. Given a set of n steps. A person can climb one or two steps at a time. Find the number of ways in which one can reach the nth step. (Easy stuff.. I probably wasn't doing good by this time)

Ans.

The number of ways to reach the nth step using 1 or 2 steps at a time.

  • Use dynamic programming to solve this problem

  • Create an array to store the number of ways to reach each step

  • Initialize the first two elements of the array as 1, since there is only one way to reach the first and second steps

  • For each subsequent step, the number of ways to reach it is the sum of the number of ways to reach the previous two steps

  • Return the value at the nth index of the array

Q194. what is binary search tree...given n elements in binary tree....what is max ht of tree...what is search complexity for the case when this ht is max....how can u reduce it?

Ans.

A binary search tree is a data structure where each node has at most two children, and the left child is smaller than the parent while the right child is larger.

  • The maximum height of a binary search tree with n elements is n-1.

  • The search complexity for the case when the height is maximum is O(n).

  • To reduce the search complexity, we can balance the binary search tree using techniques like AVL trees or Red-Black trees.

Q195. Q: What is a Transaction in DBMS and ACID properties? Q: What is Thread and how it is different from the Process? Q: What are some Linux commands. Write any 5 commands? Q: Why sudo is used for commands? Q: Linu...

read more
Ans.

Answers to common technical questions in a software engineering interview

  • A transaction in DBMS is a sequence of operations that must be treated as a single unit of work. ACID properties ensure reliability and consistency of transactions.

  • A thread is a lightweight process that shares memory and resources with other threads in the same process. A process is a separate instance of a program.

  • Common Linux commands include ls, cd, mkdir, rm, and grep.

  • sudo is used to run commands wit...read more

Q196. 7. what is public and private IP. how are they different

Ans.

Public and private IP addresses are used in computer networks. Public IPs are globally unique and accessible from the internet, while private IPs are used within a local network.

  • Public IP is assigned by the Internet Service Provider (ISP) and is used to identify a device on the internet.

  • Private IP is assigned by a local network administrator and is used to identify a device within a local network.

  • Public IPs are globally unique, allowing devices to communicate with each other ...read more

Q197. Write a query to find the employee name who earns maximum salary

Ans.

The query finds the employee name who earns the maximum salary.

  • Use the SELECT statement to retrieve the employee name and salary from the database table.

  • Use the ORDER BY clause to sort the results in descending order based on salary.

  • Use the LIMIT clause to limit the result to only one row.

  • Return the employee name from the query result.

Q198. Find the third largest element from array, give the optimized approach using just half traversal of array.

Ans.

Optimized approach to find third largest element from array using half traversal.

  • Sort the array in descending order and return the element at index 2.

  • Use a max heap to keep track of the top 3 elements while traversing the array.

  • Use two variables to keep track of the second and third largest elements while traversing the array.

  • Divide the array into two halves and find the maximum and second maximum in each half, then compare them to find the third largest element.

Q199. How to write any sentence (given to u ) in mirror image form in java?(ans :by 2 ways 1. reverse string function in string object 2 .by aaray conversion )

Ans.

Two ways to write a sentence in mirror image form in Java: reverse string function and array conversion.

  • Use the reverse() method of the String class to reverse the sentence

  • Convert the sentence to a character array, then swap the first and last characters, second and second-to-last characters, and so on until the middle is reached

  • Example: 'Hello World' becomes 'dlroW olleH'

Q200. How would you clear the 7th bit in a 32 bit register

Ans.

To clear the 7th bit in a 32-bit register, perform a bitwise AND operation with a mask that has all bits set to 1 except the 7th bit.

  • Create a mask with the 7th bit set to 0 and all other bits set to 1

  • Perform a bitwise AND operation between the register and the mask

  • Store the result back in the register

Previous
1
2
3
4
5
6
7
Next
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Interview experiences of popular companies

3.7
 • 10.5k Interviews
3.8
 • 8.2k Interviews
3.6
 • 7.7k Interviews
3.7
 • 5.7k Interviews
3.8
 • 5.6k Interviews
3.7
 • 4.8k Interviews
3.5
 • 3.9k Interviews
3.5
 • 3.8k Interviews
3.8
 • 3k 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 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

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