About Question enthuware.ocajp.i.v7.2.990 :

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

Moderator: admin

Post Reply
ewebxml
Posts: 78
Joined: Sun Jun 30, 2013 10:04 pm
Contact:

About Question enthuware.ocajp.i.v7.2.990 :

Post by ewebxml »

I answered this question using the compiler and answered it correctly.

Now looking at the question again it is not clear to me what the question is asking for.

Which of the following methods can be inserted at line //1 ?

It is an "open ended" question so you do not know whether you should use
1) overriding or
2) overloading?

When one looks at all the available options,

option e) public abstract void teach(String s)

is the only one that is abstract.

Is this the property or characteristic that prevents one from inserting this method
at line //1?

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

Re: About Question enthuware.ocajp.i.v7.2.990 :

Post by admin »

Hi,
The explanation for this option says, "This is wrong because class Prof has not been declared as abstract. Note that otherwise it is OK to override a method by an abstract method."

You cannot have an abstract method in a non-abstract class.

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

fasty23
Posts: 37
Joined: Thu Feb 13, 2014 12:58 am
Contact:

Re: About Question enthuware.ocajp.i.v7.2.990 :

Post by fasty23 »

The question asked "Which of the following methods can be inserted at line //1" I assumed which option at a time not all together, so just C & D are correct, but if the question asked "Which of the following methods can be inserted in Prof class with other methods" A & B & C & D were correct. did I get wrong?

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

Re: About Question enthuware.ocajp.i.v7.2.990 :

Post by admin »

Why do you think A and B are wrong if inserted independently(i.e.without any other method) as you said?
If you like our products and services, please help us by posting your review here.

fasty23
Posts: 37
Joined: Thu Feb 13, 2014 12:58 am
Contact:

Re: About Question enthuware.ocajp.i.v7.2.990 :

Post by fasty23 »

Oh :O
I got it
I just assumed it should be just overriding, but it could be another method independently from super class method, my bad.
your question helped me to realize my fault, thank you.

Nisim123
Posts: 42
Joined: Mon Jan 20, 2014 2:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.990 :

Post by Nisim123 »

So lets just try to put fasty32 question and answer clear.
fasty32 had found it hard at the beginning to realize that the act of overloading
can be made actually from the extended class, and still will be treated by the compiler as overloading and not overriding. A fact that I myself find hard to realize.

true || false ?

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

Re: About Question enthuware.ocajp.i.v7.2.990 :

Post by admin »

Overloading is very very different from overriding. Overloading is basically same as having another method altogether. For example, if base class has a method named m1(), can a subclass have a method named m2? Of course, yes. Would you say that m2 overrides m1? Of course not. Technically, it is the same with overloaded methods. For example, m1(int) and m1(int, int) are exactly same has having m1() and m2(). They are different methods with no relation at all.
If you like our products and services, please help us by posting your review here.

Nisim123
Posts: 42
Joined: Mon Jan 20, 2014 2:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.990 :

Post by Nisim123 »

Thanks for making things clear.. actually I've checked the KS&BB guide and I've found out
the following facts:

in chapter 2 page 110 it says:
■ A method can be overloaded in the same class or in a subclass. In other words,
if class A defines a doStuff(int i) method, the subclass B could define a
doStuff(String s) method without overriding the superclass version that
takes an int. So two methods with the same name but in different classes
can still be considered overloaded, if the subclass inherits one version of the
method and then declares another overloaded version in its class definition.
And the "exam watch" paragraph in page 114 that says:
Don’t be fooled by a method that’s overloaded but not overridden by a
subclass. It’s perfectly legal to do the following:
public class Foo {
void doStuff() { }
}
class Bar extends Foo {
void doStuff(String s) { }
}
The Bar class has two doStuff() methods: the no-arg version it inherits
from Foo (and does not override), and the overloaded doStuff(String s) defined in the
Bar class. Code with a reference to a Foo can invoke only the no-arg version, but code
with a reference to a Bar can invoke either of the overloaded versions.
So thanks for waking me up and "Forcing" me (few weeks ago though) to read thoroughly
the KS&BB guide....

Leonid
Posts: 9
Joined: Mon Jun 28, 2021 4:50 am
Contact:

Re: About Question enthuware.ocajp.i.v7.2.990 :

Post by Leonid »

Please tell me. I answered correct when I saw abstract method. But really I saw that no one method is correct, because every methods don't have own body of method! Because Class Prof is not abstract class.

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

Re: About Question enthuware.ocajp.i.v7.2.990 :

Post by admin »

None of the methods has a body because the question is about the method signature only, which is clear from the fact that there are 4 correct options and there is no option that says "none of the above is correct".

Also, only one method has abstract keyword. So, only that one is abstract. Others are concrete methods.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests