|
|
350 Mock Questions on SCJP 1.5 - JUST Rs.200 or 7 USD
Send us mail to sales@javabeat.net
more details
|
Do you have paypal account? Click Here to pay now and get the questions.
|
|
SCJP 5.0 Objective - 4(10 Questions)
2) What will be the output of the following program?
package chapters.chap04;
public class Ques01 {
public static void main(String[] args) {
HelloThread hello = new HelloThread();
hello.start();
}
}
class MyThread implements Runnable{
@Override
public void run() {
System.out.println("My thread");
}
}
class HelloThread extends Thread{
public void start(){
System.out.println("Hello thread");
}
public void run(){
Thread thread = new Thread(new MyThread());
thread.start();
}
}
- The program will output 'Hello Thread' and 'My Thread'.
- The program will output 'My Thread' and 'Hello Thread'.
- The order of the outputs is not will vary upon execution.
- The program will output 'Hello Thread'.
Answer
2) d.
Since the start() method in the HelloThread has been overridden, the run() method won't be called and hence the output will only be 'My thread'.
|
|
350 Mock Questions on SCJP 1.5 - JUST Rs.200 or 7 USD
Send us mail to sales@javabeat.net
more details
|
|