
5.22 Class Objects and Methods
32. System.out.println(“Total empl:”+ StaticOutClass.countEmp);
33. System.out.println(“male emp:”+ StaticOutClass.mcount);
34. System.out.println(“female emp:”+StaticOutClass.fcount);
35. }
36. }// end of EmpStatic2 class
Output: block initializes all static variable :
total employess salary :22000.0
Total No of employess :2
No of male employess :1
No of female employess :1
Display static variable directly outside class
total employess salary :42000.0
Total No of employess :3
No of male employess :2
No of female employess :1
Line Nos. 30 to 34: show use of static variables directly by mentioning the class name,
StaticOutClass, ...