Q. Explain different software design patterns
asked 2xmediumOOPTechnical2021
Ans. Software design patterns are reusable solutions to common design problems, usually grouped as creational, structural, and behavioural patterns. Creational patterns, like Factory and Singleton, handle object creation. Structural patterns, like Adapter and Decorator, organise relationships between classes. Behavioural patterns, like Observer and Strategy, manage communication and responsibility between objects.
Q. Reverse a linked list
asked 2xeasyLinked listsTechnical2022-2023
Ans. Reverse a linked list by iterating through it and changing each node’s next pointer to point to the previous node. Keep three pointers: previous, current, and next, so you do not lose the rest of the list. At the end, previous is the new head. Time complexity is O(n), space complexity is O(1).
Q. Explain CPU scheduling algorithms
asked 2xeasyOperating systemsTechnical2023-2024
Ans. CPU scheduling algorithms decide which ready process gets the CPU next. Common algorithms include First Come First Served, Shortest Job First, Round Robin, Priority Scheduling and Multilevel Queue. The key trade-off is between throughput, response time, waiting time and fairness, with pre-emptive algorithms allowing the OS to interrupt a running process.
Q. What is the difference between Exception and Error in Java?
asked 2xeasyOOPTechnical2021
Ans. An exception is a condition an application may handle, while an error is a serious problem usually outside the application’s control. Both extend Throwable. Exceptions include checked exceptions like IOException and unchecked ones like NullPointerException. Errors, such as OutOfMemoryError or StackOverflowError, normally indicate the program should not try to recover.
Q. What is the parent class and sibling classes of Exception in Java?
asked 2xeasyOOPTechnical2021
Ans. The parent class of Exception in Java is Throwable, and its main sibling class is Error. Both Exception and Error directly extend Throwable. Exception represents conditions an application may want to handle, while Error represents serious JVM or system problems that applications normally should not try to catch or recover from.
Q. Bulbs and switches puzzle
asked 1xmediumLogical reasoningTechnical2019
Ans. Turn on switch 1 for a few minutes, then turn it off. Turn on switch 2 and enter the room once. The bulb that is on is controlled by switch 2. The bulb that is off but warm is controlled by switch 1. The off, cold bulb is controlled by switch 3.
Q. How do you secure a Web API?
asked 1xmediumNetworkingTechnical2024
Ans. Secure a Web API by using HTTPS, strong authentication, and strict authorisation on every request. The key detail is to verify what the caller is allowed to do for the specific resource, not just that they are logged in. Also validate input, rate limit, log security events, and avoid exposing secrets.
Q. How are errors handled in Java?
asked 1xmediumOOPTechnical2021
Ans. Java handles errors through its exception mechanism, using try, catch, finally, throw and throws. Exceptions are objects in the Throwable hierarchy. Checked exceptions must be declared or caught at compile time, while unchecked exceptions occur at runtime. Serious Error types, such as OutOfMemoryError, are usually not handled by application code.
Q. Debug a given C++ linked list code
asked 1xmediumDebuggingTechnical2024
Ans. I would debug it by checking pointer updates, null checks, and ownership at every link change. The key issue in C++ linked lists is usually losing a node, dereferencing null, or creating a cycle. I would trace head, previous, current, and next pointers manually. This uses the linked list itself and runs in linear time.
Q. Find the diameter of a binary tree
asked 1xmediumTreesTechnical2024
Ans. Use a postorder DFS that returns the height of each subtree and updates a global maximum diameter at every node. For each node, the longest path through it is left height plus right height, measured in edges. Visit each node once, so the time complexity is O(n), with O(h) recursion stack space.
Q. Explain the Diamond Problem in Java
asked 1xmediumOOPTechnical2024
Ans. The Diamond Problem is an ambiguity that happens when a class inherits the same method through two different parent paths. Java avoids it by not allowing multiple inheritance of classes. With interfaces, if two default methods conflict, the implementing class must override the method and choose the behaviour explicitly.
Q. Find the Longest Common Subsequence
asked 1xmediumDynamic programmingTechnical2024
Ans. Use dynamic programming with a 2D table where each cell stores the LCS length for prefixes of the two strings. If characters match, take the diagonal value plus one; otherwise take the maximum of top and left. Backtrack from the bottom-right to build the subsequence. Time is O(nm), space is O(nm).
Q. Perform merge sort on a linked list
asked 1xmediumLinked listsTechnical2023
Ans. Use merge sort by splitting the linked list into two halves with slow and fast pointers, recursively sorting each half, then merging the two sorted lists by relinking nodes. The key detail is to cut the list at the midpoint before recursion. It runs in O(n log n) time and O(log n) stack space.
Q. How would you implement an LRU Cache?
asked 1xmediumDesignTechnical2024
Ans. I would implement it with a hash map plus a doubly linked list. The hash map maps keys to list nodes for O(1) lookup, and the list stores usage order. On get or put, move the node to the front. When capacity is exceeded, remove the tail node, which is least recently used.
Q. Move all zeros to the end of an array
asked 1xmediumArraysTechnical2024
Ans. Use a two-pointer approach to compact all non-zero values at the front, then fill the remaining positions with zero. Keep a write index, scan the array once, and copy each non-zero element to that index. This works in place using the same array, with O(n) time and O(1) extra space.
Q. Explain notations used in UML diagrams
asked 1xmediumUmlTechnical2019
Ans. UML notations are standard symbols used to describe software structure and behaviour. Classes are rectangles with attributes and operations, relationships use lines with arrows for association, inheritance, dependency and aggregation, and behaviour diagrams use actors, use cases, states, messages and activities. The key detail is that notation meaning depends on the diagram type.
Q. Print the bottom view of a binary tree
asked 1xmediumTreesTechnical2024
Ans. Use level order traversal with a horizontal distance for each node, and keep the latest node seen at each distance. Start root at distance 0, left child at -1, right child at +1. A queue stores nodes with distances. After traversal, print map values from smallest to largest distance. Time is O(n log n).
Q. Explain the Dining Philosophers Problem
asked 1xmediumOperating systemsTechnical2023
Ans. The Dining Philosophers Problem is a classic concurrency problem showing how processes can deadlock when they compete for shared resources. Philosophers need two forks to eat, but each fork is shared with a neighbour. If everyone picks up one fork and waits, no one can continue. It illustrates deadlock prevention and resource ordering.
Q. Print a given 2D matrix in spiral order
asked 1xmediumArraysManagerial2019
Ans. Traverse the matrix layer by layer using four boundaries: top, bottom, left, and right. Print the top row, right column, bottom row, and left column, then move the boundaries inward. Check boundaries before printing bottom or left to avoid duplicates. Use no extra data structure beyond the output. Time complexity is O(mn).
Q. Explain slicing and namespace in Python.
asked 1xmediumProgrammingTechnical2023
Ans. Slicing is a way to take part of a sequence, and a namespace is a mapping from names to objects. In Python, slicing uses start, stop and step on strings, lists or tuples, returning selected elements. Namespaces control name lookup, such as local, global, enclosing and built-in scopes.
Q. Detect and remove a loop in a linked list
asked 1xmediumLinked listsTechnical2023
Ans. Use Floyd’s slow and fast pointer method to detect the loop, then remove it by finding the node where the cycle starts and setting the previous node’s next pointer to null. After slow and fast meet, move one pointer to head and advance both one step at a time. Time is O(n), space is O(1).
Q. Detect if a linked list contains a cycle.
asked 1xmediumLinked listsTechnical2016
Ans. Use Floyd’s cycle detection algorithm with two pointers, slow and fast. Move slow by one node and fast by two nodes each step. If they ever meet, the linked list has a cycle. If fast reaches null, there is no cycle. This takes O(n) time and O(1) extra space.
Q. Explain the Java compiler and its working
asked 1xmediumJavaTechnical2019
Ans. The Java compiler, javac, converts Java source code into platform independent bytecode stored in .class files. It checks syntax, types, imports and other compile time rules, then generates bytecode for the JVM. At runtime, the JVM interprets or just in time compiles this bytecode into native machine instructions.
Q. Explain different types of design patterns
asked 1xmediumOOPTechnical2024
Ans. Design patterns are commonly grouped into creational, structural, and behavioural patterns. Creational patterns, such as Factory and Singleton, handle object creation. Structural patterns, such as Adapter and Decorator, organise relationships between classes or objects. Behavioural patterns, such as Observer and Strategy, manage communication, responsibility, and algorithms between objects.
Q. Explain indexers in SQL and their purpose.
asked 1xmediumDBMSTechnical2024
Ans. Indexes in SQL are data structures that let the database find rows faster without scanning the whole table. They are usually built on one or more columns, commonly using a B-tree. They speed up searches, joins, sorting and filtering, but add storage cost and can slow inserts, updates and deletes.
Q. Explain the concept of Dynamic Programming
asked 1xmediumDynamic programmingTechnical2019
Ans. Dynamic Programming is a technique for solving problems by breaking them into smaller overlapping subproblems and storing their results so they are not recomputed. It works when the problem has optimal substructure, meaning an optimal answer can be built from optimal answers to smaller cases, using memoisation or tabulation.
Q. Implement compile-time polymorphism in C++
asked 1xmediumOOPTechnical2024
Ans. Implement compile-time polymorphism in C++ using function overloading, operator overloading, or templates. The compiler selects the correct function or generated template version based on argument types at compile time. The key detail is that binding is static, so there is no virtual dispatch overhead, unlike runtime polymorphism with virtual functions.
Q. Puzzle on dividing shapes into n equal parts
asked 1xmediumLogical reasoningTechnical2021
Ans. There is no single answer without the exact shape and value of n. The standard method is to use area and symmetry: find the total area, divide it by n, then draw cuts so each region has that area. For regular shapes, use centre lines or equal angles. For irregular shapes, use equal-area slicing.
Q. Explain Common Table Expressions (CTE) in SQL.
asked 1xmediumDBMSTechnical2024
Ans. A Common Table Expression is a named temporary result set defined with WITH and used by the following SQL statement. It makes complex queries easier to read by breaking them into logical parts. CTEs can reference other CTEs, and recursive CTEs are useful for hierarchical data such as trees or organisation charts.
Q. Pointer-based element extraction in 2D arrays.
asked 1xmediumPointersOnline test2022
Ans. The element at row i and column j is extracted by dereferencing the address base plus i times the column count plus j. In C-style row-major storage, this works for contiguous 2D arrays. A true 2D array is not the same as an array of pointers. Access time is O(1).
Q. Using two cubes, show all the dates in a month
asked 1xmediumLogical reasoningTechnical2021
Ans. Put 0, 1 and 2 on both cubes, because 01 to 09 need zero paired with every digit, and 11 and 22 need repeated digits. Use 6 upside down as 9. One valid labelling is 0,1,2,3,4,5 and 0,1,2,6,7,8. This covers 01 to 31.
Q. Explain the use of extern and volatile keywords
asked 1xmediumOOPTechnical2024
Ans. extern declares a variable or function that is defined in another translation unit, while volatile tells the compiler that a value may change unexpectedly and must be read or written exactly as requested. extern is mainly for shared global declarations in headers. volatile is used for memory-mapped I/O, signal handlers, or interrupt-updated data, not normal thread synchronisation.
Q. Logical reasoning problems of average difficulty
asked 1xmediumLogical reasoningOnline test2019
Ans. Identify the rule or relationship first, then test it against every option. Break the problem into small parts, such as order, grouping, condition, pattern, or cause and effect. Use elimination to remove impossible answers. For sequences, compare differences or positions. For statements, separate facts from assumptions before choosing.
Q. Explain the working of Decision Tree classifiers.
asked 1xmediumMachine learningTechnical2021
Ans. A Decision Tree classifier predicts a class by asking a sequence of feature-based questions from the root to a leaf. During training, it recursively splits the data to make child nodes as pure as possible, commonly using Gini impurity or information gain. A leaf stores the final predicted class.
Q. How would you approach debugging a complex issue?
asked 1xmediumProblem solvingTechnical2024
Ans. I would debug a complex issue systematically: reproduce it, narrow the scope, form hypotheses, test one change at a time, and use evidence rather than guesses. The most important detail is isolating the smallest failing case, because it makes logs, traces, recent changes, and assumptions much easier to verify.
Q. Check whether a given Linked List is a palindrome.
asked 1xmediumLinked listsTechnical2022
Ans. Use two pointers to find the middle, reverse the second half of the linked list, then compare it node by node with the first half. The key detail is restoring the reversed half afterwards if the list must remain unchanged. This uses constant extra space and takes O(n) time.
Q. What is a virtual destructor and why is it needed?
asked 1xmediumOOPTechnical2024
Ans. A virtual destructor is a destructor declared virtual in a base class so destruction is dispatched dynamically. It is needed when objects may be deleted through a base class pointer, because it ensures the derived destructor runs first, then the base destructor. Without it, behaviour is undefined and resources may leak.
Q. Why is multiple inheritance not supported in Java?
asked 1xmediumOOPTechnical2019
Ans. Java does not support multiple inheritance of classes to avoid ambiguity and complexity, especially the diamond problem where two parent classes define the same member. Instead, Java allows a class to implement multiple interfaces, giving multiple inheritance of type while keeping implementation inheritance simpler and safer.
Q. Detect whether a cycle exists in an undirected graph
asked 1xmediumGraphsTechnical2022
Ans. Use DFS or BFS and track the parent of each visited vertex. When exploring an edge to a neighbour, if the neighbour is already visited and is not the current vertex’s parent, a cycle exists. For disconnected graphs, start traversal from every unvisited vertex. Time complexity is O(V + E), using O(V) space.
Q. Low-level design discussion for a software component
asked 1xmediumLldSystem design2022
Ans. Start by fixing the component’s responsibilities, public API, data model, and main flows, then discuss classes, interfaces, storage, errors, and concurrency. The most important detail is keeping boundaries clear: the component should expose simple operations, hide internal state, validate inputs, and be easy to test or replace without affecting callers.
Q. Solve logical reasoning problems under time pressure
asked 1xmediumLogical reasoningOnline test2016
Ans. Work quickly by identifying the rule, not by testing every option. Note key facts, translate words into simple symbols or diagrams, and eliminate choices that break the conditions. For sequences, compare changes; for arrangements, fix definite positions first. If stuck, skip and return after easier questions.
Q. Find the longest substring with all unique characters
asked 1xmediumStringsTechnical2024
Ans. Use a sliding window with two pointers and a set or map of characters to track the current substring. Move the right pointer to expand, and when a duplicate appears, move the left pointer until the window is unique again. Track the maximum length seen. Time complexity is O(n), space is O(k).
Q. What are the different types of dependency injection?
asked 1xmediumOOPTechnical2024
Ans. The main types of dependency injection are constructor injection, setter or property injection, and method injection. Constructor injection is usually preferred for required dependencies because it makes objects valid at creation time and supports immutability. Setter or property injection suits optional dependencies, while method injection provides a dependency only for a specific operation.
Q. Why does a static constructor have only one instance?
asked 1xmediumOOPTechnical2024
Ans. A static constructor does not have an instance because it belongs to the type, not to any object. It is used to initialise static members and is called automatically by the runtime once, before the type is first used. Since static data is shared, multiple constructor instances would be unnecessary and unsafe.
Q. Answer verbal reasoning questions within a limited time
asked 1xmediumVerbalOnline test2016
Ans. Read the question first, then scan the passage for the exact information needed. Do not rely on outside knowledge or assumptions. For true, false, cannot say questions, choose only what is directly supported. Manage time by skipping difficult items and returning later. Eliminate clearly wrong options quickly.
Q. How do you remove the third record from a table in SQL?
asked 1xmediumDBMSTechnical2024
Ans. Delete the row identified as third only after defining an order, usually by selecting the third row’s primary key with an ORDER BY and deleting by that key. SQL tables have no natural row order, so “third record” is meaningless unless you specify ordering. If you mean id 3, delete where the primary key equals 3.
Q. Demonstrate inheritance (all types) with hands-on coding
asked 1xmediumOOPTechnical2024
Ans. Implement inheritance by creating a base class, then deriving classes to show single, multilevel, hierarchical, multiple, and hybrid inheritance. For example, use Animal to Dog, Animal to Mammal to Dog, Animal to Dog and Cat, and interfaces for Flyable and Swimmable. In Java, multiple inheritance uses interfaces. Method calls are constant time.
Q. Implement the Shell Sort algorithm and perform a dry run
asked 1xmediumSortingTechnical2023
Ans. Shell Sort repeatedly performs gapped insertion sort, starting with a large gap and reducing it to 1. For array [8, 5, 3, 7, 6, 2], use gaps 3, 1. Gap 3 compares pairs: [7, 5, 2, 8, 6, 3]. Gap 1 finishes insertion sort: [2, 3, 5, 6, 7, 8]. Average time is about O(n log² n), worst depends on gaps.
Q. How does Java overcome the issue of multiple inheritance?
asked 1xmediumOOPTechnical2019
Ans. Java avoids the problems of multiple inheritance by not allowing a class to extend more than one class. Instead, it supports multiple inheritance of type through interfaces. A class can implement many interfaces, and if default methods conflict, the class must override the method explicitly, avoiding the diamond problem.
Q. Explain DBSCAN clustering and its advantages over K-Means.
asked 1xmediumMachine learningTechnical2021
Ans. DBSCAN clusters points by density, growing groups from points that have enough neighbours within a chosen radius. Its main advantage over K-Means is that it does not require the number of clusters in advance and can find irregularly shaped clusters. It also identifies noise and outliers instead of forcing every point into a cluster.
Q. How can you improve the performance of an MVC application?
asked 1xmediumSystem designTechnical2024
Ans. Improve an MVC application by reducing work per request and making expensive work cacheable or asynchronous. Use output, data, and fragment caching where suitable, optimise database queries with indexing and eager loading, minimise view rendering cost, bundle and compress static assets, use async I/O, and profile first so changes target the real bottleneck.
Q. Find the Lowest Common Ancestor (LCA) of two nodes in a Binary Tree
asked 1xmediumTreesTechnical2022
Ans. Use a recursive depth first search: if the current root is null or equals either target node, return it. Search left and right subtrees. If both return non-null, the current root is the LCA; otherwise return the non-null side. This uses the call stack, with linear time and tree-height space.
Q. How do you identify bottlenecks in your projects and structure solutions?
asked 1xmediumProblem solvingHR2022
Ans. Pick a project where progress was visibly blocked and you had data to diagnose it. Emphasise how you separated symptoms from root causes, used metrics, feedback, or process mapping, then prioritised fixes by impact and effort. Interviewers listen for structured thinking, ownership, collaboration, and evidence that your solution improved delivery.
Q. Tell me about a time you faced a technical challenge. How did you overcome it?
asked 1xmediumProblem solvingManagerial2024
Ans. Choose a real, specific challenge where the problem was difficult but the outcome was positive. Emphasise how you diagnosed the issue, sought input, tested options, and stayed calm under pressure. Interviewers listen for structured thinking, ownership, collaboration, persistence, and learning, not just technical knowledge or a perfect result.
Q. Describe the challenges you faced in the past few months and how you overcame them.
asked 1xmediumConflict resolutionTechnical2021
Ans. Choose a recent, work-related challenge with real stakes, not personal drama or blame. Emphasise the context, your specific responsibility, the action you took, and the measurable result. Interviewers listen for resilience, ownership, sound judgement, communication under pressure, and evidence that you learned something useful from the experience.
Q. If you had to design a high-quality telephone as a product, what factors would you consider?
asked 1xmediumProduct designTechnical2024
Ans. I would prioritise clear, reliable communication, then design around audio quality, network performance, battery life, durability, usability, accessibility, privacy, cost and supportability. The most important detail is end-to-end call quality in real conditions, including microphones, speakers, noise cancellation, antenna design and graceful behaviour on weak networks.
Q. Design an object-oriented program to represent shapes ranging from a point to an n-sided polygon, supporting operations like area calculation.
asked 1xmediumOOPTechnical2016
Ans. Use a Shape interface with an area method, then implement Point, Line, Triangle, Rectangle and Polygon as separate classes. Point and Line return zero area. Polygon stores an ordered list of vertices and uses the shoelace formula, giving O(n) time. The key detail is validating vertices and ordering them consistently.
Q. Given two sorted arrays, find the median
asked 1xhardArraysTechnical2024
Ans. Use binary search on the smaller array to find a partition where the left halves of both arrays contain half the total elements and every left value is less than or equal to every right value. The median is then the max of left values, or the average of max left and min right. Time is O(log min(m,n))).
Q. Compare SQL and NoSQL databases
asked 1xeasyDBMSTechnical2023
Ans. SQL databases are relational, schema based, and use SQL for structured queries, while NoSQL databases use models such as document, key value, column, or graph for more flexible data. SQL usually gives strong consistency and joins; NoSQL is often chosen for horizontal scaling, high throughput, and changing data structures.
Q. Explain ACID properties in DBMS.
asked 1xeasyDBMSTechnical2021
Ans. ACID properties are the guarantees that make database transactions reliable: Atomicity, Consistency, Isolation and Durability. Atomicity means all or nothing, Consistency keeps valid rules, Isolation prevents concurrent transactions interfering, and Durability ensures committed changes survive crashes. They are essential for correctness in systems handling critical data.
Showing 60 of 290 questions. Ranked by how often the same question came back across interviews.