Movius Corp
10+ Juspay Technologies Interview Questions and Answers
Q1. What will be the output of the following Swift code: \n\nstruct s1Struct {\n var abc = "Hello"\n \n func change() {\n abc = "bye"\n }\n}\n\nvar a = s1Struct()\na.change()\nprint(a.abc)
The output will be 'bye'.
The code defines a struct 's1Struct' with a property 'abc' initialized to 'Hello'.
It also has a method 'change()' that changes the value of 'abc' to 'bye'.
An instance 'a' of 's1Struct' is created and its 'change()' method is called.
Finally, the value of 'abc' in the instance 'a' is printed, which will be 'bye'.
Q2. What is the difference between the Liskov Substitution Principle and the Interface Segregation Principle?
Liskov Substitution Principle focuses on inheritance while Interface Segregation Principle focuses on interfaces.
Liskov Substitution Principle states that objects of a superclass should be replaceable with objects of its subclasses without affecting the program's correctness.
Interface Segregation Principle states that a client should not be forced to implement interfaces they do not use.
Liskov Substitution Principle is related to inheritance hierarchy, while Interface Segrega...read more
Q3. What is the time complexity for finding the longest common prefix in a given array of strings? (to be done in playground)
The time complexity for finding the longest common prefix in an array of strings is O(n*m), where n is the number of strings and m is the length of the longest string.
Iterate through the characters of the first string and compare them with the corresponding characters of the other strings.
The worst-case scenario is when all strings have the same prefix, resulting in O(n*m) time complexity.
Example: For strings ['apple', 'app', 'apricot'], the longest common prefix is 'ap'.
Q4. What are the benefits of using Structs over Classes in SwiftUI?
Structs are value types, leading to better performance and memory management in SwiftUI.
Structs are value types, meaning they are copied when passed around, leading to better performance compared to reference types like classes.
Structs are immutable by default, making it easier to reason about the state of your app and preventing unexpected changes.
Structs are more lightweight than classes, which can lead to better memory management in SwiftUI applications.
Structs are preferr...read more
Q5. What are the SOLID principles in software development?
SOLID principles are a set of five design principles in object-oriented programming to make software more maintainable, flexible, and scalable.
Single Responsibility Principle (SRP) - A class should have only one reason to change.
Open/Closed Principle (OCP) - Software entities should be open for extension but closed for modification.
Liskov Substitution Principle (LSP) - Objects of a superclass should be replaceable with objects of its subclasses without affecting the functiona...read more
Q6. What is Automatic Reference Counting, and how does it work?
Automatic Reference Counting (ARC) is a memory management feature in iOS development that automatically manages memory by keeping track of references to objects.
ARC automatically adds and removes retain/release calls to manage memory for objects.
It helps prevent memory leaks by deallocating objects when they are no longer needed.
ARC is the default memory management model in Swift and Objective-C.
Example: var myObject = MyObject() // ARC automatically retains myObject
Example: ...read more
Q7. What is a retain cycle in programming?
A retain cycle in programming occurs when two objects hold a strong reference to each other, preventing them from being deallocated.
Retain cycles can lead to memory leaks in iOS development.
To break a retain cycle, one of the objects involved needs to have a weak reference to the other.
An example of a retain cycle is when a parent object holds a strong reference to a child object, and the child object holds a strong reference back to the parent.
Q8. How you handle reference cycle?
Handle reference cycles by using weak or unowned references to break the strong reference cycle.
Use weak or unowned references to break strong reference cycles
Weak references do not keep a strong hold on the instance they refer to
Unowned references assume that the instance they refer to will never be nil
Q9. What are computed properties?
Computed properties are properties in Swift that do not store a value directly, but instead provide a getter and an optional setter to retrieve and set their value.
Computed properties do not have a backing store like stored properties.
They are used to calculate a value on-the-fly based on other properties or data.
Example: calculating the area of a square based on its side length.
Q10. What is the mutating keyword?
The mutating keyword is used in Swift to indicate that a method is allowed to modify the properties of a value type.
Used in Swift with value types like structs and enums to allow methods to modify their properties
Prevents compilation error when attempting to modify properties of a value type within a method
Example: mutating func updateValue(newValue: Int) { self.value = newValue }
Q11. How did you use Combine?
I used Combine to handle asynchronous events and data streams in my iOS app development.
Used Combine to manage network requests and responses
Implemented Combine to handle user input and UI updates
Utilized Combine to combine multiple data streams and perform operations on them
Q12. What are closures?
Closures are functions that have access to variables from their containing scope even after the scope has closed.
Closures allow functions to access variables outside of their scope
They 'close over' their surrounding scope, retaining access to variables even after the scope has finished executing
Closures are commonly used in JavaScript for callbacks and event handlers
Q13. What is event loop?
Event loop is a mechanism in programming that allows for asynchronous execution of code by continuously checking for and handling events.
Event loop is commonly used in JavaScript to handle asynchronous operations.
It allows for non-blocking I/O operations by delegating tasks to the operating system.
Event loop continuously checks the event queue for new events and executes them in a sequential manner.
Example: In Node.js, the event loop allows for handling multiple requests conc...read more
Q14. Improve website performance
Optimize website performance by implementing caching, minimizing HTTP requests, and optimizing images.
Implement browser caching to reduce load times for returning visitors
Minimize HTTP requests by combining CSS and JavaScript files
Optimize images by compressing them and using the correct file format
Use a content delivery network (CDN) to distribute content closer to users
Enable Gzip compression to reduce file sizes transferred over the network
Q15. Linux command disk usage
The Linux command for disk usage is 'du'.
The 'du' command shows the disk space used by files and directories in a specified location.
Use the '-h' option to display the sizes in a human-readable format.
Use the '-s' option to display only the total size of the specified location.
Use the '-c' option to display a grand total of all specified locations.
Example: 'du -h /home/user' will show the disk usage of the /home/user directory in a human-readable format.
Interview Process at Juspay Technologies
Top Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month