• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Any hints on inheritance?

 
Bartender
Posts: 1868
81
Android IntelliJ IDE MySQL Database Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I took an Enthuware standard test today and six of the inheritance questions incorrect, which equals about 8.6% of the grade.
I did get five of the inheritance questions correct, however I feel that this is not good enough.
Currently I'm going over the Official Java Trail regarding inheritance and soon I'll be reading other web sites which I've found using Google.
After which I plan on going over this topic in
OCA: Oracle Certified Associate Java SE 8 Programmer I Study Guide: Exam 1Z0-808 by Jeanne Boyarsky, Scott Selikoff

For some reason the IS-A and HAS-A don't always seem to work for me when the questions are kind of as follows:
-----------
Given:

Which line(s) produce errors:

It would appear to me that while I think I know IS-A and HAS-A, I don't fully understand it in these test conditions.
I was wondering if you had any hints or different ways of approaching this subject?
 
Marshal
Posts: 8857
637
Mac OS X VI Editor BSD Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Pete Letkeman wrote:It would appear to me that while I think I know IS-A and HAS-A


You might just preparing too much so you got confused because too tired. Perhaps those two cases for a start could help you back on the track.

HAS-A. PC has a Fan. It has nothing to do with inheritance. PC just have a dependency, which appear to be Fan. In real world understanding, PC can't function properly without a Fan.


IS-A. Every programmer is an employee, but not every employee IS-A programmer. Last bit is very important in your specified case.


Basically on the first line:

What you just said is: I need programmer, take random employee and create software. Wait! Can't do that, he might don't know how to program. Oh I see...

How about, I'll pick employee who I'm sure knows how to program. Do you really know? Ok, I trust you then (cast).

Other than that is illegal without you assuring CEO you know that this employee is programmer. But, if when the time comes to write software, appears that programmer isn't really a programmer, you'll get an exception at runtime (ClassCastException - nope, he just said he knows how to program, apparently I misunderstdood, his actual title within a company is systems administrator).

Other way round is legal:

What you saying here is: I need some employee to do some work. Ok, I'll give you programmer, nevermind, he's programmer, but you asked me just give you employee, so it's fine.
 
Pete Letkeman
Bartender
Posts: 1868
81
Android IntelliJ IDE MySQL Database Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think that you maybe right Liutauras.

What I need to do is when I see something like

I need to give it practical objects.
For instance if this code

is transformed into real file it could be

then when casting it I would know that redApple is could never be an orange, but it can be an apple and has seeds so then this could work

However this is something that I still need to work on as I'm not exactly pleased with my last score.
The Enthuware tests before this I did do okay on. I just need to think of things in real like like fruits, employees, programmers.
 
Liutauras Vilda
Marshal
Posts: 8857
637
Mac OS X VI Editor BSD Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Pete Letkeman wrote:However this is something that I still need to work on as I'm not exactly pleased with my last score.
The Enthuware tests before this I did do okay on. I just need to think of things in real like like fruits, employees, programmers.


Maybe. In my own belief, I think it is healthy to put stuff away for a while (day or two) and do not think about it at all - do completely different stuff, so let your brains to process the stuff you read. After few days come back and read once again with a fresh head and see if you understanding is still the same, in case yes - then you probably know this stuff. Verify with test not in a rush mode.

I think speed comes with practice. But to understand question and identify correct answer you can let yourself to spend an hour or so - important is to understand, later you can train your eye and an ability to identify those things quicker.
 
Pete Letkeman
Bartender
Posts: 1868
81
Android IntelliJ IDE MySQL Database Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for helping me put this into perspective Liutauras.

Some time away form it all can be great. Yet some times the upcoming task, in my case exam, is still on the mind.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic