Q:

Java - Static Variable

0

This program is used to demonstrate Static Variable concept.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

class bill 
{ 
String onam; // onam is instance variable 
String hnam; // hnam is instance variable 
int htax; // htax is instance variable 

static int wtax=300; // wtax is static variable 

bill(String onam,String hnam,int htax) 
{ 
this.onam = onam; 
this.hnam = hnam; 
this.htax = htax; 
} 

void one() 
{ 
System.out.println("\nHouse Tax : "+htax); 
} 

void two() 
{ 
System.out.println("\nWater Tax : "+wtax); 
} 

void three() 
{ 
int ttax; 
ttax = htax + wtax; 
System.out.println("\nTotal Tax : "+ttax); 
} 
} 

class ssvStatic 
{ 
public static void main(String arg[]) 
{ 
bill b = new bill("ssv","D69A",1000); 

b.one(); 
b.two(); 
b.three(); 
} 
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now