🌹🎉Mahindra Rise Questions &
Answers
Question:
N = 23876x794y, where x and y are single-digit natural numbers.
If N is divisible by 9, what is the value of (x + y)?
Options:
A. 8
B. 17
C. 7
D. (a) or (b)
Correct Ans:
A. 8
Explanation:
Sum of known digits = 2 + 3 + 8 + 7 + 6 + 7 + 9 + 4 = 46
So, 46 + x + y must be divisible by 9
→ (x + y) ≡ -46 mod 9 → x + y ≡ (9 - (46 mod 9)) = 8
🎉Mahindra Rise Questions & Answers 1
Question:
In a factory, 60% of the workers are above 30 years, and of these, 75% are m
Options:
A. 3000
B. 2000
C. 1800
D. 1500
Correct Ans:
A. 3000
Explanation:
Let total workers = x
60% of x = workers above 30 years = 0.6x
75% of them are males = 0.75 × 0.6x = 0.45x
Given: 0.45x = 1350 → x = 1350 / 0.45 = 3000
🎉Mahindra Rise Questions & Answers 2
💡 Four different positions of a standard six-faced die are shown below.
Based on the positions, what number is on the face opposite to the
face showing 4?
Dice Positions:
Dice 1: 6, 1, 5
Dice 2: 6, 5, 3
Dice 3: 2, 3, 5
Dice 4: 2, 1, 4
Options:
A) 1
B) 2
C) 3
D) 6
Correct Answer: C) 3
🎉Mahindra Rise Questions & Answers 3
🎉Mahindra Rise Questions & Answers 4
💡 3rd Question:
Question:
At a crossing, a direction signboard showing different directions to
various places was placed such that the pointer which was pointing
towards East is now pointing towards South. A person went in the
wrong direction thinking it is the direction shown by the pointer. In
which direction is he actually traveling?
Options:
A. East
B. South
C. North
D. West
Correct Answer:
C. North
Explanation:
The signboard has rotated 90° clockwise. Therefore, the direction
that was originally East is now pointing South. Consequently, the
direction that was originally North is now pointing East, and so on. If a
person thinks they are heading East based on the rotated signboard,
they are actually heading North.
4th Question:
Question:
Alex walks 1 mile towards East, then he turns towards North and walks
2 miles. After that, he turns East and walks 2 miles further. Finally, he
turns to his South and walks 2 miles. How far is he from the starting
point?
Options:
A. 2 miles
B. 25 miles
🎉Mahindra Rise Questions & Answers 5
C. 5 miles
D. 4 miles
Correct Answer:
D. 4 miles
Explanation:
Let's track Alex's movements step by step:
1. 1 mile East: Position at (1, 0)
2. 2 miles North: Position at (1, 2)
3. 2 miles East: Position at (3, 2)
4. 2 miles South: Position at (3, 0)
Now, calculate the distance from the starting point (0,0) to the final
position (3,0):
Distance = √[(3 - 0)² + (0 - 0)²] = √(9 + 0) = √9 = 3 miles
Note: There seems to be a discrepancy here. The calculation shows 3
miles, but the correct answer provided is 4 miles. Let's re-express the
steps:
1. 1 mile East: (1, 0)
2. 2 miles North: (1, 2)
3. 2 miles East: (3, 2)
4. 2 miles South: (3, 0)
Now, the final position is (3, 0). Starting point is (0, 0). Distance = √[(3
- 0)² + (0 - 0)²] = √9 = 3 miles
This indicates that the correct distance is 3 miles, not 4 miles.
Therefore, the correct answer should be:
Correct Answer:
C. 3 miles
Apologies for the earlier confusion.
5th Question:
Question:
🎉Mahindra Rise Questions & Answers 6
An octagonal table is marked A to H consecutively and clockwise. A
black ball is in corner A, while the white ball is in corner E. The black
ball moves one corner at a time clockwise, while the white ball moves
anti-clockwise. First, it goes to the next corner. In the next move, it
misses one and goes to the next corner. Then, it misses two, then
three, and so on. In how many moves and at which corner will the two
balls be together?
Options:
A. 3 moves, Corner D
B. 4 moves, Corner C
C. 5 moves, Corner F
D. None of these
Correct Answer:
C. 5 moves, Corner F
Explanation:
Let's simulate the movements:
Black Ball (Clockwise): Moves one corner per move.
White Ball (Anti-clockwise): Moves in a pattern where it skips an
increasing number of corners each time.
After simulating the movements for each move:
Move 1: Black at B, White at D
Move 2: Black at C, White at B
Move 3: Black at D, White at F
Move 4: Black at E, White at B
Move 5: Black at F, White at D
At Move 6: Black at G, White at H
At Move 7: Black at H, White at C
At Move 8: Black at A, White at G
At Move 9: Black at B, White at B
They meet at Move 9 at Corner B.
🎉Mahindra Rise Questions & Answers 7
Therefore, the correct answer is:
Correct Answer:
D. None of these
Explanation:
They meet at Move 9 at Corner B, which is not listed in the options.
6th Question:
Question:
Find the next term in the following series: ACQX, BDRY, CESZ, ______
Options:
A. DFTB
B. DFTY
C. DFTZ
D. DFTX
Correct Answer:
A. DFTB
Explanation:
Let's analyze the pattern:
First Letters: A → B → C → D (increment by 1)
Second Letters: C → D → E → F (increment by 1)
Third Letters: Q → R → S → T (increment by 1)
Fourth Letters: X → Y → Z → A (loop back to A)
So, the next term is:
First Letter: D
Second Letter: F
Third Letter: T
Fourth Letter: A
Combining: DFTA
🎉Mahindra Rise Questions & Answers 8
However, this option is not listed. Assuming a typographical error in
options, the closest match is:
Correct Answer:
A. DFTB
Note: There may be a discrepancy in the options provided. Please
verify the options for accuracy.
🎉Mahindra Rise Questions & Answers 9
public class A
{
int z;
static void func()
{
System.out.println(z++);
}
public static void main(String args[])
{
func();
🎉Mahindra Rise Questions & Answers 10
}
}
Correct Answer:
C. compilation error
public class Test
{
public static void main(String[] args) throws Exception
{
String str1 = "hello";
String str2 = "hello";
System.out.println(str1 == str2);
}
}
🎉Mahindra Rise Questions & Answers 11
Correct Answer:
A. true
public class Test
{
static
{
a[0] = 2;
}
static int[] a;
public static void main(String[] args)
{
}
}
🎉Mahindra Rise Questions & Answers 12
Correct Answer:
B. java.lang.ExceptionInInitializerError
import java.io.*;
class A {
protected void process() {
System.out.print("A,");
}
}
public class Test extends A {
void process() {
System.out.print("B,");
}
public static void main(String[] args) throws Exception {
🎉Mahindra Rise Questions & Answers 13
new Test().process();
}
}
Correct Answer:
Compilation Error
class A {
int x = 1;
}
public class Test extends A {
public static void main(String[] args) {
Test obj1 = new Test();
A obj2 = new A();
obj1 = (Test) obj2;
System.out.println(obj1.x);
🎉Mahindra Rise Questions & Answers 14
}
}
Correct Answer:
C. Runtime error (specifically, java.lang.ClassCastException )
class B implements Runnable {
AtomicInteger a = new AtomicInteger();
@Override
public void run() {
System.out.println(a.getAndIncrement());
}
}
public class A {
public static void main(String[] args) {
🎉Mahindra Rise Questions & Answers 15
B classVar = new B();
Thread t1 = new Thread(classVar);
t1.start();
Thread t2 = new Thread(classVar);
t2.start();
}
}
Correct Answer:
D. None of the above
public static void main(String[] args) throws java.lang.Exception {
int num = 10 * 0b1_0_1;
System.out.println(num);
}
🎉Mahindra Rise Questions & Answers 16
Correct Answer:
B. 50
🎉Mahindra Rise Questions & Answers 17
🎉Mahindra Rise Questions & Answers 18
🎉Mahindra Rise Questions & Answers 19
Coding 1
🎉Mahindra Rise Questions & Answers 20
import java.util.ArrayList;
🎉Mahindra Rise Questions & Answers 21
public class Solution {
public static ArrayList<Integer> findFirstAndLast(int[] arr, int x) {
ArrayList<Integer> result = new ArrayList<>();
int first = -1;
int last = -1;
for (int i = 0; i < arr.length; i++) {
if (arr[i] == x) {
if (first == -1) {
first = i;
}
last = i;
}
}
result.add(first);
result.add(last);
return result;
}
public static void main(String[] args) {
int[] arr = {1, 3, 5, 5, 5, 5, 67, 123, 125};
int target = 5;
ArrayList<Integer> result = findFirstAndLast(arr, target);
System.out.println(result); // Output: [2, 5]
}
}
Coding 2
🎉Mahindra Rise Questions & Answers 22
🧾 Problem Statement: Supermarket Inventory Management System
Design a system to manage a supermarket’s inventory and wallet balance. You
Adding new items to the inventory.
Updating the quantity of existing items.
Selling items from the inventory.
Maintaining a wallet balance based on purchases and sales.
📦 Class Requirements
Inventory.java
Handles the item storage with their price and quantity.
🎉Mahindra Rise Questions & Answers 23
Wallet.java
Manages the wallet balance and updates on spending or earning.
Market.java
Acts as the main controller for accessing Inventory and Wallet.
Purchase.java
Handles purchasing items and updating the inventory and wallet.
Sell.java
Handles selling items from inventory and updating wallet.
🧩 Classes and Their Implementations
📁 Inventory.java
import java.util.*;
public class Inventory {
private Map<String, Integer> stock = new HashMap<>();
private Map<String, Integer> price = new HashMap<>();
public void addItem(String item, int quantity, int cost) {
stock.put(item, stock.getOrDefault(item, 0) + quantity);
price.put(item, cost);
}
public void removeItem(String item, int quantity) {
if (stock.containsKey(item)) {
stock.put(item, stock.get(item) - quantity);
if (stock.get(item) <= 0) {
stock.remove(item);
price.remove(item);
}
🎉Mahindra Rise Questions & Answers 24
}
}
public int getPrice(String item) {
return price.getOrDefault(item, 0);
}
public int getStock(String item) {
return stock.getOrDefault(item, 0);
}
public boolean hasItem(String item) {
return stock.containsKey(item);
}
}
📁 Wallet.java
public class Wallet {
private int balance = 0;
public void add(int amount) {
balance += amount;
}
public void subtract(int amount) {
balance -= amount;
}
public int getBalance() {
return balance;
}
}
📁 Market.java
public class Market {
public static Inventory inventory = new Inventory();
🎉Mahindra Rise Questions & Answers 25
public static Wallet wallet = new Wallet();
}
📁 Purchase.java
public class Purchase {
public static void process(String item, int quantity, int cost) {
int totalCost = quantity * cost;
if (Market.wallet.getBalance() >= totalCost) {
Market.wallet.subtract(totalCost);
Market.inventory.addItem(item, quantity, cost);
} else {
System.out.println("Insufficient funds to purchase " + item);
}
}
}
📁 Sell.java
public class Sell {
public static void process(String item, int quantity) {
if (Market.inventory.hasItem(item) && Market.inventory.getStock(item) >=
int sellPrice = Market.inventory.getPrice(item);
Market.inventory.removeItem(item, quantity);
Market.wallet.add(sellPrice * quantity);
} else {
System.out.println("Cannot sell: " + item + ", insufficient stock");
}
}
}
Note :- You have to check the code
properly then change according to this
code in your origional code.
Thank You.
🎉Mahindra Rise Questions & Answers 26
Best of luck
🎉Mahindra Rise Questions & Answers 27