자격증/OCJP_ExamD
QUESTION 9
IT grow.
2018. 7. 29. 16:23
반응형
QUESTION 9Given:1. public class Threads3 implements Runnable {2. public void run() {3. System.out.print("running");4. }5. public static void main(String[] args) {6. Thread t = new Thread(new Threads3());7. t.run();8. t.run();9. t.start();10. }11. }What is the result?A. Compilation fails.B. An exception is thrown at runtime.C. The code executes and prints running.D. The code executes and prints runningrunning.E. The code executes and prints runningrunningrunning.Solution : E
plus imformation
class Threads 는 메서드 run을 가지고 있음 run은 running 을 출력함
Main문에서 class Threads에 대한 인스턴스를 하나 만듬 그게 t임
결국 threads의 run을 3번 실행 하는 꼴이 됨
반응형