aspose file tools*
The moose likes Associate Certification (SCJA,OCAJ 5/6) and the fly likes Help me with this question from mock exam Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Associate Certification (SCJA,OCAJ 5/6)
Bookmark "Help me with this question from mock exam" Watch "Help me with this question from mock exam" New topic
Author

Help me with this question from mock exam

Sid Bachtiar
Greenhorn

Joined: Feb 25, 2007
Posts: 8
Your 17 year old son wanted a car for his birthday, and he was over the moon with the rusty old Al Bundy Dodge you bought him.

On the other hand, your 21 year old daughter wanted a Mercedes for her birthday, and was not amused when she unwrapped the keys to a different, but similar, Al Bundy Dodge.

This scenario describes:

A. the relation between parent and ancestor classes
B. data encapsulation
C. object instantiation
D. the unidirectional nature of polymorphism

The correct answer was D, but I don't understand the answer (or the question for that matter). Would someone please explain to me what this question is all about and why it the answer is D?

BTW this is not a real exam question, this is from http://www.scja.com/ (Fundamentals of JDK).

Thanks
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

Nothing like a challenging question that combines both Java, and American pop culture.

The son wants a car. A Dodge is-a car. By the way, an Al Bundy Dodge refers to the broken down Dodge car that Al Bundy always complained about in the TV show 'Married with Children.'

Married with Children TV Show

The point is, the son wants a car, and a Dodge is-a car. If you want something generic, like a car, and you get one, a specific type of car, then life is good. This is polymorphism in action. When you want a certain type of object, any subtype of that object will suffice.

On the other hand, the daughter wants a very specific type of car - a mercedes. A beaten up old dodge is not a mercedes. A brand new BMW isn't a Mercedes either. The daughter was very specific - she didn't want just a car, but instead, a very specific type of car. Since she didn't get the type that she wanted, she was not happy.

The same thing applies in Java. When you want an Object, any old Object will do. If you want a java.lang.Object, and I give you a java.awt.Color, life is good; if I give you a String, life is good; if I give you a Byte, life is good. On the other hand, if you want a String, and I give you a Byte, Object or java.awt.Color, there will be problems.

With polymorphism, you can ask for a general object, and be given any subclass; but if you are given something more general that the type you are asking for, there will be problems. This is how polymorphism is unidirectional.

Shoot me an email if you have any more questions: male att cameronmckenzie dawt com

-Cameron McKenzie
[ February 25, 2007: Message edited by: Cameron W. McKenzie ]
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

...This scenario describes:

A. the relation between parent and ancestor classes
B. data encapsulation
C. object instantiation
D. the unidirectional nature of polymorphism
E. a question writer who loses focus by trying to be clever :roll:


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Sid Bachtiar
Greenhorn

Joined: Feb 25, 2007
Posts: 8
Hi Cameron,

Thanks for the excellent explanation. Soon after I posted the question above, I realised the website where the mock exam is also provides explanation of the answer, but I still didn't understand after reading it.

To marc,

Yeah, when I read the question, I was like 'What the...'.
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

Yes, you just have to click and drag where it says 'don't click and drag' and you can see the answer.

A bit of a nutty question, I admit. That's the 11th question in a free, 11 question exam, where most of the questions are very dry and to the point. I believe strongly that part of the elegance of Java is how it models in code, many of the ideas we see around us everyday. Inheritance and polymorphism aren't just concepts releated to Java, they're concepts related to life.

It's all about broadening the mind.

Cheers!

-Cameron
[ February 28, 2007: Message edited by: Cameron W. McKenzie ]
Sid Bachtiar
Greenhorn

Joined: Feb 25, 2007
Posts: 8
Hi Cameron,

Are you the author of scja.com?

I think there's an incorrect result in one of the questions:

Which of the following must have their code compiled before being able to deliver content to the client?
A. Java Applets
B. Java based Swing applications
C. Java Server Pages
D. JavaScript

I answered ABC but the result checker said the correct answer is ABD.

It's question 12 of 'Fundamental Java Based Client' set of questions.

Kind Regards,

Sid
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

Those free exams. What do you expect?



I'll fix that up right away. Thanks.

-Cameron
Sid Bachtiar
Greenhorn

Joined: Feb 25, 2007
Posts: 8
Originally posted by Cameron W. McKenzie:
Those free exams. What do you expect?



I'll fix that up right away. Thanks.

-Cameron


Hi Cameron,

I appreciate the availability of the free exams, they are useful and I enjoyed trying them. I was just letting you know so you could fix it.

Btw, aren't they sort of like the advertisement/preview of the paid ones? So if they're broken ...

Kind Regards,

Sid Bachtiar
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Help me with this question from mock exam
 
Similar Threads
Chapter 6 K&B Self Test Question 12 Help
The Best Certification Path
What is the plural of Algorithm ?
Epractize Labs - Drag & Drop behavior
Passed SCJA exam