permaculture playing cards*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Why null null? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Why null null?" Watch "Why null null?" New topic
Author

Why null null?

Sandeep Sachan
Greenhorn

Joined: Sep 17, 2005
Posts: 9
Hi, I got this question in to my MasterExam i am not getting why the answer is Null and null
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

s is always null. What do you expect it to be ?


[My Blog]
All roads lead to JavaRanch
Sandeep Sachan
Greenhorn

Joined: Sep 17, 2005
Posts: 9
I am bit confused into this perticular code


please elaborate it in little deep, i ma not getting the part which is there in to main method.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

dhwani mathur
Ranch Hand

Joined: May 08, 2007
Posts: 621
ok!!
public static void main(String [] args)
{
Mineral [] ma = {new Mineral(), new Gem()};

for(Object o : ma)
getWeight((Mineral)o);
}

here Mineral is the Base class,ma is the reference to the class Mineral
you will notice at right side new Mineral,new Gem......now here it is instantiated by writing "new" ...."so ma becomes the object".

Later enhanced for loop is used,where Object o is assigned object ma(actualy value),than getweight method is called.

i hope it helps you to atleast some extent.
Bharat Makwana
Ranch Hand

Joined: May 21, 2007
Posts: 107
Originally posted by Sandeep Sachan:
[QB]Hi, I got this question in to my MasterExam i am not getting why the answer is Null and null

Sorry budy,but answer is null null , you have capitalized N in first one



ॐ सर्वे जना: सुखिनो भवन्तु , तथास्तु |
'May the whole world be happy, so be it'

SCJP1.5, SCWCD1.5
Sandeep Sachan
Greenhorn

Joined: Sep 17, 2005
Posts: 9
Thanks ranchars,
prateek urmaliya
Ranch Hand

Joined: Sep 15, 2006
Posts: 87
ma is the reference to the class Mineral

[ June 25, 2007: Message edited by: prateek urmaliya ]

this message brought to you by .... PIE! .... it's yummy! ;)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why null null?