{"id":1618,"date":"2016-09-14T12:30:39","date_gmt":"2016-09-14T12:30:39","guid":{"rendered":"http:\/\/codethataint.com\/blog\/?p=1618"},"modified":"2016-09-14T12:30:55","modified_gmt":"2016-09-14T12:30:55","slug":"throws-vs-throw","status":"publish","type":"post","link":"https:\/\/codethataint.com\/blog\/throws-vs-throw\/","title":{"rendered":"Throws vs Throw"},"content":{"rendered":"<p>Difference between throw and throws in Java<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\nvoid doCalc() throws ArithmeticException\r\n{  \r\n   .\r\n   .\r\n   throw new ArithmeticException(&quot;sorry&quot;);  \r\n}  \r\n<\/pre>\n<p><strong>throw<\/strong><\/p>\n<ol>\n<li>Java throw keyword is used to explicitly throw an exception.<\/li>\n<li>Checked exception cannot be propagated using throw only.<\/li>\n<li>Throw is followed by an instance.<\/li>\n<li>Throw is used within the method.<\/li>\n<li>You cannot throw multiple exceptions.<\/li>\n<\/ol>\n<p><strong>throws<\/strong><\/p>\n<ol>\n<li>Java throws keyword is used to declare an exception.<\/li>\n<li>Checked exception can be propagated with throws.<\/li>\n<li>Throws is followed by class.<\/li>\n<li>Throws is used with the method signature.<\/li>\n<li>You can declare multiple exceptions e.g.<br \/>\npublic void method()throws IOException,SQLException.<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Difference between throw and throws in Java void doCalc() throws ArithmeticException { . . throw new ArithmeticException(&quot;sorry&quot;); } throw Java throw keyword is used to explicitly throw an exception. Checked exception cannot be propagated using throw only. Throw is followed by an instance. Throw is used within the method. You cannot throw multiple exceptions. throws&hellip; <a href=\"https:\/\/codethataint.com\/blog\/throws-vs-throw\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[193],"tags":[],"class_list":["post-1618","post","type-post","status-publish","format-standard","hentry","category-interview-questions-java"],"_links":{"self":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/1618","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/comments?post=1618"}],"version-history":[{"count":2,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/1618\/revisions"}],"predecessor-version":[{"id":1620,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/1618\/revisions\/1620"}],"wp:attachment":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/media?parent=1618"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/categories?post=1618"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/tags?post=1618"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}