What is inference in bridge? Before entering into the details lets look at an example.

Hand One

Let's start with a 'simple' hand. Bidding was South 1 No Trump, and North raised to 3 No Trump. West led 3

North ♠ K 6 J 8 4 K 10 8 4 ♣ K 6 5 3

South ♠ A 6 4 3
K 7 A J 9 3 ♣ A 4 2

South can see 6 top tricks, and a winning
K, and will need 2 additional tricks.

RHO wins the heart ace and returns the 9. You win the king and LHO follows with the heart 2. 
Your only hope for 9 tricks is to score 4 diamonds, and that will require you to find the queen. You can finesse either opponent for that card. Is it a pure guess, or do you have a clue that will help you make the decision? 
There's no discovery play available here, since cashing your other tricks first is unlikely to give you any helpful information. All you have to go on is your count in the heart suit, which you've already determined by watching the cards played to the first two tricks.
Here, LHO led the heart 3 and then followed with the 2, so he's shown that he holds 5 hearts (Qxx32). RHO therefore has 3 hearts (A9x). 
When you're in doubt about the location of a specific card, the odds favor it being in the hand that has the most "room" to hold that card. Your count in the heart suit tells you there are 8 chances that LHO has the diamond queen (he had 5 hearts, so has 8 unknown cards) and 10 chances that RHO has the queen (he had 3 hearts, so has 10 unknown cards). So your best play is to cash the diamond king and lead the 10, planning to finesse RHO for the diamond queen.

Here's a defensive quiz where you can use the opening lead and the bidding to come up with the right play:

s K9765
h Q7
d J95
c J64 
You:   s J1082   
h A65      
d A742    
c A3        
 LHO     RHO 
   1D          1S   
   1NT      Pass
2 of clubs
Declarer plays low from dummy and you win the club ace. Now is the time to add up all the evidence. It's often right to return the suit partner led, but you'll change your mind if you stop to count out the hand. Try to answer these questions before you make your decision:
     How many clubs does declarer hold?  
     How many diamonds?  
     How many hearts?        How many spades?       How many points does partner have?
     Which card will you lead at trick two?  
Dummy (RHO)Opening lead: 
Focus your count on declarer's hand.
How many clubs does he hold?  Exactly 4 (because the lead shows that partner holds exactly 4 clubs).
How many diamonds?  At least 4 (because he didn't raise spades).
How many hearts?  Exactly 4. Declarer didn't open 1H, so he has fewer than 5 hearts. It appears that partner also has fewer than 5 hearts, since he surely would have led a 5-card heart suit rather than a 4-card club suit. The 8 hearts that you can't see must therefore be divided 4-4 in partner's and declarer's hands. (Note that you also have a clue that partner doesn't hold a heart honor. Since partner is 4-4 in hearts and clubs and he chose clubs for his opening lead, his clubs are probably stronger than his hearts.)      How many spades?  You've counted declarer's hand to be 4-4-4 in the other three suits, so that leaves him with one spade. That means partner has three spades with at least one honor. 
     Note that without a count, you probably wouldn't have expected opener to have a singleton for his 1NT rebid. Many players, however, prefer this approach when they have a 1-4-4-4 pattern. The alternative with this hand is to bid 2C (showing a minor two-suiter), which is also a distortion. 
You can also add up the high-card points here. Declarer's minimum notrump rebid tells you he has 12 to 14 points. (If he had 15 pts., he would have opened a 15-17 1NT.) Add declarer's points to the 20 total points in your hand and dummy, and you can determine that partner holds from 6  to 8 high-card points.
Did you find the killing shift? It's right to lead a low spade at trick two. Partner wins the spade ace and returns a spade for down one. Your side will eventually score seven tricks -- three spades, the AK of clubs and the two red aces. 
   Declarer's hand was:  
s Q       h KJ109  d KQ106   c Q1085     Partner's hand was:     s A43    h 8432    d 83          c K972

Here's a deal where you can use a
discovery play to collect extra information:
s AQ9                   h 765 
d A432
c K102  
 You:        s K10865
h 842    
d K7
c AJ5    
  RHO    You    LHO   Partner 
   1H       1S      Pass       4S
Jack of hearts
RHO overtakes the heart jack and cashes the AKQ. LHO pitches two small clubs on the second and third hearts. RHO exits with a spade and you cash the AKQ. RHO follows with the J74 of spades. LHO follows with the 32  and pitches a small club on the third spade.
Your contract depends on guessing the location of the club queen. With nothing else to go on, you might finesse RHO for the queen just because he opened the bidding and is therefore more likely to hold the missing high-card points. If you're counting the opponents' cards, though, you might come to a different conclusion. And if you use a simple discovery play, you may be  able to guarantee three club winners.
 DummyOpening lead: 
Your thought process:     Focus your count on opener (RHO). 
    So far, you know 9 of his 13 cards -- 6 hearts and 3 spades.
    You've seen 10 of his high-card points -- the AKQ of hearts and the jack of spades.
    Did he need the club queen to open the bidding?  No. He could hold the diamond queen or QJ, which would give him 12 or 13 points.
Extra insurance -- the discovery play: 
     Before you make the critical play in the club suit, play on diamonds to gather more information about RHO's distribution. Cash the king and ace and trump one of dummy's small diamonds. RHO will follow to all three diamonds, so you now have all the information you need to take three sure club tricks. You may also see more of RHO's high-card points on the diamond tricks, but the most important information here is his distribution.
     You now know 12 of RHO's 13 cards -- 3 spades, 6 hearts and at least 3 diamonds. That leaves him with a void or singleton in clubs, so you have a "marked" finesse. Cash the club ace, just in case RHO has the singleton queen. If the queen doesn't fall, finesse LHO for his known queen by leading a low club to dummy's 10.