• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Question, reference, package  RSS feed

 
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I feel it difficult to understand the things;
Is this something talking about what reference variable can be passed to the method?

Please help.


Source
Thanks,
[ May 01, 2007: Message edited by: Chandra Bhatt ]
 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A and B are fine for obvious reasons
C causes compiler error
D is fine given that all we do is assign it to the lastEvent.
However if one would try to use it, you would get a NullPointerException.

Given the code:- D should be fine as lastEvent is not used.
 
Ranch Hand
Posts: 2410
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The point of this question is that if a method expects a reference parameter of type A, then you can send any reference parameter which has the "is a" relationship with A.

One thing this means is that you cannot send a superclass of type A to the method.
 
swarna dasa
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Man!!! you edit your posts in fraction of a second... thats fast..

Yup it deals with inheritance, the kind of reference variables used.

So Reference of the Base class or subclasses would be fine.
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Swarna and Keith for your prompt reply.
It helped me to get the question correctly.



Thanks,
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!