aspose file tools*
The moose likes OO, Patterns, UML and Refactoring and the fly likes Sub class name- qualify clause Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Sub class name- qualify clause" Watch "Sub class name- qualify clause" New topic
Author

Sub class name- qualify clause

Binu K Idicula
Ranch Hand

Joined: Jul 11, 2002
Posts: 99
Please see the question from IBM 486 sample test. The earlier thread for 100% IBM 486 says, the answer is b and c.Can anybody tell me why anwser b is selected than a? Is it because of the clause "even if others do not apply" in the option a?
Can anybody tell me what is implied by option B? The class name should normally be a qualification of its superclass' name. ?

27)
When creating a subclass, which of the following are TRUE?
a) The selected superclass should be chosen because it has some methods the subclass can reuse, even if others do not apply.
b) The class name should normally be a qualification of its superclass' name.
c) The subclass should be of the same type as all of its superclasses.
d) The superclass should be marked as abstract.
Multiple Select - Please select all of the correct answers (this
question has 2 correct choices).
b, c
Binu K Idicula
[ June 25, 2003: Message edited by: Binu K Idicula ]
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
I'm guessing that if the super class is "Animal" they'd say a good subclass would be "FurryAnimal". But "Mammal" just might be better. Maybe they'd like "MammalianAnimal"? Ack!
The thing about writing a multiple choice test is you have to make up silly rules that are testable by muliple choice. Infuriating.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Raj Waters
Ranch Hand

Joined: Apr 21, 2002
Posts: 37
Is there any well defined syntax in UML to show the qualification?
like superclass::subclass
:roll:


- Raj<br />[MCSE, SCJP, SCWCD]
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Stan James:
I'm guessing that if the super class is "Animal" they'd say a good subclass would be "FurryAnimal". But "Mammal" just might be better. Maybe they'd like "MammalianAnimal"? Ack!

Are you saying that "Mammal" is not a qualification of "Animal"?


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Hmmmm, good point! I took the question to suggest more literal qualification, like a name space, and included the original name "Animal". Surely wouldn't have to be that way.
I guess their point was that it should not be a more general term? That I could buy.
I usually do very well on standardized tests (much better than my actual skills might lead others to anticipate) but I still loath them.
HS Thomas
Ranch Hand

Joined: May 15, 2002
Posts: 3404
a} smacks of multiple inheritance
d) not all superclasses need be abstract.An abstract class is a base class that is not instantiated. It provides common functionality to be inherited by subclasses. An abstract class contains no code, but instead, defines what code must be defined in subclasses.
Usually defined at the at the top of an object hierarchy.
So a) and d) are wrong as far as the subclass
qualifying name.
regards
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by HS Thomas:
An abstract class contains no code

That's not totally true - you can even declare a class as abstract when it only has non-abstract methods. The only semantic of the abstract modifier on classes is that it makes them non-instantiatable (is that a word?).
HS Thomas
Ranch Hand

Joined: May 15, 2002
Posts: 3404
Illja, I know the Math and System classes are non-instantiatable (if it isn't a word it's used a lot anyway) also. These are final classes which have static methods and no instance methods.
An abstract class MAY contain abstract methods, that is, methods with no implementation. is what I should have said.The implementation is left to the subclasses.
An abstract class MAY have member variables and methods that were wholly shared by all subclasses.
Thanks for pointing that out.
regards
[ June 27, 2003: Message edited by: HS Thomas ]
Jayadev Pulaparty
Ranch Hand

Joined: Mar 25, 2002
Posts: 662
Math class is non-instantiable. But i don't think that qualifies them as abstract classes.
Also having abstract classes with empty methods is not the best of approaches IMO. Abstract classes are supposed to present some abstract behaviour (provided by the methods), which the child concrete classes are going to consolidate upon. I also agree that it is C++ way of defining an interface, having an abstract class with all pure virtual functions (no body).
HS Thomas
Ranch Hand

Joined: May 15, 2002
Posts: 3404
Math class is non-instantiable. But i don't think that qualifies them as abstract classes.

Sorry, I wasn't saying they were. Just that they are non-instantiatable.
BTW cannot find the words non-instantiatable or non-instantiable in any dictionary.But both words are used a lot so my guess is they will be included soon.
regards
[ June 29, 2003: Message edited by: HS Thomas ]
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Jayadev Pulaparty:
Also having abstract classes with empty methods is not the best of approaches IMO. Abstract classes are supposed to present some abstract behaviour (provided by the methods), which the child concrete classes are going to consolidate upon.

Sometimes it's also sensible to provide (possibly empty) default implementations which subclasses can override. See the AWT "Adapter" classes for an example (i.e. java.awt.event.MouseAdapter).
I also agree that it is C++ way of defining an interface, having an abstract class with all pure virtual functions (no body).

That's because C++ has multiple inheritance for classes, and so doesn't need the concept of interfaces.
Jayadev Pulaparty
Ranch Hand

Joined: Mar 25, 2002
Posts: 662
QUOTE] Sometimes it's also sensible to provide (possibly empty) default implementations which subclasses can override. See the AWT "Adapter" classes for an example (i.e. java.awt.event.MouseAdapter).
I agree with the example you cited above. But, the concept of adapter is to make the implementation of an interface easy for any class by simply deriving from the adapter and only writing code for the methods of interest. I guess implementation of an interface(defining a face/behaviour for an object) is different from giving real shape to an abstraction.
That's because C++ has multiple inheritance for classes, and so doesn't need the concept of interfaces.

This is an excellent observation
BTW, i too searched for instantitable and instantiable, but with no luck in the vocabulary. My vote goes for the latter spelling
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112

Here, processItem is declared abstract, because every subclass is expected to provide its own implementation. Overriding preProcess and/or postProcess on the other hand is optional, so empty implementations are provided.
What do you think?
[ June 29, 2003: Message edited by: Ilja Preuss ]
Jayadev Pulaparty
Ranch Hand

Joined: Mar 25, 2002
Posts: 662
I think this is a good example.
Thanks.
HS Thomas
Ranch Hand

Joined: May 15, 2002
Posts: 3404
I think there is a trick question in there but I can't spot it yet.

BTW , 90% use non-instantiatable and 10% use non-instantiable then non-instantiatable makes it into the vocabulary first.
regards
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sub class name- qualify clause