//what is the o/p ?
package govind;
public class VariableScope {
public static
void main(String[] args) {
int x;
x=5;
{
int y=6;
System.out.println(x+" "+y);
}
System.out.println(x+" "+y);
}
}
o/p:-Compile time error
//what is the o/p ?
package govind;
public class Access {
static int x;
void increment()
{
x++;
}
}
package
govind;
public class
StaticUse {
public static void
main(String[] args) {
Access obj1=new
Access();
Access obj2=new
Access();
obj1.x=0;
obj1.increment();
obj2.increment();
System.out.println(obj1.x+ "
"+obj2.x);
}
}
o/p:-----------
2 2
No comments:
Post a Comment