Email address:
Password:
SCJP/OCPJP 1.6 certification
Practice Exams and Training
SCJP Online Training » Discussions

Execution jump

I an unable to understand this thing .... Please help me out sir ...

Hi Shashank,


To run this statement:

System.out.print(ga.i+" "+ga.getI());


We first need to find out the outcome of our expression : ga.i + " " + ga.getI()

Can we print something without knowing it value? No, right? So at this expression, we first need to call ga.getI() to see its value.


As we call this method, there is a println statement in that method which prints "Sub". So that's what gets printed at first.


After that, we have the value "2" returned. Now we know the value of ga.getI(), which is "2". So we can now just print the expression. This will be "1 2".


Since "Sub" has already been printed, the output would be "Sub1 2"


Does this make it clear?

OK..... Thanks for the explanation

ExamLab © 2008 - 2024