Hello Everyone! Can anyone tell me answers to these dicy questions from IBM486 Sample test 1.A resulting benefit of using polymorphism is reduction of:
a) methods in the associated classes
b) subclasses needed to accomplish the same functionality
c) case statements and conditionals
d) coupling between classes in the system
2. UML interfaces are used to:
a) define an API for all classes.
b) program in Java, but not in C++ or Smalltalk.
c) define executable logic to reuse across classes.
d) specify required services for types of objects.
Geoff Tate
Ranch Hand
Joined: Feb 06, 2001
Posts: 55
posted
0
1 = a 2 = d I think...
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR> fantastic, a towel? <HR></BLOCKQUOTE>
Junilu Lacar
Ranch Hand
Joined: Feb 26, 2001
Posts: 3008
posted
0
My $0.02: 1. You don't reduce the number of methods in related classes (choice a) because each class will have it's own version of the polymorphic method. (b) doesn't make sense because each subclass could potentially implement the functionality a different way and you can create as many subclasses as you like with the same method name. I can't find any reason for selecting (d) either. Therefore, (c) seems to be the best choice for me. If you didn't have polymorphism, then you'd have to resort to something like:
2. (a) seems to be the best answer to me. (b) is incorrect since the UML is not language-specific (c) an interface does not define executable logic (d) just doesn't sound right to me.
well my choices are 1.c 2.c but these are really tricky questions. You get different answers everytime you think. Is anyone sure
Jack Majad
Greenhorn
Joined: Mar 03, 2001
Posts: 4
posted
0
well my choices are 1.c 2.c but these are really tricky questions. You get different answers everytime you think. Is anyone sure
Jack Majad
Greenhorn
Joined: Mar 03, 2001
Posts: 4
posted
0
well my choices are 1.c 2.c but these are really tricky questions. You get different answers everytime you think. Is anyone sure
Vivek Viswanathan
Ranch Hand
Joined: Mar 03, 2001
Posts: 350
posted
0
my choices are 1.c (same reason as JUNILU LACAR) 2.d Since an interface defines just the type of service given and not how the service is to be given, I am sticking with 2.d , an Interface is something like; I press a button to get the coffee from the coffee machine ..but I DO NOT go into the exact working of how the machine is going to make my coffee, simalrly the button in the coffee machine is my interface for getting me coffee. The examlple may b real stupid ...but I cant help it I am having Coffee rit now :-)
[This message has been edited by Vivek Viswanathan (edited March 04, 2001).]
The reason I said a for no 1 is that there only has to be one method created (ie. parentclass.move()) then there can me a subclass.move(). There doesn't have to be a subclass.subclassMove(). So now I can make parentclass = subclass and call parentClass.move() and get the subclass functionality. I think I didn't select case statements and conditionals is because case statements only work with int-compatable and I think it would be tough to decide which objects method called based on an int flag if you are going to indentify objects on the fly unless you are going to do if instanceOf == object1 { oType = 1 }, then test oType. I could be and have been wrong before though.
Caroline Iux
Ranch Hand
Joined: May 14, 2001
Posts: 103
posted
0
This is an old POST. But anyone who is sure about the answer? I got problems with the same two questions too.
Desai Sandeep
Ranch Hand
Joined: Apr 02, 2001
Posts: 1157
posted
0
1. c Polymorphism is used to reduce case and conditions. 2. d c is a bit tricky.Interface allows reuse, but doesn't have executable logic. -- Sandeep
<b>Sandeep</b> <br /> <br /><b>Sun Certified Programmer for Java 2 Platform</b><br /> <br /><b>Oracle Certified Solution Developer - JDeveloper</b><br /><b>-- Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java </b><br /><b>-- Object-Oriented Analysis and Design with UML</b><br /> <br /><b>Oracle Certified Enterprise Developer - Oracle Internet Platform</b><br /><b>-- Enterprise Connectivity with J2EE </b><br /><b>-- Enterprise Development on the Oracle Internet Platform </b>
Caroline Iux
Ranch Hand
Joined: May 14, 2001
Posts: 103
posted
0
Thanks! I assume "executable logic" means the implementation of an operation here.
sreeram upendran
Greenhorn
Joined: Jun 08, 2001
Posts: 6
posted
0
Answer for Q No 1 : a According to UML User Guide by Booch, Jacobson and Rumbaugh the first choice is the most suitable one for the usage of Polymorphism Answer for Q No 2 : d According to the same reference an Interface is defined like this option (d). I feel very sorry for those who have chosen wrong answers. I just want to tell them one thing : PLEASE STRENGTHEN YOUR FUNDAS ON UML. Refer to standard books like User Guide. I think UMLUG is one of the very few books which provides fundamental understanding of UML concepts
------------------ Ram
Ram
Junilu Lacar
Ranch Hand
Joined: Feb 26, 2001
Posts: 3008
posted
0
Feel sorry for yourself and your own "FUNDAS", dude. Polymorphism and UML have nothing at all to do with each other. And just because "UML" is in the question doesn't mean that it has anything to do with the concept of "interfaces". [This message has been edited by JUNILU LACAR (edited June 08, 2001).]
Desai Sandeep
Ranch Hand
Joined: Apr 02, 2001
Posts: 1157
posted
0
Hi Sreeram,
Originally posted by sreeram upendran: Answer for Q No 1 : a According to UML User Guide by Booch, Jacobson and Rumbaugh the first choice is the most suitable one for the usage of Polymorphism
I am not sure on your reasoning of how Polymorphism would reduce methods in associated classes.With polymorphism you can override methods (or in UML terms, should I say operations) defined in your supertype.If you have 10 subtypes of a supertype and if you have 10 different implementations for your operations (assuming that each subtype is disjoint and behaves/reacts/operates in a different manner; that is reason which prompted you to create a subtype), you will have 10 different implementations of the operation,(i.e. different methods for each of the 10 subclasses for the operation defined in your supertype!).So how is polymorphism reducing methods in the associated classes? The correct answer for 1. should be C.Polymorphism allows you to reduce case and conditions. To illustrate this further, let us assume you have an [b]execute() method in your superclass, Payment.The client is interested in 3 kinds of Payment - Cash,Credit and Check.Without subclassing Payment (and hence not overriding the execute() operation), you would need to put the conditional logic (switch..case,if..else) in the Payment class to account for these kinds of payment.This is so because the execute() would have to take care of all the three kinds of Payment.If you override execute() in your subclasses, viz., CashPayment,CreditPayment and CheckPayment then you only have to plug in a different subclass object to the superclass reference to call the required execute() method.This means the conditional logic in the superclass is no longer required, as the overidden execute() method is taking care of the different kinds of payments.
Originally posted by sreeram upendran: Answer for Q No 2 : d
Your answer for 2. is correct! Would like to say though, UML Interfaces are not Java Interfaces.They symbolize responsibilities (services/operations), which the derived specialized concepts (subtypes) must conform to.UML Interfaces may be implemented as a normal Java class or an interface or an abstract class in the Construct phase, as long as it conforms to the responsibilities specified for it. Hope this helps, Sandeep [This message has been edited by Desai Sandeep (edited June 09, 2001).]
qudsia
Greenhorn
Joined: Jun 05, 2001
Posts: 5
posted
0
Originally posted by sudharma malkas: Hello Everyone! Can anyone tell me answers to these dicy questions from IBM486 Sample test 1.A resulting benefit of using polymorphism is reduction of:
a) methods in the associated classes
b) subclasses needed to accomplish the same functionality
c) case statements and conditionals
d) coupling between classes in the system
2. UML interfaces are used to:
a) define an API for all classes.
b) program in Java, but not in C++ or Smalltalk.
c) define executable logic to reuse across classes.
d) specify required services for types of objects.
The correct answers are 1-c, 2-d. I have scored 100 on the test a couple of times so I am positive, besides both these answers make sense.
Tariq Haque
Greenhorn
Joined: Jun 04, 2001
Posts: 6
posted
0
Hi, Correct answers are 1. c 2. d I am 100% sure about these answers. Tariq
Joe Rossano
Greenhorn
Joined: Apr 13, 2001
Posts: 11
posted
0
I think the confusion about question 1 has to do with inheritance vs. polymorphism. Inheritance eliminates the need to duplicate method implementations in subclasses. Polymorphism eliminates the need to write conditional logic. The appropriate method implementations are determined at runtime through dynamic binding. Hope this is helpful, Joe
Muhammad Asif
Ranch Hand
Joined: Jul 13, 2001
Posts: 201
posted
0
Hi! My answers for these two questions are 1) c 2) d When u r using Polymorphisam then via dymanic binding the references are assigned appropriate objects at run time so their is no need to check to what Class an instance belongs! As the case of interaces, i think that interfaces just declare what services are required from an object. So any class which is realizing an interface has to provide the complete Services that the interface declares. Hope this helps!
Originally posted by Joe Rossano: Inheritance eliminates the need to duplicate method implementations in subclasses.
I would say Inheritance allows you to define a generic operation in the superclass.The implementation of this operation is taken care of by methods defined in the subclasses. I am not sure, if we could say Inheritance eliminates the duplicate method implementation in the subclasses since each subclass is going to have its own specialized implementation.However, the subclass would inherit the responsibility defined in the superclass. Hope this helps, Sandeep