Shall I design the following API using null returned value, or checked exception, or possible null object pattern
<p>I come to an API <code>getStock</code> designed, where I have no good judgment, on how I should deal with failure of operation.</p>

<p>The API will enable me to pass a stock code, and return a stock if success.</p>

<p>Shall I use <code>null returned value</code> to indicate failure of operation, or <code>throwing checked exception</code> to indicate failure of operation? Or possible <a href="http://en.wikipedia.org/wiki/Null_Object_pattern" rel="nofollow">Null Object Pattern</a>? Why?</p>

<hr>

<p><strong>Null Returned Value</strong></p>

<pre><code>// User force to check the returned value each time.
// This happen when, stock server is down, network is down, 
// stockCode is not valid...
Stock stock = stockServer.getStock(stockCode);
if (stock != null) {
    // Success.
}
</code></pre>

<hr>

<p><strong>Checked Exception</strong></p>

<pre><code>try {
    // User force to catch the exception each time.
    // This happen when, stock server is down, network is down,
    // stockCode is not valid...
    Stock stock = stockServer.getStock(stockCode);
    // Success.
} catch (StockNotFoundException ex) {
}
</code></pre>

<hr>

<p><strong>Null Object Pattern</strong></p>

<pre><code>Stock stock = stockServer.getStock(stockCode);
// stock.getPrice(), stock.getVolume() will return 0...
// But when there is a need to check whether we are getting
// a null stock, we need to check 
// if (stock.getPrice() == 0.0 &amp;&amp; stock.getVolume()...
</code></pre>
