aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes output of the thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "output of the thread" Watch "output of the thread" New topic
Author

output of the thread

srilatha annepu
Greenhorn

Joined: Jun 29, 2006
Posts: 28
public class Tux extends Thread{
static String sName = "vandeleur";
public static void main(String argv[]){
Tux t = new Tux();
t.piggy(sName);
System.out.println(sName);
}
public void piggy(String sName){
sName = sName + " wiggy";
start();
}
public void run(){
for(int i=0;i < 4; i++){
sName = sName + " " + i;
}
}
}


Compilation and probably output of "vandeleur" but possible output of "vandeleur 0 1 2 3"


public class Checket extends Thread{
static String sName="venture";
public static void main(String argv[]){
Checket c = new Checket();
c.everton(sName);
System.out.println(sName);
}
public void everton(String s){
sName+="boatwright";
start();
}
public void run(){
sName="vicarage";
}
}

Compilation and output "vicarage" or possibly "ventureboatwright"

please see the outputs for both

for the first output why is it "vandeleur" and not "vandeleur wiggy";
when it is for the second question please help
wise owen
Ranch Hand

Joined: Feb 02, 2006
Posts: 2023




What is variable hiding and shadowing?
[ July 07, 2006: Message edited by: wise owen ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: output of the thread