It is a compile-time error if a method is declared with more than one of the modifiers abstract, default, or static.
Ramya Subraamanian wrote:
But you cannot create a static abstract method like in line 5. It will throw a compiler error like in line 5. so there is no question of overriding it.
Jan Stückrath wrote:There is one question that says "Which of the following are true statements about interface methods?" and one of the possible options is "They can be overridden by an abstract method in an abstract class that implements the interface". The answer text claims that this it true, but interfaces can also have static methods. Besides the fact that these methods cannot be unverridden (only hidden) in general, static methods of interfaces are not inherited to subclasses, thus, they cannot be overridden. Am I missing something?
Roel De Nijs wrote:
If answer option C had stated: "Non-static interface methods can be overridden with an abstract method in an abstract class that implements the interface", it definitely was a correct answer.
Roel De Nijs wrote:
Also the explanation has a minor issue: "An interface may only be marked" should be "An interface method may only be marked" (at first glance it seems to be not listed yet in the official overview).
Jan Stückrath wrote:If you write it this way, it really seems that they meant non-static interface methods and wanted to ask weather an abstract method can be overridden by an abstract method.
Roel De Nijs wrote:
Non-static interface methods refers not only to abstract interface methods but to default interface methods as well.
Jan Stückrath wrote:
Roel De Nijs wrote:
Non-static interface methods refers not only to abstract interface methods but to default interface methods as well.
You are of course right. I actually thought about both, but forgot default in my post.
Secondly, other answer options mention explicitly "default methods" or "abstract methods".
Roel De Nijs wrote:
You can better forget it here than on the exam
Ramya Subraamanian wrote:
I will have options like Interface Methods are static,abstract and default.But in answer statement they have clearly mentioned "overridden by an abstract method". so I will rule out my options for a static abstract or default abstract because its not feasible and understand that the author just wants to convey about abstract methods and not others. And so I conclude this statement is true.(entirely my perspective).
Ramya Subraamanian wrote:
Roel De Nijs wrote:Secondly, other answer options mention explicitly "default methods" or "abstract methods".
I am worried only about the correctness of this statement while considering if this statement is true or not. I don't care, if other statements have default in them. or should i care?
Ramya Subraamanian wrote:When I look at this statement "They can be overridden by an abstract method in an abstract class that implements the interface".I will have options like Interface Methods are static,abstract and default.But in answer statement they have clearly mentioned "overridden by an abstract method". so I will rule out my options for a static abstract or default abstract because its not feasible and understand that the author just wants to convey about abstract methods and not others. And so I conclude this statement is true.(entirely my perspective).
Ramya Subraamanian wrote:I am worried only about the correctness of this statement while considering if this statement is true or not. should I be bothered if other statements have default in them ?
Ramya Subraamanian wrote:"(they)abstract methods of the interface can be overridden by an abstract method in an abstract class that implements the interface".and thats true..(I am not a Native English speaker either)
Goofy, Pluto and Micky Mouse go to the movie theater to watch the latest Disney movie. They bought popcorn and a drink.
Ramya Subraamanian wrote:Because Jan mentioned he is not native English speaker, I just said I wasn't either !! And that has absolutely nothing to do with the statement.
Ramya Subraamanian wrote:
Goofy, Pluto and Micky Mouse go to the movie theater to watch the latest Disney movie. They bought popcorn and a drink.
If the question is who are "they" and I already know goofy and pluto dont eat popcorn or drink. the answer would be Micky. But I am sure you would disagree because, you cannot assume anything about Goofy and Pluto. But questions are set based on the question setters assumption and the answers are based on their assumption. And each person who reads it perceives it differently. shouldn't we consider all possibilities before answering a question.
Roel De Nijs wrote:
As mentioned earlier, it's very important to be aware of the "context of the question" when answering mock (and real) questions. In this thread you'll find a nice discussion about this "context of a question", it's definitely worth reading.
Ramya Subraamanian wrote:Because Jan mentioned he is not native English speaker, I just said I wasn't either !! And that has absolutely nothing to do with the statement.
Ramya Subraamanian wrote:If the question is who are "they" and I already know goofy and pluto dont eat popcorn or drink. the answer would be Micky. But I am sure you would disagree because, you cannot assume anything about Goofy and Pluto. But questions are set based on the question setters assumption and the answers are based on their assumption. And each person who reads it perceives it differently. shouldn't we consider all possibilities before answering a question.
Ramya Subraamanian wrote:And I came across this question in whiz labs practice test :
If x.equals(y) is true then is this statement true -> " both x and y objects should have the same field status" ?
and other statements are "y.hashCode() must equal x.hashCode()" , "y.hashCode() may equal x.hashCode()".
Jan Stückrath wrote:At the moment I think that "ambiguous" questions (at least from my perspective) and too well hidden subtleties in code examples will be my main source of point loss in the exam.
What about these statements?
Ramya Subraamanian wrote:If "x.equals(y)" returns true , then which of these statements are correct ?
A. both x and y objects should have the same field status
B. y.hashCode() must be equal to x.hashCode()
C. y.hashCode() may equal x.hashCode()
So from the part in bold it's pretty clear that B is the correct answer (and therefore C is wrong).Object's hashCode() method wrote:If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result.
Ramya Subraamanian wrote:x.equals(y) must be true only if I override equals. And if I have 2 fields as num1 and color. I will check if both of them are equal and then return true, thats the actual meaning of equality.
Ramya Subraamanian wrote:But this is possible ,because we can write equals in anyway we want which makes statement "A" false.
Ramya Subraamanian wrote:Now there's no confusion. Awesome explanation with the code snippet. Thank you Roel.
Roel De Nijs wrote:The more mock exams (or actual exams) you take, the more familiar you'll get with such "ambiguous" questions and you'll become much better at interpreting the "context of a question".
Roel De Nijs wrote:And altough it might introduce some subtleties, I think it's definitely necessary. Otherwise exam creators would have a very difficult task to create clear/obvious/unambiguous questions.
Roel De Nijs wrote:
Ramya Subraamanian wrote:that's a superb score !!
Agreed! Such a score deserves a topic on its own instead of a post tucked away in some other topic. What are you waiting for, Jan?![]()
Jan Stückrath wrote:
Roel De Nijs wrote:
Ramya Subraamanian wrote:that's a superb score !!
Agreed! Such a score deserves a topic on its own instead of a post tucked away in some other topic. What are you waiting for, Jan?![]()
Thanks.Well, I was just not planning to write a big report about my experiences, so a new topic seemed to be too much self-praise.
But I just noticed that there is a subforum for exam results, so I will add a short entry there and also one to the hall of fame.
[OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Jan Stückrath wrote:But I just noticed that there is a subforum for exam results, so I will add a short entry there and also one to the hall of fame.
Roel De Nijs wrote:Also the explanation has a minor issue: "An interface may only be marked" should be "An interface method may only be marked" (at first glance it seems to be not listed yet in the official overview).
[OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2