op investment banks or reputed companies asked many Java Programming Puzzles as well as brainteasers questions to the candidates. These logical puzzles in java interview are used to check whether candidate can think out of box if facing difficult and complex problems.Let us discuss the tips to tackle such kind of questions in effective way.
Tips to Solve Java Programming Puzzles and Brainteasers
1. While answering Java Programming Puzzles ,remember that the obvious answer is almost never the right answer.
2. If the solution that seems logical is wrong, you made a false assumption.Categorize your assumptions, and try to identify those that are false.
3. Don’t be intimidated by complexity. Try a subproblem, a simplified version,or some examples. Be patient, keep working, and keep talking.
4. When you’re stuck on a simple, restricted problem, brainstorm all the possibilities to identify the one you’re missing.
Java Programming Puzzles and Brainteaser Questions
Q1 You are standing in a hallway next to three light switches switches, all of which are off. Each switch operates a different incandescent light bulb in the room at the end of the hall. You cannot see the lights from where the switches are. Determine which light corresponds to each switch. You may go into the room with the lights only once.
Q2 How do you cut a rectangular cake into two equal pieces when someone has already removed a rectangular piece from it ? The removed piece can be of any size or orientation. You are allowed just one straight cut .
Q3 You have eight marbles and a two-pan scale. All the marbles weigh the same, except for one which is heavier than all the others. The marbles are otherwise indistinguishable. You may make no assumptions about how much heavier the heavy marble is. What is the minimum number of weighing needed to be certain of identifying the heavy marble? Now generalize the question. What is the minimum number of weighing to find a heavy marble among n marbles?
Q4 Christine and Siri have 21$ between them. Christine has 20$ more than Siri. How much does each have. You cant use fractions in the answer
Q5 A party of four travelers comes to a rickety bridge at night. The bridge can hold the weight of at most two of the travelers at a time, and it cannot be crossed without using a flashlight. The travelers have one flashlight among them. Each traveler walks at a different speed: The first can cross the bridge in 1 minute, the second in 2 minutes, the third in 5 minutes, and the fourth takes 10 minutes to cross the bridge. If two travelers cross together, they walk at the speed of the slower traveler. What is the least amount of time in which all the travelers can cross from one side of the bridge to the other?
Q6 You have 10 Jars filled with marbles. Each marble weighs 10 gm, except one Jar which contains defective marbles which weighs 9 gm. Given a scale to weigh, How do you find Jar with defective marbles in just one measurement. Here scale is modern day electronic scale to measure weight.
Q7 A person shoots her wife. Then holds her under water for 5 minutes. Finally, he hangs her. But after 10 minutes they both go out together and enjoy a wonderful dinner together. How can this be?
Q8 A father and son are going in a car and suddenly there car met accident. Father died on the spot but the child rushed to the hospital. When he arrives in the hospital, doctor says, "I can't operate on this child, he is my son!" How can this be?
Q9 There are three ants on different vertices of a triangle. What is the probability of collision (between any two or all of them) if they start walking on the sides of the triangle? Similarly find the probability of collision with ‘n’ ants on an ‘n’ vertex polygon.
Q10 Starting from one end , one complete burn (burning from one end to other end) requires 1 hour each for two sticks.Assuming that sticks do not burn at constant rate i.e some part may burn faster then the other part of the stick. You need to measure 45 minutes by using these two sticks and a lighter.
More Difficult Questions
Q11 A small school with only 100 lockers has this ritual on the last day of school: The student go into the hall and stand by their closed lockers. At the first blow of a whistle, the students open every locker. At the second whistle, the students close every second locker(lockers 2,4,6 etc. are slammed shut). At the third whistle , the students toggle every third locker. To "toggle" means to close if it's open, and to open if it's closed. They toggle lockers 3,6,9 etc.to 99. At whistle four, they toggle every fourth locker. At whistle five , they toggle every fifth locker and so on.
At the hundreth whistle , the student standing next to locker 100 (and only that student) toggles his locker. How many lockers are then open.
Q12 Every man in a village of fifty couples has been unfaithful to his wife. Every woman in the village instantly knows when a man other than her husband has philandered (meaning a man who easily enter into casual sexual relationships with women ) but not when her own husband has ("always the last to know").The village's no tolerance adultery statute requires that a woman who can prove her husband is unfaithful must kill him that very day.No woman would dream of disobeying this law.One day , the Queen , who is known to be infallible(meaning incapable of making mistakes or being wrong) , visits the village . She announces that atleast one husband has been unfaithful. What happens ?
Q13 Five pirates on an island have one hundred gold coins to split among themselves. They divide the loot as follows : The senior pirate proposes a division, and everyone votes on it. Provided at least half the pirates vote for the proposal , they split the coins that way.If not , they kill the senior pirate and start over. The most senior (surviving) pirate proposes his own division plan , and they vote by same rules and either divide the loot or kill the senior pirate, as the case may be. The process continues until one plan is accepted. Suppose you are the senior pirate.What division do you propose? (The pirates are all extremely logical and greedy, and all want to live).
Q14 You are in a boat in the exact center of a perfectly circular lake. There is a goblin on the shore of the lake. The goblin wants to do bad things to you. The goblin cant swim and doesn't have a boat.Provided you can make it to the shore - and the goblin isn't there,waiting to grab you - you can always outrun him on land and get away.
The problem is this: The goblin can run four times as fast as the maximum speed of your boat.He has perfect eyesight,never sleeps and is extremely logical. He will do everything in his power to catch you. How would you escape the goblin?
Q15 One of your employees insists on being paid daily in gold. You have a gold bar whose value is that of seven days salary for this employee. The bar is already segmented into seven equal pieces. If you are allowed to make just two cuts in the bar and must settle with the employee at the end of each day, how do you do it?
# Weird Logical Thinking Question
1. How many gas stations are there in United States(Your country) ?
2. How would you locate a specific book in a big library? There's no cataloging system and no librarian to help you ?
We will share the answers shortly in the mean time try to solve questions by yourself. If you solve any questions then Please mention answers in the comment .
Tips to Solve Java Programming Puzzles and Brainteasers
1. While answering Java Programming Puzzles ,remember that the obvious answer is almost never the right answer.
2. If the solution that seems logical is wrong, you made a false assumption.Categorize your assumptions, and try to identify those that are false.
3. Don’t be intimidated by complexity. Try a subproblem, a simplified version,or some examples. Be patient, keep working, and keep talking.
4. When you’re stuck on a simple, restricted problem, brainstorm all the possibilities to identify the one you’re missing.
Java Programming Puzzles and Brainteaser Questions
Q1 You are standing in a hallway next to three light switches switches, all of which are off. Each switch operates a different incandescent light bulb in the room at the end of the hall. You cannot see the lights from where the switches are. Determine which light corresponds to each switch. You may go into the room with the lights only once.
Q2 How do you cut a rectangular cake into two equal pieces when someone has already removed a rectangular piece from it ? The removed piece can be of any size or orientation. You are allowed just one straight cut .
Q3 You have eight marbles and a two-pan scale. All the marbles weigh the same, except for one which is heavier than all the others. The marbles are otherwise indistinguishable. You may make no assumptions about how much heavier the heavy marble is. What is the minimum number of weighing needed to be certain of identifying the heavy marble? Now generalize the question. What is the minimum number of weighing to find a heavy marble among n marbles?
Q4 Christine and Siri have 21$ between them. Christine has 20$ more than Siri. How much does each have. You cant use fractions in the answer
Q5 A party of four travelers comes to a rickety bridge at night. The bridge can hold the weight of at most two of the travelers at a time, and it cannot be crossed without using a flashlight. The travelers have one flashlight among them. Each traveler walks at a different speed: The first can cross the bridge in 1 minute, the second in 2 minutes, the third in 5 minutes, and the fourth takes 10 minutes to cross the bridge. If two travelers cross together, they walk at the speed of the slower traveler. What is the least amount of time in which all the travelers can cross from one side of the bridge to the other?
Q6 You have 10 Jars filled with marbles. Each marble weighs 10 gm, except one Jar which contains defective marbles which weighs 9 gm. Given a scale to weigh, How do you find Jar with defective marbles in just one measurement. Here scale is modern day electronic scale to measure weight.
Q7 A person shoots her wife. Then holds her under water for 5 minutes. Finally, he hangs her. But after 10 minutes they both go out together and enjoy a wonderful dinner together. How can this be?
Q8 A father and son are going in a car and suddenly there car met accident. Father died on the spot but the child rushed to the hospital. When he arrives in the hospital, doctor says, "I can't operate on this child, he is my son!" How can this be?
Q9 There are three ants on different vertices of a triangle. What is the probability of collision (between any two or all of them) if they start walking on the sides of the triangle? Similarly find the probability of collision with ‘n’ ants on an ‘n’ vertex polygon.
Q10 Starting from one end , one complete burn (burning from one end to other end) requires 1 hour each for two sticks.Assuming that sticks do not burn at constant rate i.e some part may burn faster then the other part of the stick. You need to measure 45 minutes by using these two sticks and a lighter.
More Difficult Questions
Q11 A small school with only 100 lockers has this ritual on the last day of school: The student go into the hall and stand by their closed lockers. At the first blow of a whistle, the students open every locker. At the second whistle, the students close every second locker(lockers 2,4,6 etc. are slammed shut). At the third whistle , the students toggle every third locker. To "toggle" means to close if it's open, and to open if it's closed. They toggle lockers 3,6,9 etc.to 99. At whistle four, they toggle every fourth locker. At whistle five , they toggle every fifth locker and so on.
At the hundreth whistle , the student standing next to locker 100 (and only that student) toggles his locker. How many lockers are then open.
Q12 Every man in a village of fifty couples has been unfaithful to his wife. Every woman in the village instantly knows when a man other than her husband has philandered (meaning a man who easily enter into casual sexual relationships with women ) but not when her own husband has ("always the last to know").The village's no tolerance adultery statute requires that a woman who can prove her husband is unfaithful must kill him that very day.No woman would dream of disobeying this law.One day , the Queen , who is known to be infallible(meaning incapable of making mistakes or being wrong) , visits the village . She announces that atleast one husband has been unfaithful. What happens ?
Q13 Five pirates on an island have one hundred gold coins to split among themselves. They divide the loot as follows : The senior pirate proposes a division, and everyone votes on it. Provided at least half the pirates vote for the proposal , they split the coins that way.If not , they kill the senior pirate and start over. The most senior (surviving) pirate proposes his own division plan , and they vote by same rules and either divide the loot or kill the senior pirate, as the case may be. The process continues until one plan is accepted. Suppose you are the senior pirate.What division do you propose? (The pirates are all extremely logical and greedy, and all want to live).
Q14 You are in a boat in the exact center of a perfectly circular lake. There is a goblin on the shore of the lake. The goblin wants to do bad things to you. The goblin cant swim and doesn't have a boat.Provided you can make it to the shore - and the goblin isn't there,waiting to grab you - you can always outrun him on land and get away.
The problem is this: The goblin can run four times as fast as the maximum speed of your boat.He has perfect eyesight,never sleeps and is extremely logical. He will do everything in his power to catch you. How would you escape the goblin?
Q15 One of your employees insists on being paid daily in gold. You have a gold bar whose value is that of seven days salary for this employee. The bar is already segmented into seven equal pieces. If you are allowed to make just two cuts in the bar and must settle with the employee at the end of each day, how do you do it?
# Weird Logical Thinking Question
1. How many gas stations are there in United States(Your country) ?
2. How would you locate a specific book in a big library? There's no cataloging system and no librarian to help you ?
We will share the answers shortly in the mean time try to solve questions by yourself. If you solve any questions then Please mention answers in the comment .
Reference;---
No comments:
Post a Comment