This week's book giveaways are in the iOS and Features new in Java 8 forums.
We're giving away four copies each of Barcodes with iOS: Bringing together the digital and physical worlds and Core Java for the Impatient and have the authors on-line!
See this thread and this one for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Interface variable initialization Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Barcodes with iOS this week in the iOS forum
or Core Java for the Impatient in the Java 8 forum!

JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Interface variable initialization" Watch "Interface variable initialization" New topic

Interface variable initialization

Nikhil Bansal
Ranch Hand

Joined: Jan 24, 2005
Posts: 60
Hi All,

I am posting a ques frm the forum itself.

interface I{ int i = 1, ii = Main.out("ii", 2);}

interface J extends I{ int j = Main.out("j", 3), jj = Main.out("jj", 4);}

interface K extends J{ int k = Main.out("k", 5);}

public class Main {

public static void main(String args[]){


public static int out(String s, int i) {

System.out.println(s + "=" + i);
return i;

I think,in interface the variables must be initialized at thier declaration.But here the code is containing method calls.And also iam not able to understand the output.

Please Help Me

Burkhard Hassel
Ranch Hand

Joined: Aug 25, 2006
Posts: 1274
Hi ranchers,

Nikhil Bansal posted Halloween, 2006 06:27 AM
Hi All,

I am posting a ques frm the forum itself.

what was so bad in the explanation in this thread?


all events occur in real time
I agree. Here's the link:
subject: Interface variable initialization