|
I have a basic doubt - Java
Hi,
I executed this program without Object and with Object.
With object my answer is 200,202, but I'm not using object ref. I guess,
It should be 18,19. What is the reason ?
// This is my program
package com.test;
public class TestOne {
private static int a=10;
private static int b;
static{
if(a ==10){
a=18;
b=19;
}else{
b=222;
}
}
public TestOne(){
a =200;
b =202 ;
}
public static void main(String[] args) {
TestOne t = new TestOne();
System.out.println(TestOne.a); // Calling without object REF.
System.out.println(TestOne.b);
}
}
|