Sunteți pe pagina 1din 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

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

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

{ throw new Exception (''This is an exception on this.content ()''); } private static class B { public String content () { return ''B''; } } private static class A extends B { public String content () { return ''A''; } } } a. The code will compile but will fail to run b. The code will compile and on running, it will print ''A'' c. The code will fail to compile d. 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, b; a = 2; b = 0;

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

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

S-ar putea să vă placă și