Question : You have been given below code, what is the expected behavior? package com.hadoopexam;
import java.io.IOException;
public class Welcome extends Thread {
@Override public void run() { System.out.print("HadoopExam"); }
public static void main(String[] args) throws IOException, InterruptedException { Welcome wel = new Welcome(); wel.start(); Thread.sleep(500); System.out.print(".com "); } } 1. It will give compile time error
Correct Answer : Get Lastest Questions and Answer : Explanation: As we can see, here we are calling start() method on Thread class. Hence, it will also print "HadoopExam" . However, we have called Thread.sleep(500) which will ask current thread to waith 500 milli second. In this case main() thread will sleep for 500 ms. Hence, most of the time wel thread would be processed first and then main() thread will be processed.
Question : You have a various runnable tasks, which needs to be executed one by one, based on their priority (Between to ). However, you are keep getting higher priority tasks in the Queue and you lower priority tasks will never get an opportunity to being executed. Which of the following problem is discussed in above statement?
A. Deadlock B. Starvation C. Livelock D. R ace condition
Correct Answer : Get Lastest Questions and Answer : Explanation: It is a example of Starvation, lower priority tasks will never be executed because of higher priority tasks are keep processed.
Question : Which of the following definition are correct?
1. class Welocme { public synchronized void foo() {} }
2. abstract class Welcome { public abstract synchronized void foo(); }