Nomura Research Institute Financial Technologies India
10+ MG Motor Interview Questions and Answers
Q1. Design a class that can give maximum 3 instance of that class, from 4th call it will repeat those instances.
Design a class that limits maximum 3 instances and repeats them from 4th call.
Create a private static array to hold instances.
Create a private static counter to keep track of instance count.
Create a public static method to get instance of the class.
In the method, check if counter is less than 3, create new instance and add to array, else return instance from array based on counter modulo 3.
Increment counter after each call.
Q2. Design simple model class for Shopping cart. Custom exception handling. Create a custom Immutable list.
Design a model class for shopping cart with custom exception handling and custom immutable list.
Model class should have properties like cart items, total price, etc.
Custom exception handling should be implemented for scenarios like adding invalid items to cart.
Custom immutable list can be created using C# ReadOnlyCollection or ImmutableList.
Immutable list should be used to store cart items to prevent accidental modification.
Q3. How many people go to coffee shops in India?
The number of people going to coffee shops in India varies depending on the location and time of day.
The number of people going to coffee shops in India can vary greatly depending on the city, neighborhood, and time of day.
Major cities like Mumbai, Delhi, Bangalore, and Chennai have a higher number of people visiting coffee shops compared to smaller towns.
Coffee shops near colleges and offices tend to have more footfall during weekdays.
Weekends and evenings are usually busier...read more
Q4. What are the new features of Java 8
Java 8 introduced several new features including lambda expressions, streams, and default methods.
Lambda expressions enable functional programming and simplify code.
Streams provide a new way to process collections and perform operations in parallel.
Default methods allow interfaces to have method implementations.
Other features include the Optional class, Date and Time API, and Nashorn JavaScript engine.
Q5. What is a singleton design pattern
A singleton design pattern restricts the instantiation of a class to a single object.
Singleton pattern ensures that only one instance of a class is created.
It provides a global point of access to the instance.
Commonly used in scenarios where a single instance is required to control actions or resources.
Example: Database connection manager, logger, configuration manager.
Q6. What is an observer design pattern
Observer design pattern is a behavioral design pattern that allows objects to subscribe and receive updates from a subject.
It is used to establish a one-to-many dependency between objects.
The subject maintains a list of observers and notifies them of any state changes.
Observers can be added or removed dynamically.
It promotes loose coupling between objects.
Example: A weather station broadcasts weather updates to multiple display devices.
Q7. Minimum difference element in sorted array.
Find the element with minimum difference between adjacent elements in a sorted array.
Iterate through the array and calculate the difference between each pair of adjacent elements.
Keep track of the minimum difference found so far.
Return the element corresponding to the minimum difference.
Q8. Difference between linked list and array?
Arrays store elements in contiguous memory locations, while linked lists store elements in nodes with pointers to the next node.
Arrays have fixed size, while linked lists can dynamically grow or shrink.
Accessing elements in arrays is faster (O(1)), while in linked lists it is slower (O(n)).
Inserting or deleting elements in arrays can be inefficient, while in linked lists it is efficient.
Example: Array - [1, 2, 3, 4], Linked List - 1 -> 2 -> 3 -> 4
Q9. Find the palindrome in the string?
To find palindromes in a string, compare characters from both ends towards the middle.
Iterate through each string in the array
Check if the string is equal to its reverse to determine if it's a palindrome
Examples: 'level', 'radar', 'madam'
Q10. Normalization and sql query in dbms.
Normalization is the process of organizing data in a database to reduce redundancy and improve data integrity. SQL queries are used to retrieve and manipulate data in a database management system.
Normalization involves breaking down data into smaller, more manageable tables to reduce redundancy.
SQL queries are used to retrieve specific data from a database using SELECT, INSERT, UPDATE, and DELETE statements.
Normalization helps maintain data integrity by reducing the risk of i...read more
Q11. How many people watch football in India
It is estimated that millions of people watch football in India, making it one of the most popular sports in the country.
Football is one of the most popular sports in India, with a huge fan following.
The Indian Super League (ISL) and the I-League are the two main football leagues in India.
The FIFA World Cup and UEFA Champions League are also widely watched in India.
Football matches featuring popular international teams like Barcelona, Real Madrid, and Manchester United attrac...read more
Q12. What is lambda and optional
Lambda is an anonymous function in programming, while Optional is a container object that may or may not contain a non-null value.
Lambda is used to write concise and functional code by allowing the creation of small, reusable functions.
Optional is used to handle null values in a more explicit and safe way, reducing the chances of NullPointerExceptions.
Lambda expressions can be used with functional interfaces, allowing the implementation of methods directly in the expression.
O...read more
Q13. Palindrome check in string.
Check if a string is a palindrome or not.
Iterate through the string from both ends and compare characters.
Ignore spaces and punctuation while checking for palindrome.
Examples: 'racecar' is a palindrome, 'hello' is not a palindrome.
Q14. what are 4 pillars of oops?
The 4 pillars of OOP are Inheritance, Encapsulation, Abstraction, and Polymorphism.
Inheritance allows a class to inherit properties and behavior from another class.
Encapsulation restricts access to certain components of an object, protecting its integrity.
Abstraction hides complex implementation details and only shows the necessary features.
Polymorphism allows objects to be treated as instances of their parent class or their own class.
Q15. Test use cases how to do that for this
Test use cases can be created by identifying different scenarios and inputs to validate the functionality of a system.
Identify different scenarios and inputs that the system should be able to handle
Create test cases based on these scenarios and inputs
Execute the test cases and verify the expected outcomes
Include positive and negative test cases to cover all possible scenarios
Q16. what programming languages familiar with
I am familiar with Java, Python, and C++ programming languages.
Java
Python
C++
Interview Process at MG Motor
Top Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month