Static Data Members

class sample
{
static int I,
static int j= 2;
static int k;
static String s1;
static String s2 =” Welcome”;
static Boolean flag;
}
class sampleDemo
{
public static void main(String[] args)
{
System.out.println(Sample.i);
System.out.println(Sample.j);
System.out.println(Sample.k);
System.out.println(Sample.s1);
System.out.println(Sample.s2);
System.out.println(Sample.flag);
}
}
Output :
0
2
0
null
Welcome
False

 

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.