About Question enthuware.ocpjp.v7.2.1550 :

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

Moderator: admin

Post Reply
Paulus
Posts: 5
Joined: Fri Jul 15, 2016 8:55 am
Contact:

About Question enthuware.ocpjp.v7.2.1550 :

Post by Paulus »

The 2nd answer states:

Code: Select all

As there is no conflict, the compiler figures out that 'i' is actually Outer.this.i.
Could you give an example of what is ment by a conflict in this case?

admin
Site Admin
Posts: 10067
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1550 :

Post by admin »

You could have a local variable i in the method or even in the class Inner as well.
ie.

Code: Select all

public class Outer
{
  int i = 10;
  class Inner
  {
    int i = 20;
    public void methodA()
    {
       i = 30;
       //line 1.
    }
  }
}
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 232 guests