wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes java threads 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 "java threads" Watch "java threads" New topic
Author

java threads

Asanka Vithanage
Ranch Hand

Joined: Oct 24, 2008
Posts: 59
when i compiled this gives a asanswer
but my answer is 2.so can any body give a reson to this out


class B extends Thread{
public void run(){
System.out.println("1");
}
}

class A extends B implements Runnable {
public void Run(){
System.out.println("2");
}

public static void main( String as[]){

A a =new A();
Thread z=new Thread(a);
z.start();


}
}


SCJP 1.5 (94%)
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9313
    
  17

Hi asanka!

In your code the run method in class A is mistyped. It must be run not Run. This is why you are getting wrong output...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Asanka Vithanage
Ranch Hand

Joined: Oct 24, 2008
Posts: 59
thank you
ankit
 
wood burning stoves
 
subject: java threads