Javatpoint Logo

Exception handling

By: rajesh*** On: Mon Aug 07 15:47:47 IST 2017     Question Reputation0 Answer Reputation0 Quiz Belt Series Points0  0Blank User
if we put some line of code in method of class and then throw exception in this method of class
like this
public class Xyz{
public void foo()
{
System.out.print("hello");
throw Runtime Exception();
}
and we handle this exception in public static void main(string args [])
then tell me what will execute first .
the first line of void fooo()
or try block that we will write in main
and why
Up0Down

 
Image Created0Down

By: [email protected] On: Tue Aug 08 20:16:46 IST 2017 Question Reputation0 Answer Reputation0 Belt Series Points0 0User Image
Are You Satisfied :0Yes0No
 
The first line in method will be executed first.
It comes out only when the exception will be thrown.
Image Created0Down

By: [email protected] On: Wed Aug 09 11:34:17 IST 2017 Question Reputation0 Answer Reputation0 Belt Series Points0 0User Image
Are You Satisfied :0Yes0No