About Question com.enthuware.ets.scjp.v6. 2 .321 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
subhamsdalmia
Posts: 32
Joined: Sat May 02, 2015 11:57 pm
Contact:

About Question com.enthuware.ets.scjp.v6. 2 .321 :

Post by subhamsdalmia »

Why will it print 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;
   }
}
Output :
P24 called inside toString TestClass.si = 10

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests