Win a copy of Grokking Bitcoin this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

Inheritance - OCA Java SE 8 Programmer I Exam Guide - Mock Test question  RSS feed

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
doing a mock test (TEST 1), there is the question "Which are true", followed by several statements about inheritance. One of these is the following:
It is possible to override methods in a class without extending another class

The test consider this statement as FALSE.

I have marked this statement as TRUE, because a class can implement an interface including a default method and override that method. So in my undestanding the statement is true, we can override without extending a class, implementing an interface.

Where am I wrong?


Thank you for your reply

 
Marshal
Posts: 64109
215
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

I think you are right. Let's see whether anybody disagrees.
 
Ranch Hand
Posts: 257
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark,

On the actual exam the number of correct answers you must select is mentioned, so you could use process of elimination.    

Are they possibly suggesting that the Object Class is always always always there with respect to this statement.  Thus, one is never "truly" without at least one superclass?  (I don't know, but that's all I got.)

 
Mark Parent
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Charles O'Leary wrote:Mark,

On the actual exam the number of correct answers you must select is mentioned, so you could use process of elimination.    

Are they possibly suggesting that the Object Class is always always always there with respect to this statement.  Thus, one is never "truly" without at least one superclass?  (I don't know, but that's all I got.)



Well, I appreciate the effort but both points do not reply to my question
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Mark Parent wrote:Hello,
doing a mock test (TEST 1), there is the question "Which are true", followed by several statements about inheritance. One of these is the following:
It is possible to override methods in a class without extending another class

The test considers this statement as FALSE.

I have marked this statement as TRUE, because a class can implement an interface including a default method and override that method. So in my understanding the statement is true, we can override without extending a class, implementing an interface.

Where am I wrong?


Thank you for your reply







I Don't Know Man! I find Question pretty simple and self-explanatory. It's about overriding not implementing or finding other ways.
 
Charles O'Leary
Ranch Hand
Posts: 257
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Mark Parent wrote:
Well, I appreciate the effort but both points do not reply to my question



I guess I failed to fully explain that whether you write "extends java.lang.Object" (unnecessarily) yourself, or perhaps let the compiler do it for you, you cannot override without extending a class.  Specifically, you may not necessarily be overriding one of Object's methods.  Rather, Object will always be in your inheritance tree ... the very definition of extending a class.  Again, I'm rationalizing here because these "word problems" sometimes aren't as precise (to us test takers sometimes, rather than test writers), when compared to a "what is the result of this code" problem.  

I hope that helps?
 
Mark Parent
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Vaibbhav Mande wrote:
I Don't Know Man! I find Question pretty simple and self-explanatory. It's about overriding not implementing or finding other ways.


"It is possible to override methods in a class without extending another class"
You can override methods without extending another class? Yes, implementing an interface that includes default methods and "overriding" them. In my understing this is overriding, and we are not extending but implementing. So, the reply is yes. Also to me the question is pretty simple and self-explanatory, but in the opposite way. So, it is not so simple.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!