I got a program from my friend, it was ok. When i compiled it and ran it,
i got a very different output.
I am pasting the program with output. Please tell me how constructors got invoked in respective program.
File : Bootchy.java
public class Bootchy {
int bootch;
String snootch;
public Bootchy() {
this("snootchy");
System.out.print("first ");
}
public Bootchy(String snootch) {
this(420, "snootchy");
System.out.print("second ");
}
public Bootchy(int bootch,String snootch) {
this.bootch = bootch;
this.snootch = snootch;
System.out.print("third ");
}
public static void main(String[] args)
{
Bootchy b = new Bootchy();
System.out.print(b.snootch + " " + b.bootch);
}
}
Output :
E:\>javac Bootchy.java
E:\>java Bootchy
third second first snootchy 420
2006-08-17
18:55:13
·
2 answers
·
asked by
K Ban
2
in
Computers & Internet
➔ Programming & Design