Placement papers on Java - Set 3

Placement papers on Java - Set 3


1. Which of the following are not the methods of the Collection interface?

iterator
isEmpty
toArray
setText
View Answer / Hide Answer

ANSWER: setText




2. Which of the following best describes the use of the synchronized keyword?

Allows two process to run in paralell but to communicate with each other
Ensures only one thread at a time may access a method or object
Ensures that two or more processes will start and end at the same time
Ensures that two or more Threads will start and end at the same time
View Answer / Hide Answer

ANSWER: Ensures only one thread at a time may access a method or object




3. Which of the following methods are members of the Vector class and allow you to input a new element

addElement
insert
append
addItem
View Answer / Hide Answer

ANSWER: addElement




4. Which of the following statements are true

An inner class may be defined as static
There are NO circumstances where an inner class may be defined as private
An inner class may extend another class
1 and 3
View Answer / Hide Answer

ANSWER: 1 and 3




5. Which of the following statements about threading are true

You can obtain a mutually exclusive lock on any object
A thread can obtain a mutually exclusive lock on an object by calling a synchronized method on that object.
Thread scheduling algorithms are platform dependent
All of the above
View Answer / Hide Answer

ANSWER: All of the above




6. Which of the following are not the methods of the Thread class?

yield()
sleep(long msec)
go()
stop()
View Answer / Hide Answer

ANSWER: go()




7. Which of the following will give compile time error?

File f = new File("/","autoexec.bat");
DataInputStream d = new DataInputStream(System.in);
OutputStreamWriter o = new OutputStreamWriter(System.out);
RandomAccessFile r = new RandomAccessFile("OutFile");
View Answer / Hide Answer

ANSWER: RandomAccessFile r = new RandomAccessFile("OutFile");




8. Which of the following is TRUE?

In java, an instance field declared public generates a compilation error.
int is the name of a class available in the package java.lang
Instance variable names may only contain letters and digits.
A class has always a constructor (possibly automatically supplied by the java compiler).
View Answer / Hide Answer

ANSWER: A class has always a constructor (possibly automatically supplied by the java compiler).




9. Consider the following code snippet

String river = new String(Columbia);
System.out.println(river.length());

What is printed?

6
7
8
Columbia
View Answer / Hide Answer

ANSWER: 8




10. A constructor

must have the same name as the class it is declared within.
is used to create objects.
may be declared private
All of the above
View Answer / Hide Answer

ANSWER: All of the above


Post your comment