Posts

Blocking Queue Questions for Java Interview

Following are questions which are normally asked on Blocking queue in Java interviews. 1. What is Blocking Queue and When it was introduced in Java ? 2. Custom implementation of Blocking Queue. 3. Different types of BlockingQueue methods.

Half full and Half Empty Glass

You are given a round glass full of water having capacity of 1 Ltr. You do not have any kind of measurements or any other things. How you will remove water from this glass such that glass will contain exact half of its quantity (500ml).

Gold Bar and Worker

You are having a gold bar and you need a worker to finish some work at your home.  Work will be finished in exact 7 days. You need to pay worker every day with equal part of the gold bar.  You are allowed to make two breaks in the Gold bar.  So how you will be going to pay to the worker ? Note: You need to pay equal part of Gold bar everyday.

Children in House Puzzle

Nine children are in a house and only these 9 are in house, no-one else in house other than these 9 children. A is ironing. B is watching TV C is playing Foosball D is listening radio E is bathing F is sleeping G is dressing I is cooking So what is H doing ? For Hint: Click Here Hint will be uploaded in 1 Day.

Red Apple Puzzle

There are 200 apples in basket, out of which 99% apples are Red apple. How many red apples must be removed to make the percentage of Red apple 98% ? For Hint: Click Here To make Red apple 98%, you need to make other apples count as 2. Currently basket have 2 other apples.

Bus Ticket Puzzle

Two deaf and dumb guys Ramesh and Suresh went to bus station. They wanted to take ticket to Kalyan station from thane and ticket cost per person is 50rs. Ramesh gave him 100rs and Ticket master gave him two tickets without looking at him. How did ticket master get to know that he wants two tickets not one as ticket master did not even seen his face ? For Hint: Click Here He did not gave 100rs Note.

Prime Number Program in Java

Prime number is a number which is divisible by itself. We can write this program in multiple ways but it will reduce the performance for  larger numbers. Here we define one of faster and optimised way to check if number is prime or not. public boolean isPrime( int value) {           if(value == 2)                    return true;            if (value % 2 == 0)                    return false ;          for ( int j = 3; j <= Math.sqrt(value); j+=2) {                if (value % j == 0) {                        return false ;               }         }         return true ; } In this...

Cross River puzzle

Two boys want to cross a river. Only one boat is present on the riverside that can carry only one person at a time. However, they still manage to cross the river. How is it possible ?

Count mangoes puzzle

In a basket of Mangoes, when counted in twos, there was one extra when counted in threes, there were two extra when counted in fours, there were three extra when counted in fives, there were four extra when counted in sixes, there were five extra. However, if the mangoes were counted in sevens, no extra mango was left. Can you calculate the minimum number of mangoes that were present in the basket ?

Turn off Whatsapp tone in Windows phone

Image
To turn off whatsapp tone on Windows phones, Please go through following steps: 1. Go to Settings of Windows phone. 2. Go to Notifications and Actions 3. Click on whatsapp 4. Change/disable the tone.  Enable/disable vibrate option for whatsapp.

Place queen on Chessboard puzzle

Image
Can you place 8 queens on the board in a manner that none of the queens can attack each other? Note: Queen moves horizontal, vertical and diagonally. Please see below image for reference.

Tricky Question

On my way to Temple, I saw a man with 7 wives. Each wife had 7 sacks. Each sack had 7 cats. Each cat had 7 kittens. Kitten, cats, sacks, wives, How many livings were going to Temple?

Tricky Question

Circle exact four numbers to get sum of 12.                     1    6     1                     6    1     6                     1    6     1                     6    1     6                     1    6     1                     6    1     6

Suspect in hotel puzzle

An old man was sitting in his hotel room when he heard a knock on the door. he opened the door and found that a man was standing outside.  The man said, "Oh! I am really sorry, I thought this was my room." He then walked through the corridor to the elevator. The old man did not know the man. he closed his door and called the security asking them to arrest the man. What made him suspicious of that man? He might have been genuinely mistaken.

Chessboard Puzzle

Image
Can you count the number of squares in a chess board ? Buy Lawman Slim Fit Men

chm viewer unable to show contents

In Windows Applications, we use chm file for help contents or for documentations. But we sometimes we are not able to see any contents in chm viewer. While it works fine on another systems. How to solve that: 1. Open command prompt and run as administrator. 2. go to location where chm file is located. 3.  input the file name (xxx.chm) and click on enter. It should work fine. Another way to do. 1. Right click on chm file. 2. Go to properties. 3. Select the Unblock option.

Burning Island

A man is staying on an island covered in forest.  One day, when the wind is blowing from the west, lightning strikes the west end of the island and sets fire to the forest. The fire is very violent, burning everything in its path, and without intervention the fire will burn the whole island, killing the man in the process.  There are cliffs around the island, so he cannot jump off. How can the man survive the fire? (There are no buckets or any other means to put out the fire) Click Here for Solution

Paintings Puzzle

Image
T hree friends A, B, and C are talking to each other about the art collection of Leonardo. A says: "Leonardo has at least four paintings of Hussain." B says: "No, he has less than four paintings of  Hussain ." "According to me," says C, " Leonardo  has at least one painting of Hussain." If you know that only one of the three friends is right, how many paintings does Leonardo possess ?

Nidhi and An Intruder puzzle

Image
Nidhi was sitting at her study table, home alone, on a cold and stormy night.  She was reading her books when she heard faint footsteps. Nidhi got out of her room and looked around when suddenly, without warning, she was grabbed by the neck. She tried to scream but it came out as a mere whimper as the intruder was pressing hard against her throat with his arm.  "Give me all your money!" growled the man who had grabbed her from behind. "Th-there is none h-here! Please ll-let me go!" cried Nidhi. "Don't LIE TO ME!" screamed the increasingly agitated man. She felt the man strengthen his grip around her neck. She said nothing and a few seconds passed by in silence.  Suddenly the phone rang which alerted both of them. "People will get suspicious if I don't answer the phone," said Nidhi, with a controlled voice. The intruder let her go. "Alright, but NO funny business, or ELSE!" said the nervous intruder. Nidhi wa...

Juice canes puzzle

Image
Six Juice canes are in a row. The first three canes are filled with juice and last three are empty. By using only one cane, can you arrange them so that the full and empty canes are alternate ?