Interviu Thales
Interviu Thales
a) True
b) False (*)
----------------------------------
Which Java building block would you use to implement Producer-Consumer problem?
a) Observer / Observable
b) wait / notify
c) BlockingQueue
--------------------------------------------
How can I provide a method implementation in a Java interface?
a) Methods of a Java interface are implicitly abstract and cannot have
implementations
b) By using “default” methods (*)
c) By extending a class that already provides the method implementation
----------------------------------
You want subclasses in any package to have access to members of a superclass. Which
is the most restrictive access that accomplishes this objective?
a) public
b) private
c) protected (*)
d) transient
e) default
-------------------------------------
-Which of the following are valid method signatures in an interface?
1. private int getArea();
2. public float getVol(float x);
3. protected void main(String args);
4. public static void main(String args);
5. Boolean setFlag(Boolean () test);
-----------------------------------------------------
-Given the following code:
switch (x) {
default:
System.out.println(“Hello”);
}
a) 1 and 3
b) 2 and 4
c) 3 and 5
d) 4 and 6
----------------------------------
Which three guarantee that a thread will leave the running state?
1. yield()
2. wait()
3. notify()
4. notifyAll()
5. sleep(500)
6. aliveThread.join()
7. Thread.killThread()
a) 1, 2 and 4
b) 2, 5 and 6
c) 3, 4 and 7
d) 4, 5 and 7
-----------------------------
Given the following code:
public void readFromSocket() throws IOException {
final byte[] buff = new byte[1024];
Socket socket = new Socket(“localhost”, 5500);
InputStream is = socket.getInputStream();
final int res = is.read(buff);
System.out.println(“Read from socket”); // line 5
}