Q. Write a program to swap two numbers without using a third variable.
asked 4xeasyMathTechnical2019-2024
Ans. Swap them using arithmetic: set the first number to the sum of both, set the second to the new first minus the second, then set the first to the new first minus the new second. This uses constant space and constant time. The key caveat is integer overflow, so a temporary variable is usually safer.
Q. Check whether a given string is a palindrome
asked 2xeasyStringsTechnical2019-2023
Ans. Use two pointers, one at the start of the string and one at the end, and compare characters while moving inward. If any pair differs, it is not a palindrome; if the pointers meet or cross, it is. This uses no extra data structure and runs in O(n) time with O(1) space.
Q. Check whether a given number is a prime number
asked 2xeasyMathOnline test, Technical2022-2024
Ans. A number is prime if it is greater than 1 and has no divisors other than 1 and itself. Handle n less than or equal to 1 as not prime, then test divisibility only up to the square root of n. This uses constant space and runs in O(sqrt n) time.
Q. Explain core Object-Oriented Programming (OOP) concepts
asked 2xeasyOOPTechnical2024
Ans. Core OOP concepts are encapsulation, abstraction, inheritance and polymorphism. Encapsulation keeps data and behaviour together and controls access. Abstraction exposes only essential details. Inheritance lets classes reuse and extend behaviour. Polymorphism lets different objects be used through a common interface, with each providing its own implementation.
Q. Floor Sum problem
asked 1xmediumMathOnline test2019
Ans. Compute the floor sum using Euclidean recursion on n, m, a and b, summing contributions when a or b exceed m, then transforming the remaining problem by swapping roles of modulus and slope. No data structure is needed. The key detail is avoiding iteration over n, giving O(log max(a, b, m)) time.
Q. Ant-triangle puzzle.
asked 1xmediumLogical reasoningTechnical2019
Ans. Each ant has two choices: clockwise or anticlockwise, so there are 2³ = 8 equally likely direction patterns. They avoid collision only if all three choose the same direction, giving 2 safe cases. So the probability of no collision is 2/8 = 1/4, and collision is 3/4.
Q. 3 Bulbs and 3 Switches puzzle
asked 1xmediumLogical reasoningManagerial2019
Ans. Turn on switch 1 for several minutes, then turn it off. Turn on switch 2 and leave switch 3 off. Enter the bulb room. The lit bulb is controlled by switch 2. The unlit but warm bulb is controlled by switch 1. The unlit and cold bulb is controlled by switch 3.
Q. Explain SQL Injection in brief
asked 1xmediumDBMSTechnical2022
Ans. SQL injection is an attack where untrusted input is inserted into an SQL query so the attacker can change what the query does. It can expose, modify, or delete data, bypass login checks, or run harmful database commands. The key prevention is using parameterised queries or prepared statements, not string concatenation.
Q. Sort an array using Merge Sort
asked 1xmediumSortingManagerial2022
Ans. Use divide and conquer: recursively split the array into two halves until each part has one element, then merge sorted halves back together by comparing front elements. The key data structure is a temporary array used during merging. Merge Sort runs in O(n log n) time and uses O(n) extra space.
Q. Explain async/await in JavaScript.
asked 1xmediumJavaScriptTechnical2019
Ans. async and await are JavaScript syntax for working with Promises in a cleaner, more synchronous-looking way. An async function always returns a Promise, and await pauses execution inside that function until the Promise settles. It does not block the main thread, and errors can be handled with try and catch.
Q. Explain table partitioning in SQL.
asked 1xmediumSQLTechnical2024
Ans. Table partitioning in SQL splits a large logical table into smaller physical parts, called partitions, while applications still query it as one table. Partitions are usually based on range, list, hash, or date columns. The key benefit is performance and manageability, because queries can scan only relevant partitions and maintenance can target smaller data sets.
Q. Explain garbage collection in Java.
asked 1xmediumMemory managementTechnical2023
Ans. Garbage collection in Java is automatic memory management that finds objects no longer reachable by the program and reclaims their heap memory. The key point is reachability from roots such as stack variables, static fields and active threads. It reduces manual memory errors, but collection timing is not deterministic and may briefly pause execution.
Q. What are lifecycle methods in Spring Boot?
asked 1xmediumSpringTechnical2023
Ans. Spring Boot lifecycle methods are hooks that run at key points when beans or the application start and stop. Common bean hooks are @PostConstruct for initialisation and @PreDestroy for cleanup. Alternatives are InitializingBean, DisposableBean, custom init and destroy methods, and ApplicationRunner or CommandLineRunner for code after startup.
Q. Fill-in-the-blank SQL queries in PostgreSQL
asked 1xmediumSQLOnline test2024
Ans. Fill the blanks by following PostgreSQL’s logical query order: FROM and JOIN, WHERE, GROUP BY, HAVING, SELECT, then ORDER BY and LIMIT. The key detail is to match each blank to its role, such as filtering rows with WHERE, filtering groups with HAVING, and using aggregates only after grouping.
Q. What are SQL triggers and how do they work?
asked 1xmediumSQLTechnical2024
Ans. SQL triggers are database routines that run automatically when a specified event occurs on a table or view, such as an insert, update, or delete. They can run before or after the event, and are often used for validation, auditing, maintaining derived data, or enforcing rules close to the data.
Q. Measure 45 minutes using two identical wires
asked 1xmediumLogical reasoningManagerial2019
Ans. Assuming each wire takes 60 minutes to burn, light the first wire at both ends and the second at one end. The first wire burns out in 30 minutes. At that moment, light the other end of the second wire. Its remaining burn time is 30 minutes, so burning from both ends takes 15 more minutes: 45 total.
Q. How do you detect and fix memory leaks in iOS?
asked 1xmediumOOPTechnical2023
Ans. Detect iOS memory leaks with Xcode’s Memory Graph Debugger and Instruments, especially Leaks and Allocations, then fix the ownership causing objects to stay alive. Most leaks are retain cycles, so check closures, delegates, timers, observers and subscriptions, use weak or unowned references where appropriate, and confirm deinit is called.
Q. When should we use unowned references in Swift?
asked 1xmediumOOPTechnical2023
Ans. Use unowned references when avoiding a strong reference cycle and the referenced object is guaranteed to outlive the reference. They are non-optional and do not become nil automatically. If the object has been deallocated and you access an unowned reference, the program crashes, so use weak when lifetime is uncertain.
Q. How do you handle failure within a team project?
asked 1xmediumConflict resolutionManagerial2019
Ans. Pick a real team setback where you shared responsibility, not blamed others. Emphasise how you identified the issue, communicated early, supported the team, helped agree corrective actions, and captured lessons afterwards. Interviewers listen for accountability, calm problem solving, collaboration, resilience, and evidence that failure led to improved ways of working.
Q. What are abstract classes and virtual functions?
asked 1xmediumOOPTechnical2023
Ans. Abstract classes define a common interface or partial implementation that cannot be instantiated directly, while virtual functions allow derived classes to override behaviour chosen at runtime. In C++, an abstract class usually has at least one pure virtual function, and dynamic dispatch works through base class pointers or references.
Q. What are predicates and method references in Java?
asked 1xmediumJava 8Technical2023
Ans. Predicates in Java are boolean-valued functional interfaces, usually Predicate<T>, used to test whether an object matches a condition. They are common in filters and validation. Method references are a compact form of lambda expression that refer to an existing method using ::, such as a static method, instance method, or constructor.
Q. Write pseudocode to detect a loop in a linked list.
asked 1xmediumLinked listsTechnical2019
Ans. Use Floyd’s cycle detection with two pointers, slow and fast, starting at the head. Move slow one node at a time and fast two nodes at a time. If they ever meet, there is a loop. If fast reaches null, there is no loop. It uses constant extra space and runs in O(n) time.
Q. How do you motivate team members during tough times?
asked 1xmediumLeadershipManagerial2019
Ans. Pick a real period of pressure, such as missed targets, change, or heavy workload. Emphasise staying calm, listening to concerns, clarifying priorities, recognising effort, and helping remove blockers. Interviewers listen for empathy plus action, not empty positivity. Show how you kept people focused and protected trust while still delivering results.
Q. What is the difference between mock and fake testing?
asked 1xmediumOOPTechnical2023
Ans. Mock testing uses objects that are set up to expect specific calls and verify interactions. Fake testing uses a simple working implementation, such as an in-memory database, instead of the real dependency. The key difference is that mocks check how code talks to dependencies, while fakes mainly provide realistic behaviour for testing outcomes.
Q. How can we achieve inheritance using protocols in Swift?
asked 1xmediumOOPTechnical2023
Ans. In Swift, protocol inheritance is achieved by defining a protocol that inherits from one or more other protocols. Any type conforming to the child protocol must satisfy the requirements of all parent protocols as well. Protocol extensions can add default behaviour, but they cannot provide true stored state like class inheritance.
Q. Should a ViewModel have a reference to the View in MVVM?
asked 1xmediumOOPTechnical2023
Ans. No, a ViewModel should not hold a reference to the View in MVVM. The ViewModel exposes state and commands, and the View observes them through data binding. This keeps presentation logic testable and independent, while UI-specific actions should be handled by the View or an injected service abstraction.
Q. How do you manage and track the performance of your team?
asked 1xmediumLeadershipManagerial2019
Ans. Choose an example where you set clear goals, tracked progress with regular check-ins and data, and acted early when performance slipped. Emphasise transparency, coaching, accountability and adapting support to each person. Interviewers listen for a balanced approach: measurable outcomes, fair feedback, motivation, and evidence that team performance improved under your management.
Q. Analyze the time and space complexity of common algorithms
asked 1xmediumComplexityManagerial2024
Ans. Common complexities are O(1) for array access, O(log n) for binary search, O(n) for linear scan, O(n log n) for efficient sorting, and O(n²) for nested loops. Space is O(1) if only a few variables are used, O(n) for extra arrays, hash tables, queues, stacks, or recursion depth.
Q. What is the difference between Spring Boot and Spring MVC?
asked 1xmediumSpringTechnical2023
Ans. Spring MVC is a web framework for building Java web applications, while Spring Boot is a framework that makes it easier to create and run Spring applications, including Spring MVC apps. The key difference is that Spring Boot provides auto-configuration, embedded servers and sensible defaults, reducing setup and boilerplate.
Q. What are synchronized blocks in Java and why are they used?
asked 1xmediumOperating systemsTechnical2023
Ans. Synchronized blocks in Java are sections of code protected by a monitor lock so only one thread can execute them for a given lock object at a time. They are used to prevent race conditions when accessing shared mutable data. They also provide memory visibility, so changes become visible to other synchronised threads.
Q. What is a Common Table Expression (CTE)? Explain with syntax.
asked 1xmediumSQLTechnical2024
Ans. A Common Table Expression is a temporary named result set defined within a single SQL statement. Its syntax is: WITH cte_name AS followed by a subquery in parentheses, then the main SELECT, INSERT, UPDATE, or DELETE using that name. CTEs improve readability and can support recursion in databases that allow recursive CTEs.
Q. Find the square root of a number with O(log n) time complexity.
asked 1xmediumBinary searchTechnical2023
Ans. Use binary search on the range from 0 to n and return the largest value whose square is not greater than n. At each step, test the middle value and discard half the range. To avoid overflow, compare mid with n / mid instead of computing mid * mid. Time complexity is O(log n).
Q. How do you decide which architecture to use for an iOS project?
asked 1xmediumArchitectureTechnical2023
Ans. I choose the simplest architecture that keeps the app testable, maintainable, and clear for the team. For a small app, MVVM with coordinators is often enough. For larger apps, I separate features into modules with clear boundaries, dependency injection, and unidirectional data flow where state complexity justifies it.
Q. Which data structure would you use in a given scenario and why?
asked 1xmediumData structuresManagerial2024
Ans. I would choose the data structure that matches the main operation the scenario needs most often. For fast lookup by key, use a hash map. For ordered data, use a balanced tree or heap. For FIFO processing, use a queue. The key reason is to optimise the dominant operation’s time complexity.
Q. Write pseudocode to convert a binary tree into its mirror tree.
asked 1xmediumTreesTechnical2019
Ans. Swap the left and right child of every node, recursively or with an explicit stack or queue. Start at the root, visit each node, exchange its children, then continue on both children until all nodes are processed. This modifies the tree in place and takes O(n) time, with O(h) recursion space or O(n) iterative space.
Q. Explain MVC and MVVM architectures. Which one is better and why?
asked 1xmediumOOPTechnical2023
Ans. Neither MVC nor MVVM is universally better; MVC suits simpler web-style request flows, while MVVM suits UI-heavy apps with data binding. MVC separates Model, View and Controller, where the controller handles input. MVVM separates Model, View and ViewModel, where the ViewModel exposes state and commands, improving testability and reducing UI logic.
Q. Write pseudocode to add two numbers represented by linked lists.
asked 1xmediumLinked listsTechnical2019
Ans. Traverse both linked lists together, adding corresponding digits and a carry, and append each resulting digit to a new linked list using a dummy head. Continue while either list has nodes or carry remains. Advance available pointers each step. This uses a result linked list, runs in O(max(m, n)) time and O(max(m, n)) space.
Q. Why is Swift considered a protocol-oriented programming language?
asked 1xmediumOOPTechnical2023
Ans. Swift is considered protocol-oriented because it encourages designing behaviour as protocols rather than relying mainly on class inheritance. Protocols define capabilities, and protocol extensions can provide shared default implementations. This lets structs, enums and classes adopt common behaviour, supporting composition, value types and flexible reuse without deep inheritance hierarchies.
Q. Write and explain SQL queries to solve database-related problems.
asked 1xmediumSQLTechnical2024
Ans. I solve SQL problems by identifying the required rows, joining the needed tables, filtering with WHERE, grouping with GROUP BY when aggregating, and ordering or limiting only at the end. For ranking or “top per group” problems, I use window functions. The key detail is to explain row flow and check indexes on join and filter columns.
Q. Explain the concept of class and object using a real-world example
asked 1xmediumOOPTechnical2022
Ans. A class is a blueprint that defines the properties and behaviour of something, while an object is a real instance created from that blueprint. For example, Car can be a class with colour, model, and drive behaviour. A specific red Toyota is an object of the Car class with its own values.
Q. Implement Disjoint Set (Union-Find) with union and find operations
asked 1xmediumGraphsOnline test2024
Ans. Use a Disjoint Set with a parent array and a rank or size array to support find and union efficiently. Initially, each element is its own parent. Find follows parent links to the representative and applies path compression. Union connects two representatives, attaching the smaller or lower-rank tree to the larger. Operations are almost constant time, O(alpha n).
Q. What are the major modifications or features introduced in Java 8?
asked 1xmediumJava versioningTechnical2023
Ans. Java 8 introduced lambda expressions, the Stream API, functional interfaces, default and static methods in interfaces, Optional, the new java.time date and time API, and CompletableFuture improvements. The most important change was lambdas plus streams, which made functional-style programming practical and allowed clearer processing of collections with operations like map, filter, and reduce.
Q. Explain garbage collection in Java and commonly used Java libraries.
asked 1xmediumOOPTechnical2024
Ans. Garbage collection in Java automatically reclaims heap memory from objects that are no longer reachable, reducing manual memory management errors. The key point is that GC is not deterministic, so developers should still avoid leaks through lingering references. Common Java libraries include Collections, Streams, Concurrency, IO/NIO, JDBC, and popular external libraries like Spring, Jackson, and JUnit.
Q. Is it possible to run a Java program without using the main() method?
asked 1xmediumJavaTechnical2019
Ans. No, not as a normal standalone Java application. The JVM needs an entry point, normally public static void main(String[] args). Older Java versions could execute static blocks before failing, but that is not a valid modern approach. Code can run without its own main only when launched by a container or framework.
Q. Can Protocol Oriented Programming be used in Objective-C? If yes, how?
asked 1xmediumOOPTechnical2023
Ans. Yes. Objective-C supports protocol oriented design through protocols, where classes declare that they conform to a set of required or optional methods. You define behaviour as protocols and program against id<ProtocolName> rather than concrete classes. Unlike Swift, Objective-C has no protocol extensions with stored state, so default behaviour is usually added with categories or helper classes.
Q. Explain OOP concepts in Python including encapsulation and abstraction.
asked 1xmediumOOPTechnical2024
Ans. OOP in Python models programs as objects that combine data and behaviour through classes, objects, inheritance, polymorphism, encapsulation and abstraction. Encapsulation means keeping internal state controlled, usually with methods, properties and naming conventions like a leading underscore. Abstraction means exposing a simple interface while hiding implementation details from the user.
Q. What is normalization in DBMS? Explain different normal forms and BCNF.
asked 1xmediumDBMSTechnical2023
Ans. Normalization in DBMS is the process of organising tables to reduce redundancy and avoid update, insert, and delete anomalies. 1NF removes repeating groups, 2NF removes partial dependency on a composite key, 3NF removes transitive dependency, and BCNF is stricter: every determinant must be a candidate key.
Q. How do you handle varying network bandwidths in a video calling application?
asked 1xmediumScalabilityTechnical2023
Ans. Use adaptive bitrate streaming with real-time congestion control to change video resolution, frame rate and bitrate as bandwidth varies. The most important detail is to prioritise audio and call continuity over video quality. Use WebRTC-style bandwidth estimation, jitter buffers, packet loss recovery, simulcast or scalable video coding, and degrade gracefully under poor networks.
Q. What is autowiring in Spring and what are the different ways to implement it?
asked 1xmediumSpringTechnical2023
Ans. Autowiring in Spring is automatic dependency injection, where the Spring container finds and supplies a bean’s required collaborators. It can be implemented using XML autowire modes such as byName, byType and constructor, or with annotations like @Autowired on constructors, setters or fields. Constructor injection is usually preferred for required dependencies.
Q. Write an SQL query to find the name and salary of employees born before 1991.
asked 1xmediumSQLManagerial2024
Ans. Filter the employees table to return only rows where the birth date is earlier than 1 January 1991, and project just the name and salary columns. The key detail is to compare against a proper date value, not just the year. With an index on birth date, this can be efficient.
Q. What is multithreading in Java and what are the different ways to implement it?
asked 1xmediumOperating systemsTechnical2023
Ans. Multithreading in Java is running multiple threads within one process so tasks can execute concurrently while sharing the same memory. It can be implemented by extending Thread, implementing Runnable, implementing Callable when a result or exception is needed, or by submitting tasks to an ExecutorService. In practice, prefer executors with Runnable or Callable.
Q. How do you prevent memory leaks when pushing the same controller multiple times?
asked 1xmediumOOPTechnical2023
Ans. Prevent it by not pushing duplicate controller instances onto the navigation stack. Before pushing, check whether that controller type or identifier is already present, then pop to it or ignore the action. The key detail is also to remove observers, invalidate timers, and use weak captures so dismissed controllers can deallocate.
Q. You have 5 jars containing pills; identify the required jar using minimum steps.
asked 1xmediumLogical reasoningTechnical2023
Ans. Use one weighing if one jar has pills of a different known weight. Take 1 pill from jar 1, 2 from jar 2, up to 5 from jar 5, and weigh them together. Compare with the expected total for normal pills. The weight difference divided by the per-pill difference gives the jar number.
Q. Divide a square into 5 parts such that 4 parts are equal, without lifting the pen.
asked 1xmediumLogical reasoningTechnical2019
Ans. Draw a diamond inside the square by joining the midpoints of the four sides in one continuous stroke. This creates five regions: the middle diamond and four corner triangles. The four triangles are equal because each has two half-side legs and the same right angle, so they are congruent.
Q. Explain method overloading, method overriding, and operator overloading in Python.
asked 1xmediumOOPTechnical2024
Ans. Method overloading means multiple methods with the same name but different parameters, but Python does not support it directly. A later definition replaces the earlier one, so defaults, *args, or dispatch are used instead. Method overriding is redefining a parent method in a subclass. Operator overloading is customising operators using special methods like __add__.
Q. Given two numbers a and b, find the Nth number that is divisible by either a or b.
asked 1xmediumMathOnline test2017
Ans. Use binary search on the answer and return the smallest number x such that count of numbers up to x divisible by a or b is at least N. The count is x/a plus x/b minus x/lcm(a,b), using gcd to compute lcm safely. Time complexity is O(log(N times min(a,b))).
Q. How would you reuse the same view controller instead of pushing a new instance repeatedly?
asked 1xmediumArchitectureTechnical2023
Ans. Check the navigation stack for an existing instance of that view controller and pop to it instead of creating and pushing a new one. The key detail is to identify the correct instance, usually by type and any context identifier, then update its state before showing it if needed.
Q. Find grammatical errors in English sentences
asked 1xeasyVerbalOnline test2019
Ans. Read the sentence in parts and check grammar systematically. First identify the subject, verb, and object. Then check subject verb agreement, tense consistency, pronouns, articles, prepositions, modifiers, and word order. Watch for parallel structure and comparisons. If nothing is wrong, choose the no error option only after checking every part.
Q. Given the sequence 7, 10, 8, 11, 9, 12, ?, find the next number.
asked 1xeasyLogical reasoningTechnical2023
Ans. 10. Look at the differences between terms: +3, -2, +3, -2, +3, so the next step is -2. Therefore 12 - 2 = 10. For this type, check for repeating differences or split the sequence into alternating subsequences.
Q. Logical reasoning problems involving directions and basic analytical reasoning
asked 1xeasyLogical reasoningOnline test2023
Ans. Draw a simple direction map instead of solving mentally. Mark the starting point, use north, south, east and west consistently, then update position after each movement or turn. For analytical reasoning, list the given facts, convert them into clear symbols or positions, eliminate impossible options, and check the remaining answer against every condition.
Showing 60 of 184 questions. Ranked by how often the same question came back across interviews.