• 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
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Question: instance and methodcall

 
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


#160 The following diagram shows the relationship between some classes you have to work with. Note that BaseWidget is declared abstract and that FastWidget is the only class that implements Runnable.



The options show signatures of various methods in another class. Choose the methods you would be able to call with an instance of SlowWidget.


(1) methodA(Object obj)
(2) methodB(BaseWidget bw)
(3) methodC(Runnable rr)
(4) methodD(FastWidget fw)
(5) methodE(SlowWidget sw)



Source: Please click to see the well formatted question
The question is not going inside my brain to think about!

Please help!

Regards,
cmbhatt
[ April 19, 2007: Message edited by: Chandra Bhatt ]
 
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ranchers,

an instance of SlowWidget IS-A object, so first method works.

and so on.

Bu.
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Burkhard for your reply because this thread was moribund for long.

But I couldn't understand the question at first!
Why not option "2"?



Regards,
cmbhatt
 
Burkhard Hassel
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Chandra,
you misunderstood me. I didn't claim that "(1)" is the only correct answer.

"Why not option2"?

you figured out already, that 2 is ok as well.

only one missing...

Bu.
 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1,2,5 is true

(1) methodA(Object obj) // true since SlowWidget is-a Object
(2) methodB(BaseWidget bw) // true SlowWidget is-a BaseWidget
(3) methodC(Runnable rr)
(4) methodD(FastWidget fw)
(5) methodE(SlowWidget sw) // true same as instance type
[ April 20, 2007: Message edited by: Eisa Ayed ]
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
O Yeah,

I came to know!

Thank you very much Burkhard and Eisa!




@cmbhatt
 
Hey cool! They got a blimp! But I have a tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic