Friday, 24 April 2020

SE - 69 - Can constructor throw exception in JAVA ?

YES , Constructor can also throw exceptions like normal method does.


public class ConstructorTest {
   public ConstructorTest() throws InterruptedException {
      System.out.println("Before Sleep");
      Thread.sleep(1000);
      System.out.println("After Sleep");
   }

No comments:

Post a Comment