About Question com.enthuware.ets.scjp.v6. 2 .321 :
Posted: Mon Jun 08, 2015 2:18 am
Why will it print TestClass.si = 10; ?
I modified the program as follows,
Output :
P24 called inside toString TestClass.si = 10
I modified the program as follows,
Code: Select all
public class P24
{
static int si = 10;
public static void main (String args[])
{
new P24();
}
public P24()
{
System.out.println("P24 called "+this);
}
public String toString()
{
return "inside toString TestClass.si = "+this.si;
}
}
P24 called inside toString TestClass.si = 10