TRUE OR FALSE 1.The method run() must be defined when the java.lang.Runnable int
ID: 3841244 • Letter: T
Question
TRUE OR FALSE
1.The method run() must be defined when the java.lang.Runnable interface is implemented.
2.Which interface provides the capability to store objects using a key-value pair?
Java.util.Set
Java.util.Deque
Java.util.Map
Java.util.List
3.What will happen when the program will be executed? All methods of class FileOutputStream, including close(), throw an IOException.
import java.io.*;
public class MyException {
public static void main(String args[]) throws IOException {
FileOutputStream out = null;
try {
out = new FileOutputStream("test.txt");
out.write(122);
} catch(IOException io) {
System.out.println("IO Error.");
} finally {
out.close();
}
}
}
This program fails to compile due to an error at line 4.
This program fails to compile due to an error at line 6.
This program fails to compile due to an error at line 11.
This program will compile successfully.
Explanation / Answer
A) True, public void run() method must be defined when lang.java.Runnable interface is implemented as this interface has only one abstract method that is run(), so must be overridden.
B) Java.util.Map as it gives value on the basis of key.
C) This program fails to compile due to an error at line 11.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.