java - Given the method signature A bar(B q) throws C, which of the following will not compile? -


public class extends exception {....} public class b extends {....} public class c extends runtimeexception {....} 

given method signature bar(b q) throws c, of following not compile?

a.

a m() throws c {     return bar(new b()); }      

b.

m() {     return bar(new b()); }   

c. of above compile.

the answer c. there might typo b, not sure. i'm not understanding question, conceptually, what's asking, etc. superclass of b, , c alone runtimeexception, it's not checked @ compile time?
, inside of method has b time exception, works in both answers. explain why both of these compile?

c kind of runtime exception. don't need declare runtime exception, , ignored compiler.

here's explanation started.

declaring exception doesn't mean there exception. means should prepared possiblility exception thrown.

choice b not compile, not because of exception. not compile because there no return type. choice has declared return of type a.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -