Search This Blog

15 June, 2011

Simple Java program 9

9. Simple Java programs to know what 
    output  will be.


class aaa
{
static final private int a;

private int b;
public void sam()

System.out.println(a); 

}

static                    // Static constructor
{
a=7;
}
}
class psp
{
public static void main(String aa[])
{
aaa x;
x=new aaa();
x.aaa();

}



Note:- If we don't want to declare the value to static
            property at the point of declaration then we can 
            also assign value for that static property in static 
            constructor. It will get compiled easily.


Output:- 7

No comments:

Post a Comment

Meetme@