Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Interface variable initialization

 
Nikhil Bansal
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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[]){

{
System.out.println(K.j);
}
}

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
Posts: 1274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
http://www.coderanch.com/t/260017/java-programmer-SCJP/certification/interfaces


Yours,
Bu.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic