• 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

Sub class name- qualify clause

 
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there any well defined syntax in UML to show the qualification?
like superclass::subclass
:roll:
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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"?
 
Stan James
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 3404
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 3404
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3404
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 662
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 662
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think this is a good example.
Thanks.
 
HS Thomas
Ranch Hand
Posts: 3404
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic