This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Interface implementation issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Interface implementation issue " Watch "Interface implementation issue " New topic
Author

Interface implementation issue

vineet walia
Ranch Hand

Joined: Feb 16, 2008
Posts: 138



i have to print f1 interface variable
Ninad Kulkarni
Ranch Hand

Joined: Aug 31, 2007
Posts: 787



Your code will not compile because reference to i is ambiguous, both variable i in f1 and variable i in f2 match
so you have to use f1.i


SCJP 5.0 - JavaRanch FAQ - Java Beginners FAQ - SCJP FAQ - SCJP Mock Tests - Tutorial - JavaSE7 - JavaEE6 -Generics FAQ - JLS - JVM Spec - Java FAQs - Smart Questions
vineet walia
Ranch Hand

Joined: Feb 16, 2008
Posts: 138
thanks a lot
Rohini Shirpewar
Greenhorn

Joined: Jan 25, 2011
Posts: 15
This should work.

Hareendra Reddy
Ranch Hand

Joined: Jan 09, 2011
Posts: 173

Hi all,

variables declared inside a interface are implicitly public ,static and final,
So, we can refer to the desired variable by using qualified name with interface type..

Can some one explain how to access the super class instance variable of same name....



Hoe to access the f3 version of variable i ??
Ninad Kulkarni
Ranch Hand

Joined: Aug 31, 2007
Posts: 787

@Hareendra
You can start new thread and ask question about super class and sub class issue because subject line of thread is interface implementation issue.
James Elsey
Ranch Hand

Joined: Dec 21, 2007
Posts: 228

would the i not be overridden if one interface extends another?


Kind Regards, James. OCPJP 1.6 || My SCJP / OCJCP Study Notes
Interested in : SCJP, Google App Engine, Stripes, Android;|| My Bite-Size SCJP Study Blog
Ninad Kulkarni
Ranch Hand

Joined: Aug 31, 2007
Posts: 787

Overriding happens with instance method
See OverridingVsHiding
Salil Vverma
Ranch Hand

Joined: Sep 06, 2009
Posts: 253

Hi Hareendra,

You can access the value of i of f3 as mentioned below -



Regards
Salil Verma
Hareendra Reddy
Ranch Hand

Joined: Jan 09, 2011
Posts: 173

Thank you Salil...
Eric Kizaki
Greenhorn

Joined: Jan 21, 2011
Posts: 12

Also:


OCPJP 6
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Interface implementation issue
 
Similar Threads
how to map this hierarchy
Assigning Array references
Final Reference Variable
Why is this thread closed?
Why is this code printing false false...this is from K&B book