Bookmark Topic Watch Topic
  • New Topic

a doubt on interfaces & classes

 
sunetra sen
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Report post to moderator
PLEASE SEE THE FOLLOWING PROG:
interface C {
char w = DD.echo('w');
char x = DD.echo('x');
}
interface D extends C {
char y = DD.echo('y');
char z = DD.echo('z');
char a = DD.echo(w);
}
class DD implements D {
static char echo(char c) {
System.out.print(c);
return c;
}
public static void main (String[] args) {

System.out.print("Main");
DD dd = new DD();
System.out.println(a);
}
}

IT GIVES OUTPUT AS:
Mainyzwxww
CAN SOMEBODY PLEASE CLARIFY HOW THIS OUTPUT IS OBTAINED.
THANKS.
 
Dan Chisholm
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
  • Report post to moderator
Sunetra,
Thank you for using my exam.
Please see the following.
http://www.coderanch.com/t/239579/java-programmer-SCJP/certification/Interfac-initialisation-rules
 
    Bookmark Topic Watch Topic
  • New Topic