• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Too subjective to test your knowledge of the inheritance objective

 
Brian Brumpton
Ranch Hand
Posts: 40
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Given the following code, which statements are true?


Select 3:

a. An instance of TwoWheeler is also an instance of FourWheeler.
b. An instance of TwoWheeler is a valid instance of Automobile.
c. The use of inheritance is not justified here because a TwoWheeler is not really a FourWheeler.
d. The code will compile only if name is removed from TwoWheeler.
e. The code will fail to compile.

Okay, according to Enthuware, test 1, question 29 this is an easy one to answer. The answers being a, b, and c.

The explanation given is "The use of inheritance in this code is not justifiable, since conceptually, a TwoWheeler is-not-a FourWheeler."

Having studied up on inheritance, a and b were fairly easy to spot and d would be correct if it did not include "only if."

Correct me if I'm wrong, but isn't answer c is too subjective to be considered a correct answer in anyone's eyes but the question's author?

Sure, if you look at it in the literal sense, the naming of the classes TwoWheeler vs. FourWheeler might be justification for such an answer but isn't this the sort thing that is left up to the programmer(s) to decide in the real world?

For me, "conceptually" a FourWheeler would be much closer to a TwoWheeler, in the real world, than it would an Automobile. My justification being, many of the components and technologies used in a TwoWheeler are also used in a FourWheeler. Am I reading too much into the question?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No a motorcycle is not a car, and vice versa. I don't think it's subjective at all.
 
Brian Brumpton
Ranch Hand
Posts: 40
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No a motorcycle is not a car, and vice versa. I don't think it's subjective at all.


My point exactly! A motorcycle is not a car, so wouldn't it stand to reason that a better answer would be "The use of inheritance is not justified here because a Automobile is not really a FourWheeler" given that the similarities between a FourWheeler and a Automobile are really only that each has four wheels?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nope. not seeing where you are coming from. A FourWheeler is clearly a type of Automobile.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Brian Brumpton wrote:For me, "conceptually" a FourWheeler would be much closer to a TwoWheeler, in the real world, than it would an Automobile. My justification being, many of the components and technologies used in a TwoWheeler are also used in a FourWheeler. Am I reading too much into the question?

That's completely irrelevant to determine if answer (c) is correct or wrong. Answer (c) only mentions TwoWheeler and FourWheeler, and I think it's safe to say that a FourWheeler IS-NOT-A TwoWheeler and vice versa, so inheritance should not be used here at all! This class hierarchy is similarAnd because Human IS-NOT-A FourLegs, inheritance should not be used here.

It would be a whole other discussion if for example answer (c) had been: The relationship between TwoWheeler and FourWheeler (class inheritance) is less (or more) justified than the relationship between FourWheeler and Automobile. This would be a much more debetable, because which one is true: FourWheeler IS-A Automobile or Automobile IS-A FourWheeler? Some real life examples: a go-kart is definitely a FourWheeler but (in my opinion) not an Automobile. And you have a Reliant Robin which is an Automobile (good or bad doesn't matter, but this Top Gear video gives an idea ) but not a FourWheeler. So that's really a tough one!

Now back to the important things. If you would encounter a similar question on the actual exam, it often uses non-existing class names (e.g. Hmpf & Zmpf; Zing, Zang & Zong;...) probably to avoid this kind of (personal) interpretations.

Hope it helps!
Kind regards,
Roel
 
Paul Anilprem
Enthuware Software Support
Ranch Hand
Posts: 3817
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roel De Nijs wrote:
Now back to the important things. If you would encounter a similar question on the actual exam, it often uses non-existing class names (e.g. Hmpf & Zmpf; Zing, Zang & Zong;...) probably to avoid this kind of (personal) interpretations.

Hope it helps!
Kind regards,
Roel

It is true that most of the questions in the exam use made up names.
This question, however, cannot use such names because it is modeling a real world situation, which is what one would be doing while developing applications. Further, how to form the hierarchy of the classes is actually completely left to the programmer (or the development team).


Of course, many real life modeling cases will be subjective. But you may expect questions on the exam where the situation is fairly obvious. If you extend HumanBeing class from a Cat, that would be obviously wrong. Our intention with this question is also the same. The author assumes that a TwoWheeler is obviously not a FourWheeler but if it is not too obvious, then we have to come up with a situation that is even more obvious.

HTH,
Paul.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Anilprem wrote:But you may expect questions on the exam where the situation is fairly obvious. If you extend HumanBeing class from a Cat, that would be obviously wrong. Our intention with this question is also the same. The author assumes that a TwoWheeler is obviously not a FourWheeler but if it is not too obvious, then we have to come up with a situation that is even more obvious.

True! I remember one similar question I got on the exam (which was drag-and-drop style) and it used also real world nouns which were very distinctive, no interpretation possible (e.g. House, Tree, Animal, Cat).

For me there's no ambiguity between TwoWheeler and FourWheeler. But if you would change it to Bicycle and Car, it might get rid of the tiniest misinterpretation. Just a suggestion!
 
Brian Brumpton
Ranch Hand
Posts: 40
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roel and Paul, I get the biggest kick out of reading the back an forth between the two of you. It's like watching Bruce Lee and Chuck Norris throw down! You both seem to understand what I was asking. The "subjective" I was referring to was how easily, at least for me, our personal associations with words and phrases, based upon our location, background, beliefs, etc... influence our interpretations of such questions. Bear quickly made the connection that a TwoWheeler was a motorcycle but could not see why I clearly did not associate a FourWheeler with an Automobile.

I was raised racing dirtbikes (TwoWheelers) and for me a FourWheeler, Quad, ATV were all names associated with those four wheeled motorcycles for people without any balance.

Clearly, I need to set aside my associations and pay attention to the which answers make the most sense. Options d and e obviously weren't correct and I should have reasoned that c would be the most viable choice. I can save my arguments about how to structure class hierarchies for a paying gig. Back to the books!
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Brian Brumpton wrote:Clearly, I need to set aside my associations and pay attention to the which answers make the most sense. Options d and e obviously weren't correct and I should have reasoned that c would be the most viable choice.

Getting the correct answer by elimination of the wrong ones is a great technique you could/should use on both the mock and actual exams. On the actual exam (and Enthuware) there's even a visual aid: if you are 100% sure an answer is wrong, simply right click on the option and it will look like this line It doesn't affect the selection of the correct answers and if you need to guess in the end, you'll have much more chance to guess correctly if you have only 2-3 answers left instead of 5-6.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic