<<= Back Next =>>
You Are On Multi Choice Question Bank SET 1643

82151. public class MyRunnable implements Runnable { public void run() { // some code here } } which of these will create and start this thread?





82152. What will be the output of the program? class MyThread extends Thread { MyThread() { System.out.print(" MyThread"); } public void run() { System.out.print(" bar"); } public void run(String s) { System.out.println(" baz"); } } public class TestThreads { public static void main (String [] args) { Thread t = new MyThread() { public void run() { System.out.println(" foo"); } }; t.start(); } }





82153. What will be the output of the program? class MyThread extends Thread { public static void main(String [] args) { MyThread t = new MyThread(); t.start(); System.out.print("one. "); t.start(); System.out.print("two. "); } public void run() { System.out.print("Thread "); } }





82154. What will be the output of the program? class MyThread extends Thread { MyThread() {} MyThread(Runnable r) {super(r); } public void run() { System.out.print("Inside Thread "); } } class MyRunnable implements Runnable { public void run() { System.out.print(" Inside Runnable"); } } class Test { public static void main(String[] args) { new MyThread().start(); new MyThread(new MyRunnable()).start(); } }





82155. What will be the output of the program? class s1 implements Runnable { int x = 0, y = 0; int addX() {x++; return x;} int addY() {y++; return y;} public void run() { for(int i = 0; i < 10; i++) System.out.println(addX() + " " + addY()); } public static void main(String args[]) { s1 run1 = new s1(); s1 run2 = new s1(); Thread t1 = new Thread(run1); Thread t2 = new Thread(run2); t1.start(); t2.start(); } }





82156. What will be the output of the program? public class Q126 implements Runnable { private int x; private int y; public static void main(String [] args) { Q126 that = new Q126(); (new Thread(that)).start( ); / Line 8 / (new Thread(that)).start( ); / Line 9 / } public synchronized void run( ) / Line 11 / { for (;;) / Line 13 / { x++; y++; System.out.println("x = " + x + "y = " + y); } } }





82157. What will be the output of the program? class s1 extends Thread { public void run() { for(int i = 0; i < 3; i++) { System.out.println("A"); System.out.println("B"); } } } class Test120 extends Thread { public void run() { for(int i = 0; i < 3; i++) { System.out.println("C"); System.out.println("D"); } } public static void main(String args[]) { s1 t1 = new s1(); Test120 t2 = new Test120(); t1.start(); t2.start(); } }





82158. What will be the output of the program? class s implements Runnable { int x, y; public void run() { for(int i = 0; i < 1000; i++) synchronized(this) { x = 12; y = 12; } System.out.print(x + " " + y + " "); } public static void main(String args[]) { s run = new s(); Thread t1 = new Thread(run); Thread t2 = new Thread(run); t1.start(); t2.start(); } }





82159. What will be the output of the program? public class ThreadDemo { private int count = 1; public synchronized void doSomething() { for (int i = 0; i < 10; i++) System.out.println(count++); } public static void main(String[] args) { ThreadDemo demo = new ThreadDemo(); Thread a1 = new A(demo); Thread a2 = new A(demo); a1.start(); a2.start(); } } class A extends Thread { ThreadDemo demo; public A(ThreadDemo td) { demo = td; } public void run() { demo.doSomething(); } }





82160. What will be the output of the program? public class WaitTest { public static void main(String [] args) { System.out.print("1 "); synchronized(args) { System.out.print("2 "); try { args.wait(); / Line 11 / } catch(InterruptedException e){ } } System.out.print("3 "); } }





82161. What will be the output of the program? public class SyncTest { public static void main (String [] args) { Thread t = new Thread() { Foo f = new Foo(); public void run() { f.increase(20); } }; t.start(); } } class Foo { private int data = 23; public void increase(int amt) { int x = data; data = x + amt; } } and assuming that data must be protected from corruption, what—if anything—can you add to the preceding code to ensure the integrity of data?





82162. What will be the output of the program? class Happy extends Thread { final StringBuffer sb1 = new StringBuffer(); final StringBuffer sb2 = new StringBuffer(); public static void main(String args[]) { final Happy h = new Happy(); new Thread() { public void run() { synchronized(this) { h.sb1.append("A"); h.sb2.append("B"); System.out.println(h.sb1); System.out.println(h.sb2); } } }.start(); new Thread() { public void run() { synchronized(this) { h.sb1.append("D"); h.sb2.append("C"); System.out.println(h.sb2); System.out.println(h.sb1); } } }.start(); } }





82163. class Test { public static void main(String [] args) { printAll(args); } public static void printAll(String[] lines) { for(int i = 0; i < lines.length; i++) { System.out.println(lines[i]); Thread.currentThread().sleep(1000); } } } the static method Thread.currentThread() returns a reference to the currently executing Thread object. What is the result of this code?





82164. What will be the output of the program? class MyThread extends Thread { public static void main(String [] args) { MyThread t = new MyThread(); / Line 5 / t.run(); / Line 6 / } public void run() { for(int i=1; i < 3; ++i) { System.out.print(i + ".."); } } }





82165. What will be the output of the program? class Test116 { static final StringBuffer sb1 = new StringBuffer(); static final StringBuffer sb2 = new StringBuffer(); public static void main(String args[]) { new Thread() { public void run() { synchronized(sb1) { sb1.append("A"); sb2.append("B"); } } }.start(); new Thread() { public void run() { synchronized(sb1) { sb1.append("C"); sb2.append("D"); } } }.start(); / Line 28 / System.out.println (sb1 + " " + sb2); } }





82166. What will be the output of the program? public class ThreadTest extends Thread { public void run() { System.out.println("In run"); yield(); System.out.println("Leaving run"); } public static void main(String []argv) { (new ThreadTest()).start(); } }





82167. What will be the output of the program? public class Test107 implements Runnable { private int x; private int y; public static void main(String args[]) { Test107 that = new Test107(); (new Thread(that)).start(); (new Thread(that)).start(); } public synchronized void run() { for(int i = 0; i < 10; i++) { x++; y++; System.out.println("x = " + x + ", y = " + y); / Line 17 / } } }





82168. What will be the output of the program? public class Test { public static void main (String [] args) { final Foo f = new Foo(); Thread t = new Thread(new Runnable() { public void run() { f.doStuff(); } }); Thread g = new Thread() { public void run() { f.doStuff(); } }; t.start(); g.start(); } } class Foo { int x = 5; public void doStuff() { if (x < 10) { // nothing to do try { wait(); } catch(InterruptedException ex) { } } else { System.out.println("x is " + x++); if (x >= 10) { notify(); } } } }





82169. What will be the output of the program? class MyThread extends Thread { public static void main(String [] args) { MyThread t = new MyThread(); Thread x = new Thread(t); x.start(); / Line 7 / } public void run() { for(int i = 0; i < 3; ++i) { System.out.print(i + ".."); } } }





82170. Which of the following periodontal lingament fibre groups are not attached to alveolar bone?





82171. Which two can be used to create a new Thread? Extend java.lang.Thread and override the run() method. Extend java.lang.Runnable and override the start() method. Implement java.lang.Thread and implement the run() method. Implement java.lang.Runnable and implement the run() method. Implement java.lang.Thread and implement the start() method.





82172. Most effective method of sterilization in dental clinic is





82173. Which two statements are true? Deadlock will not occur if wait()/notify() is used A thread will resume execution as soon as its sleep duration expires. Synchronization can prevent two objects from being accessed by the same thread. The wait() method is overloaded to accept a duration. The notify() method is overloaded to accept a duration. Both wait() and notify() must be called from a synchronized context.





82174. The following block of code creates a Thread using a Runnable target: Runnable target = new MyRunnable(); Thread myThread = new Thread(target); Which of the following classes can be used to create the target, so that the preceding code compiles correctly?





82175. For painless extraction of lower molar;the most suitable method of local anesthesia is





82176. What is the name of the method used to start a thread execution?





82177. Which two are valid constructors for Thread? Thread(Runnable r, String name) Thread() Thread(int priority) Thread(Runnable r, ThreadGroup g) Thread(Runnable r, int priority)





82178. Which three are methods of the Object class? notify(); notifyAll(); isInterrupted(); synchronized(); interrupt(); wait(long msecs); sleep(long msecs); yield();





82179. class X implements Runnable { public static void main(String args[]) { / Missing code? / } public void run() {} } Which of the following line of code is suitable to start a thread ?





82180. Which cannot directly cause a thread to stop executing?





82181. Syncope is





82182. Trismus is





82183. Ideal autoclaving temperature used in dental clinic is





82184. Most common impacted tooth in the dental arch is





82185. Which of the following is not a muscle of mastication





82186. Elated is to despondent as enlightened is to





82187. Optimist is to cheerful as pessimist is to





82188. Reptile is to lizard as flower is to





82189. Play is to actor as concert is to





82190. Sponge is to porous as rubber is to





82191. Careful is to cautious as boastful is to





82192. Pen is to poet as needle is to





82193. Secretly is to openly as silently is to





82194. Embarrassed is to humiliated as frightened is to





82195. Pride is to lion as shoal is to





82196. Artist is to painting as senator is to





82197. Exercise is to gym as eating is to





82198. Candid is to indirect as honest is to





82199. Guide is to direct as reduce is to





82200. Oar is to rowboat as foot is to





<<= Back Next =>>
Terms And Service:We do not guarantee the accuracy of available data ..We Provide Information On Public Data.. Please consult an expert before using this data for commercial or personal use
DMCA.com Protection Status Powered By:Omega Web Solutions
© 2002-2017 Omega Education PVT LTD...Privacy | Terms And Conditions