Software Engineer
1000+ Software Engineer Interview Questions and Answers for Freshers
Q201. System design of BookMyShow. Design the algorithm and database for the seat booking system. How this the system will handle the case when the payment gets failed. Again he asked me to write the query for the ti...
read moreDesign algorithm and database for seat booking system of BookMyShow and handle failed payments.
Create a database with tables for movies, theaters, seats, bookings, and payments
Use a locking mechanism to prevent double booking of seats
If payment fails, release the locked seats and notify the user
Write a query to get the timestamp in SQL: SELECT CURRENT_TIMESTAMP;
Q202. What are the things other than indexes and tables present in a dbms? (Ans - Views, .. etc.)
Other than indexes and tables, a DBMS also includes views, stored procedures, triggers, and functions.
Views: Virtual tables that are based on the result of a query. They provide a way to simplify complex queries and restrict access to data.
Stored Procedures: Precompiled sets of SQL statements that can be executed with a single command. They enhance performance and allow for code reusability.
Triggers: Special types of stored procedures that are automatically executed when a sp...read more
Q203. What is SDLC(Software Development Life Cycle) and what are it's phases?
SDLC is a process followed by software development teams to design, develop and test high-quality software.
SDLC stands for Software Development Life Cycle
It consists of several phases including planning, analysis, design, implementation, testing, and maintenance
Each phase has its own set of activities and deliverables
The goal of SDLC is to produce high-quality software that meets customer requirements and is delivered on time and within budget
Examples of SDLC models include W...read more
Q204. What is virtual memory ? Why is it called virtual ? Whats the area of hard disk where pages are replaced to, called?
Virtual memory is a memory management technique that allows the operating system to use a combination of RAM and hard disk space.
Virtual memory is a way for the operating system to provide more memory to applications than what is physically available in RAM.
It creates an illusion of a larger memory space by using a portion of the hard disk as an extension of RAM.
Virtual memory allows multiple processes to run simultaneously without the need for physical memory to accommodate ...read more
Q205. wht ll be the size of struct abc{ int a; char b; short c;}; ? how will they be arranged when they are allocated memory?
The size of struct abc will be 8 bytes. The members will be arranged in the order of declaration.
The struct abc has three members: int a, char b, and short c.
The size of int is typically 4 bytes, char is 1 byte, and short is 2 bytes.
The total size of the struct is the sum of the sizes of its members, which is 4 + 1 + 2 = 7 bytes.
However, due to memory alignment and padding, the size of the struct will be rounded up to the nearest multiple of the largest member's size, which i...read more
Q206. What determines the padding size for the last member of the struct ? (We discussed this for half an hour probably !!)
The padding size for the last member of a struct is determined by the alignment requirements of the struct.
Padding is added to ensure that each member of the struct is properly aligned in memory.
The padding size depends on the size and alignment requirements of the previous members.
The compiler may also consider the target architecture and optimization settings when determining padding size.
Share interview questions and help millions of jobseekers 🌟
Q207. What is an Agile Model?
Agile Model is an iterative approach to software development that emphasizes flexibility and customer satisfaction.
Agile Model involves continuous collaboration between cross-functional teams and customers
It prioritizes working software over comprehensive documentation
It allows for changes and adjustments to be made throughout the development process
Examples of Agile methodologies include Scrum, Kanban, and Extreme Programming (XP)
Q208. Write a program for login page with using session Database design for one example given by interviewer Palindrome program
Program for login page with session and palindrome program
Create a login page with HTML and CSS
Use PHP to handle form submission and validate user credentials
Create a session for the logged-in user
Design a database to store user information
Write a program to check if a given string is a palindrome
Software Engineer Jobs
Q209. Time complexity of different types of sorting technique?Which one is most efficient one?
Sorting techniques and their time complexity
Bubble sort - O(n^2)
Selection sort - O(n^2)
Insertion sort - O(n^2)
Merge sort - O(n log n)
Quick sort - O(n log n)
Heap sort - O(n log n)
Radix sort - O(nk)
Most efficient: Quick sort or Merge sort
Efficiency depends on the size of the array and the data distribution
Q210. Make a set of all nodes that can occur in any path from a source to a destination in both directed as well as undirected graph. Note that a node can be visited any number of times not necessarily only once.
The set of all nodes that can occur in any path from a source to a destination in both directed and undirected graphs.
Perform a depth-first search (DFS) or breadth-first search (BFS) from the source node to the destination node.
During the search, keep track of all visited nodes.
Add each visited node to the set of nodes that can occur in any path.
Repeat the search for both directed and undirected graphs.
The resulting set will contain all nodes that can occur in any path from t...read more
Q211. Logic for a program to sort an array in which we have an array of infinite length but contains only three elements like -1, 0,1.
Sorting an array of infinite length with only three elements (-1, 0, 1)
Use counting sort algorithm to count the frequency of each element
Create a new array with sorted elements based on their frequency
Time complexity is O(n) and space complexity is O(1)
Example: [-1, 1, 0, 1, -1, 0, 1, -1, 0, 1, ...]
Q212. what is basic difference between c and cpp. explain on memory levels
C is a procedural programming language while C++ is an object-oriented programming language.
C is a procedural programming language, meaning it focuses on procedures or functions.
C++ is an extension of C and adds object-oriented features like classes and inheritance.
C++ supports polymorphism, encapsulation, and abstraction, which C lacks.
C++ allows the use of standard template library (STL) for data structures and algorithms.
C++ has exception handling mechanisms, whereas C doe...read more
Q213. Write a program for reversing a string without using string function
Program to reverse a string without using string function
Iterate through the string from end to start and append each character to a new string
Use a loop to swap the first and last characters, then move towards the middle until the entire string is reversed
Convert the string to a character array, then swap the first and last elements until the entire array is reversed
Q214. struct abc{ int a; int b; char c;}; wht is the size of the structure? how will the members be allocated memory?
The size of the structure is 12 bytes. The members will be allocated memory based on their data types.
The structure 'abc' has three members: 'a' of type int, 'b' of type int, and 'c' of type char.
The size of int is typically 4 bytes and the size of char is typically 1 byte.
The total size of the structure is calculated by summing the sizes of its members.
In this case, 4 bytes for 'a', 4 bytes for 'b', and 1 byte for 'c', resulting in a total of 12 bytes.
The members will be all...read more
Q215. 17. How to add a new column to an existing table, what is the command for that?
To add a new column to an existing table, use the ALTER TABLE command.
Use the ALTER TABLE command followed by the table name.
Use the ADD keyword followed by the new column name and its data type.
Example: ALTER TABLE table_name ADD column_name data_type;
Make sure to specify any additional constraints or default values for the new column.
Q216. Can we pass arguments in place of args... In string [] args .
Yes, we can pass arguments in place of args in string[] args.
Arguments can be passed directly as an array of strings.
The number of arguments passed must match the size of the array.
Example: public static void main(String[] args) can be called as main(new String[] {"arg1", "arg2"});
Q217. why are manhole covers round in shape and why not in square
Manhole covers are round because they cannot fall through the hole they cover and are easier to move.
Round covers cannot fall through the hole they cover, unlike square covers which can fall diagonally.
Round covers are easier to move as they can be rolled instead of lifted.
Round covers are also more aesthetically pleasing and symmetrical.
Square covers may also have sharp corners which can be dangerous to pedestrians and vehicles.
Q218. Are you comfortable using Command Line Interfaces (CLIs) or Integrated Development Environments (IDEs) as part of your daily tasks?
Yes, I am comfortable using both CLIs and IDEs for my daily tasks.
I have experience using various CLIs such as Git Bash, Windows Command Prompt, and Terminal on macOS.
I am proficient in using IDEs such as Visual Studio Code, Eclipse, and IntelliJ IDEA.
I understand the benefits and drawbacks of both CLIs and IDEs and can choose the appropriate tool for the task at hand.
Q219. What are keys in database and why do we use them?
Keys in a database are unique identifiers used to establish relationships between tables and ensure data integrity.
Keys are used to uniquely identify records in a database table.
Primary keys are used to uniquely identify each record in a table.
Foreign keys establish relationships between tables.
Keys help enforce data integrity and maintain consistency in the database.
Examples of keys include primary keys, foreign keys, and unique keys.
Q220. You have knowledge of data structure? Tell me about it
Data structures are a way to organize and store data efficiently.
Data structures are used to store and manipulate data in a structured manner.
They provide different ways to access and perform operations on the data.
Examples include arrays, linked lists, stacks, queues, trees, and graphs.
Q221. 10. An array contains numbers from 1 to n. All the numbers occur twice in the array except any one element. Find the element which occurs only once.
Find the element that occurs only once in an array of numbers from 1 to n with all other numbers occurring twice.
Use XOR operation to find the unique element.
Iterate through the array and XOR each element with the result.
The final result will be the unique element.
Q222. Given many pairs intervals with their start and end. Find the maximum interval which intersects the maximum number of intervals. Look for corner cases again!
Find the maximum interval that intersects the maximum number of intervals.
Sort the intervals based on their start times.
Iterate through the sorted intervals and keep track of the current interval with the maximum number of intersections.
Update the maximum interval whenever a new interval intersects more intervals than the current maximum interval.
Q223. What are indexes , example, Is it possible to have more than one clustered index and more than one non clustered index ?
Indexes are used to improve query performance. Multiple clustered and non-clustered indexes can be created on a table.
Indexes are used to quickly locate data without scanning the entire table.
Clustered index determines the physical order of data in a table.
Non-clustered index is a separate structure that contains a copy of the indexed columns and a pointer to the actual data.
A table can have only one clustered index, but multiple non-clustered indexes.
Indexes should be create...read more
Q224. how do you take 4 liters from a 2 liter and 5 liter jugs
You cannot take 4 liters from a 2 liter and 5 liter jugs.
It is not possible to take 4 liters from a 2 liter and 5 liter jugs.
The combined capacity of the two jugs is less than 4 liters.
You would need a larger jug or a different approach to obtain 4 liters.
Q225. -a try block throws an exception which is caught by catch()...how the throw() is internally implemented
The throw() statement is internally implemented by creating an exception object and transferring control to the catch() block.
When a throw() statement is executed, an exception object is created.
The exception object contains information about the type of exception and any additional data.
The control is then transferred to the nearest catch() block that can handle the exception.
The catch() block can access the exception object and perform appropriate actions.
If no catch() bloc...read more
Q226. how static and global variables work- when they are declared inside and when they are declared outside the functions
Static and global variables have different scopes and lifetimes depending on where they are declared.
Static variables declared inside a function retain their value between function calls.
Static variables declared outside any function have file scope and are accessible within the file.
Global variables have global scope and can be accessed from any part of the program.
Global variables are initialized only once and retain their value throughout the program execution.
Q227. Represent numbers using linked list. How would you add two numbers represented in linked list form. Length of numbers can be different
Adding two numbers represented as linked lists with different lengths.
Traverse both linked lists simultaneously, adding corresponding digits and carrying over the carry.
If one list is shorter, consider the remaining digits as 0.
Create a new linked list to store the result.
Handle the case when the sum of digits exceeds 9 by carrying over the digit to the next place value.
If there is a carry after adding all digits, add an additional node to the result linked list.
Q228. Write a program to binary to decimal and decimal to binary
A program to convert binary to decimal and decimal to binary.
For binary to decimal conversion, iterate through each digit of the binary number and multiply it by 2 raised to the power of its position.
For decimal to binary conversion, repeatedly divide the decimal number by 2 and keep track of the remainders.
Use the modulo operator (%) to get the remainder and the division operator (/) to get the quotient.
Q229. 12. What is abstraction? Explain abstract class and interface - the difference between them.
Abstraction is a way of hiding implementation details and showing only necessary information to the user.
Abstract class is a class that cannot be instantiated and can have both abstract and non-abstract methods.
Interface is a collection of abstract methods and constants that can be implemented by any class.
Abstract classes can have constructors, while interfaces cannot.
A class can implement multiple interfaces, but can only inherit from one abstract class.
Abstraction helps in...read more
Q230. 15. What is a constructor and a destructor and how to represent them?
Constructor and destructor are special member functions in a class that are used to initialize and destroy objects respectively.
Constructor is called when an object is created and is used to initialize the object's data members.
Destructor is called when an object is destroyed and is used to free up any resources allocated by the object.
Constructor has the same name as the class and no return type, while destructor has the same name as the class preceded by a tilde (~) and no ...read more
Q231. Create some dynamic buttons with a json data and whenever you click on that you need to maintain active and inactive states and also you need to show the content of the button based on the json data whenever yo...
read moreCreate dynamic buttons with JSON data, maintain active/inactive states, and show content on click
Create buttons dynamically using JSON data
Toggle between active and inactive states on click
Display button content based on JSON data on click
Q232. How could you solve problem of customer without customer care help?
By providing self-service options and resources, such as FAQs and online documentation.
Create a comprehensive FAQ section on the company's website
Develop an online knowledge base with step-by-step guides and troubleshooting tips
Offer live chat support with automated responses and chatbots
Provide video tutorials and instructional videos
Implement a community forum where customers can help each other
Q234. How many programming languages do you know?
I know multiple programming languages.
I am proficient in Java, Python, and C++.
I have experience with web development languages such as HTML, CSS, and JavaScript.
I am familiar with scripting languages like Bash and PowerShell.
I have worked with database query languages like SQL.
I have knowledge of mobile app development languages like Swift and Kotlin.
Q235. eliminate repeated array from the given string
To eliminate repeated array from a given string
Convert the string to an array using split() method
Use Set object to remove duplicates from the array
Convert the array back to string using join() method
Q236. OOPS 1: Difference between Method overloading and method overriding 2: What is inheritance and it's benifits 3: Define encapsulation and Abstraction.
Questions related to OOPS concepts in software engineering.
Method overloading is having multiple methods with the same name but different parameters, while method overriding is having a method in a subclass with the same name and parameters as a method in its superclass.
Inheritance is the ability of a class to inherit properties and methods from its parent class. It allows for code reuse and promotes modularity.
Encapsulation is the practice of hiding the internal details of a...read more
Q237. What is a Tree/binary search tree, How to perform add, delete operation in BST, whats the time complexity, asked to write complete code on paper
BST is a binary tree where left child is smaller and right child is greater. Add/delete ops maintain this property.
BST is a data structure used for searching, sorting, and storing data
Add operation: Traverse the tree and find the appropriate position to insert the new node
Delete operation: Find the node to be deleted, replace it with its inorder successor or predecessor, and delete the successor/predecessor node
Time complexity: O(log n) for both add and delete operations
Code ...read more
Q238. 4. Given a string as an input, write a code to print the string in a manner such that a character that comes first in the string displays first with all occurrences in the string
Print a string with all occurrences of the first character first.
Loop through the string and count the occurrences of the first character.
Print the first character that many times, then print the rest of the string.
Q239. What are acid properties , how two transactions occur simultaneously while maintaining Acid properties
ACID properties ensure database transactions are reliable. Two transactions can occur simultaneously using locking and isolation.
ACID stands for Atomicity, Consistency, Isolation, and Durability.
Atomicity ensures that a transaction is treated as a single unit of work, either all or none of it is executed.
Consistency ensures that a transaction brings the database from one valid state to another.
Isolation ensures that concurrent transactions do not interfere with each other.
Dur...read more
Q240. What set in java and what is difference between hash set and map
Set is a collection interface in Java. HashSet and HashMap are two different implementations of Set.
Set is an interface that extends Collection interface.
HashSet is an implementation of Set that uses a hash table to store elements.
HashMap is an implementation of Map that uses a hash table to store key-value pairs.
HashSet does not allow duplicate elements while HashMap allows duplicate values but not duplicate keys.
HashSet uses only one object to store elements while HashMap u...read more
Q241. Given two sorted arrays find of size n and m. The n sized array has m spaces empty at the end. Code to merge these to arrays in single pass O(n+m).
Merge two sorted arrays with empty spaces at the end in a single pass.
Initialize two pointers at the end of each array
Compare the elements at the pointers and place the larger element at the end of the merged array
Decrement the pointer of the array from which the larger element was taken
Repeat until all elements are merged
Q242. how ll u implement a queue using a stack, u can use only push n pop
A queue can be implemented using a stack by using two stacks and simulating the enqueue and dequeue operations.
Create two stacks, stack1 and stack2.
For enqueue operation, push the element onto stack1.
For dequeue operation, if stack2 is empty, pop all elements from stack1 and push them onto stack2. Then pop the top element from stack2.
This ensures that the first element pushed onto stack1 is the first element to be popped from stack2, simulating a queue.
Q243. synchronisation and locks - given 2 threads...print out 1 to 10 such that 1 thread shud print all odd nos and other should print even nos
The question is about synchronizing two threads to print odd and even numbers from 1 to 10.
Use synchronization mechanisms like locks or semaphores to ensure only one thread prints at a time
Create two separate functions for printing odd and even numbers
Use a shared variable to keep track of the current number being printed
Use a loop to iterate from 1 to 10 and call the appropriate function based on the current number
Q244. Write a program to swap two numbers without using third variable
Program to swap two numbers without using third variable
Use the XOR operation to swap the numbers
Assign the first number to the second number using XOR
Assign the second number to the first number using XOR
Q245. explain what is deadloacks and ways to prevent them
Deadlocks are situations where two or more processes are unable to proceed because each is waiting for the other to release a resource.
Deadlocks occur when multiple processes are stuck in a circular waiting state.
Prevention techniques include resource allocation strategies, deadlock detection, and avoidance algorithms.
Examples of prevention techniques are using a resource allocation graph, implementing a banker's algorithm, and employing timeouts and resource preemption.
Q246. What version of language and framework did you use in project
We used Python 3.7 and Django 2.2 framework for the project.
Python 3.7 was used as the programming language
Django 2.2 was used as the web framework
We also used other libraries and tools such as Pandas, NumPy, and Git
The project was developed using Agile methodology
Q247. 23. Water Jug Puzzle: You are given 2 Jugs, one is 4 and the other of 7 Gallon and you need to measure x gallons of water.
Measure x gallons of water using 4 and 7 gallon jugs.
Fill 7 gallon jug completely
Pour water from 7 gallon jug to 4 gallon jug until it's full
Remaining water in 7 gallon jug = 3 gallons
Empty 4 gallon jug and pour the 3 gallons from 7 gallon jug to 4 gallon jug
Fill 7 gallon jug again and pour water to fill the remaining space in 4 gallon jug
Remaining water in 7 gallon jug = x - 3 gallons
Q248. Implementation of all linked list operations from scratch and reverse it.
Implementing all linked list operations from scratch and reversing it.
Start by creating a Node class with data and next pointer
Implement insert, delete, search, and traverse operations
To reverse the linked list, use three pointers to reverse the direction of the links
Make sure to handle edge cases such as empty list and single node list
Q249. Can paging be implemented completely in OS, thus, removing paging hardware?
No, paging cannot be implemented completely in the OS without paging hardware.
Paging is a hardware feature that allows the operating system to manage memory efficiently.
Without paging hardware, the OS would not have the necessary mechanisms to map virtual addresses to physical addresses.
Paging hardware includes components like the Memory Management Unit (MMU) and Translation Lookaside Buffer (TLB).
These hardware components are responsible for translating virtual addresses to ...read more
Q250. Can you assign variable value to a static variable during initialization ?
Yes, a variable value can be assigned to a static variable during initialization.
Static variables are initialized only once, at the start of the program.
The value assigned to a static variable during initialization can be a constant or the result of an expression.
The assigned value can be changed later in the program, but it will retain its value between function calls.
Static variables are useful for preserving data across multiple function calls.
Interview Questions of Similar Designations
Top Interview Questions for Software Engineer Related Skills
Interview experiences of popular companies
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
Reviews
Interviews
Salaries
Users/Month