aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Static variables 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 "Static variables" Watch "Static variables" New topic
Author

Static variables

rex tony
Ranch Hand

Joined: Aug 29, 2007
Posts: 159




How?
Prasun Howlader
Ranch Hand

Joined: Oct 21, 2007
Posts: 89
Because constructor in class A assign a= 20,b= 30 but in class B that is not happen so default value 10 and 20 print.
[ March 01, 2008: Message edited by: Prasun Howlader ]

"Control time instead of letting time control you."
rex tony
Ranch Hand

Joined: Aug 29, 2007
Posts: 159
why the class B doesn't call value of the constructor of class A?
Krep Lock
Ranch Hand

Joined: Sep 19, 2006
Posts: 43
Originally posted by rex tony:
why the class B doesn't call value of the constructor of class A?


class B does not instantiate an object of class A, so the constructor would never be called. the fields x and y are static, of course, so no instance is necessary when dealing with them as they belong to the class, not any object.
 
Don't get me started about those stupid light bulbs.
 
subject: Static variables