You are on page 1of 6

Which of the following statements is not correct with regard to threads in Java? a.

A call to the wait method causes the calling thread to pause its execution b. The wait and notify methods are defined in the Thread class ----True c. The synchronized keyword can be applied to either a method or a block of code d. Any code that has calls to the wait or notify methods must be synchronized Which of the following statements about threading is incorrect? a. You can obtain a mutually exclusive lock on any object b. Thread scheduling algorithms are platform dependent ---- TRUE c. You can only obtain a mutually exclusive lock on methods in a class that extends Thread or implements runnable d. A thread can obtain a mutually exclusive lock on an object by calling a synchronized method on that object Which of the following is the correct syntax for suggesting that the JVM perform garbage collection? a. System.setGarbageCollection(); b. System.out.gc(); c. System.gc(); --- True d. System.free(); Inheritance is a process by which the objects of parent class acquire the properties of the child class. a. True b. False----TRUE Which option could be use to see additional warnings about code that mixes legacy code with code that uses generics? a. -Xlint:unchecked b. -Xlint:-unchecked c. -Xswitchcheck or -Xlint:fallthrough depending on the version of Java d. -classpath or -cp Which of the following statements are correct with regard to Polymorphism? a. Polymorphism is a method in which a class can exist in multiple forms b. Polymorphism is a method in which a class can exist in only two forms c. Polymorphism is a method in which different instances of an object displays different behavior d. Polymorphism is a method in which different instances of an object displays same behavior

} private void update (Bar bar) { bar. update (b1). } . a.x). update (b). Bar b1 = new Bar (). No What will be the output when this code is compiled and run? public class Test { public Test () { Bar b = new Bar ().x = 20. } public static void main (String args[]) { new Test (). Yes----TRUE b. update (b). update (b1). System.out.Will the following code bind srvSock ? srvSock = new ServerSocket().println (bar. } private class Bar { int x = 10. b1 = b.

println (o. } public String content () throws Exception . Runnable d. 20 20 20 20 d. 10 10 10 10 c. An act of representing essential features without including details or working methodology b. what will the length() method in the File class returns? a.out. It will return the number of characters in the file b. Thread b.} a. It will return the number of lines in the file d. It will return the number of bytes in the file----True c. Applet c. The code will fail to compile b. 10 20 10 20 For a file that exists. An act of representing essential features along with the details or working methodology ---True c. An ability to be present in more than one form In which class is the notify method defined? a.content ()). Object----True What will be the output of the following program? public class Test { public static void main (String args[ ]) { B o = new A (). It will return the length of the file What is Abstraction? a. System. An act of acquiring properties of some other object d.

. The code will compile and on running. } private static class B { public String content () { return ''B''.{ throw new Exception (''This is an exception on this. b. } } } a. b = 0. The code will fail to compile d.content ()''). } } private static class A extends B { public String content () { return ''A''. it will print ''A'' c. The code will compile and on running. it will print ''B'' What will be the output of this program? public class Test { public static void main (String args[]) { int a. a = 2. The code will compile but will fail to run b.

System. y = 3.print( " ( " + x + ". new int[] {b})).out. " + y + " ) " ).out. y ). } void switchCoords( int x. System.out. x = 5.print( " ( " + x + ". 4 ---True What is printed to the standard output if myMethod() is executed? class MyPoint { void myMethod() { int x. (5. switchCoords( x. int y ) { int temp.print( " ( " + x + ". (5. 0 b. y. " + y + " ) " ). x = y. } public static int g (int a. (5. temp = x.println (g (a. 5) (5. 3) b.True d.out. 3) (3. y = temp. No output will be printed Is the following statement true or false? . } } a. 5) (3. 3) (5. System. int b[]) { b[0] = 2 * a. 3) (3. return b[0]. An exception will occur d. } } a. System. 3) --. 1 c. 5) c. " + y + " ) " ). 3) (5.

getAppletContext() . False Can Java be used to send ICMP packets? a. getCodeBase() c. Yes b.A . getDefaultContext() d.java file without any source code is a valid java file. True b. Multiple applets cannot communicate with each other within one HTML page b. No What is the method by which two or more applets can communicate with each other within one HTML page? a. a.