TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Java Static Variable Demo
Senthilvelan Sambamoorthy
Aug 21
2016
Code
582
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
ssvStatic.rar
// static variable demonstration
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();
}
}
Java
Static Variable Demo