Placement papers on Java - Set 4
1. Which of the following may be part of a class definition?
instance variables
instance methods
constructors
All of the above
View Answer / Hide Answer2. What is different between a Java applet and a Java application?
An application can in general be trusted whereas an applet can't.
An applet must be executed in a browser environment.
An applet is not able to access the files of the computer it runs on
All of the above
View Answer / Hide Answer3. What is byte code in the context of Java?
The type of code generated by a Java compiler
The type of code generated by a Java Virtual Machine
It is another name for a Java source file
It is the code written within the instance methods of a class.
View Answer / Hide AnswerANSWER: The type of code generated by a Java compiler
4. What is garbage collection in the context of Java?
The operating system periodically deletes all of the java files available on the system.
Any package imported in a program and not used is automatically deleted.
When all references to an object are gone, the memory used by the object is automatically reclaimed.
The JVM checks the output of any Java program and deletes anything that doesn't make sense.
View Answer / Hide AnswerANSWER: When all references to an object are gone, the memory used by the object is automatically reclaimed.
5. You read the following statement in a Java program that compiles and executes.
submarine.dive(depth);
What can you say for sure?
depth must be an int
dive must be a method.
dive must be the name of an instance field.
submarine must be the name of a class
View Answer / Hide AnswerANSWER: dive must be a method.
6. sleep(50); The above statement of a thread implies that the thread will get the processor-time
any moment after 50 milliseconds
exactly after 50 milliseconds
even before 50 milliseconds if the processor is idle
none
View Answer / Hide AnswerANSWER: exactly after 50 milliseconds
7. If a thread is to be declared as a daemon thread, it must be declared before
start method
run method
stop method
none
View Answer / Hide Answer8. What is the optput of this code fragment.
int X=3; int Y =10;
System.out.println(y%x);
0
1
2
3
View Answer / Hide Answer9. A monitor called mon has 5 threads in its waiting pool; all these waiting threads have the same priority. One of the threads is thread1. How can you notify thread1 so that it alone moves from Waiting state to Ready State?
Execute notify(thread1); from within synchronized code of mon.
Execute mon.notify(thread1); from synchronized code of any object.
Execute thread1.notify(); from synchronized code of any object.
You cannot specify which thread will get notified.
View Answer / Hide AnswerANSWER: You cannot specify which thread will get notified.
10. TreeMap class is used to implement which collection interface. Select the one correct answer
SortedSet
List
Tree
SortedMap
View Answer / Hide Answer