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

please explain this

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


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


A) it won't compile as you can not instantiate the interface
B)there is no relation between elephant and alpha1. so, this is ruled out
c)this on also does not compile as the get method in alpha may return the object of Lion or object of elephant which does not have any relationship with each other.
d)this compiles as both lion and elephant has the method soundOff. so, based on the passing string, the particular method will be called.

Hope you got the point.
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A oes not compile as new cannot be used with interface
B;does not compile as incompatible types
c oes not complie as if else can return a elephant object to lion so there incompatible error occurs
d:as alpha methods may return any object i.e Lion or elephant both as soundOff() methods so no problem complies
 
VIGNESHWAR VISWANATHAN
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi rajesh baba...


yo hav said tat new cannot be used with interface...
then how can an interface can return the object...
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

yo hav said tat



English is used on this forum. Please do not try your readers' patience with such carelessness. Please check your post before submitting it, and use the edit post icon if you see obvious mistakes.

And once again, please use a meaningful topic title in future.
Thanks.
[ June 14, 2007: Message edited by: Barry Gaunt ]
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, regarding to alternative C, it also won't compile, because of the name of the reference variable "1" ... it's not a valid variable name.
 
What I don't understand is how they changed the earth's orbit to fit the metric calendar. Tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic