STATIC MEMBERS-------->
members declared with static keyword . they belong to class not to instance that's why they r called static members they r given memory globally and can be called by both static methods/static functions and non static methods
static member functions can call or use only static data members
STATIC------------------
class Abc///////////////////////base class
{
static int a;
static void geta()
{
a=5;
}
int input()
{
return(a);
}
}
class Xyz extends Abc/////////////////////////derived class
{
int z;
void get()
{
int x;
x=8;
z=x;}
void display()
{
System.out.println(z);
}}
class Static_prog////////////////////////////////////main class
{
public static void main(String arg[])
{
Xyz a1=new Xyz();
a1.geta();
a1.get();
int l=a1.input();
System.out.println(l);
a1.display();
}}
members declared with static keyword . they belong to class not to instance that's why they r called static members they r given memory globally and can be called by both static methods/static functions and non static methods
static member functions can call or use only static data members
STATIC------------------
class Abc///////////////////////base class
{
static int a;
static void geta()
{
a=5;
}
int input()
{
return(a);
}
}
class Xyz extends Abc/////////////////////////derived class
{
int z;
void get()
{
int x;
x=8;
z=x;}
void display()
{
System.out.println(z);
}}
class Static_prog////////////////////////////////////main class
{
public static void main(String arg[])
{
Xyz a1=new Xyz();
a1.geta();
a1.get();
int l=a1.input();
System.out.println(l);
a1.display();
}}

No comments:
Post a Comment