About Question com.enthuware.ets.scjp.v6.2.791 and enthuware.ocajp.i.v7.2.1167 :

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

Moderator: admin

Post Reply
ssack2014
Posts: 3
Joined: Wed Aug 13, 2014 5:35 pm
Contact:

About Question com.enthuware.ets.scjp.v6.2.791 and enthuware.ocajp.i.v7.2.1167 :

Post by ssack2014 »

Why is B's m() not an override of A's m()? or am I looking at this question wrong?

ssack2014
Posts: 3
Joined: Wed Aug 13, 2014 5:35 pm
Contact:

Re: About Question com.enthuware.ets.scjp.v6.2.791 :

Post by ssack2014 »

the modifier is less restrictive.


//in file A.java
public class A
{
protected void m() throws SomeException{}
}

//in file B.java
public class B extends A
{
public void m(){ }
}

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

Re: About Question com.enthuware.ets.scjp.v6.2.791 :

Post by admin »

It is a valid override. The explanation doesn't say that it is not a valid override either. So I am not sure what is the problem?

-Paul.
If you like our products and services, please help us by posting your review here.

edufin166@yahoo.com
Posts: 24
Joined: Wed Sep 28, 2022 9:41 am
Contact:

Re: About Question com.enthuware.ets.scjp.v6.2.791 :

Post by edufin166@yahoo.com »

Ok.

As I could see. We have 2 correct answers:

A a = new B();
a.m();


A a = new B();
( ( B) a ).m();

Am I right?

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

Re: About Question com.enthuware.ets.scjp.v6.2.791 and enthuware.ocajp.i.v7.2.1167 :

Post by admin »

A a = new B();
a.m();
Did you read the explanation provided for this option? It explains exactly why this option is not correct.
A's m() declares 'throws SomeException', which is a checked exception, while the main() method doesn't. So a.m() must be wrapped in a try/catch block.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 52 guests