Errata : OCP Oracle Certified Professional Java SE 11 Programmer I Exam Fundamentals 1Z0-815 - Kindle edition

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
nk2164
Posts: 21
Joined: Mon Sep 30, 2019 9:48 pm
Contact:

Errata : OCP Oracle Certified Professional Java SE 11 Programmer I Exam Fundamentals 1Z0-815 - Kindle edition

Post by nk2164 »

OCP Oracle Certified Professional Java SE 11 Programmer I Exam Fundamentals 1Z0-815: Study guide for passing the OCP Java 11 Developer Certification Part 1 Exam 1Z0-815 (p. 5). Enthuware. Kindle Edition.

"For example, an overriding method cannot throw a more generic exception that the one declared by the overridden method. On the other hand the constructor of a subclass cannot throw only a more specific exception than the one thrown by the constructor of the superclass. Think about that."

The word "only" need to be removed. I think the text meant to say

" On the other hand the constructor of a subclass cannot throw a more specific exception than the one thrown by the constructor of the superclass. Think about that."

admin
Site Admin
Posts: 10404
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: Errata : OCP Oracle Certified Professional Java SE 11 Programmer I Exam Fundamentals 1Z0-815 - Kindle edition

Post by admin »

No, the statement is correct. "only" is intended. Observe the following code:

Code: Select all

class X{
  public X() throws IOException{
  }
}

class Y1 extends X{
  public Y1() throws Exception{ //works
  }

}
class Y2 extends X{
  public Y2() throws FileNotFoundException, IOException{  //works
  }
}

class Y3 extends X{
  public Y3() throws FileNotFoundException{ //DOES NOT WORK
  }

}

nk2164
Posts: 21
Joined: Mon Sep 30, 2019 9:48 pm
Contact:

Re: Errata : OCP Oracle Certified Professional Java SE 11 Programmer I Exam Fundamentals 1Z0-815 - Kindle edition

Post by nk2164 »

ok got it . So you mean to say it cannot just throw a more specific exception . It can however throw a more specific exception as long as it also throws the more generic exception declared in the parent class.

Thank you for the clarification.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 18 guests