IntelliJ Java IDE
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Doubt on return type. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Professional Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Doubt on return type." Watch "Doubt on return type." New topic
Author

Doubt on return type.

Jeffrey Tian
Ranch Hand

Joined: Jun 02, 2010
Posts: 34
Below is a question from Enthuware(Q10 of Test 3)


What will the following class print ?



It prints out 99, 11.

The method on Line 13 has a return type as int. However, there's no return statement in the method body. Why? Is it because the first statement is throw and statements after throw won't be reachable?
Seetharaman Venkatasamy
Bartender

Joined: Jan 28, 2008
Posts: 4503

http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.7.4


Not everything that counts can be counted, and not everything that can be counted counts-Albert Einstein
 
 
subject: Doubt on return type.
 
Threads others viewed
Has anybody had a doubt like this...
return!
flow control
Exception vs return
Packed decimal conversion - Java
developer file tools