Question 106
Given the code fragment:
public static void main (String [ ] args) throws IOException {
BufferedReader br = new BufferedReader (new InputStremReader (System.in));
System.out.print ("Enter GDP: ");
/ /line 1
}
Which code fragment, when inserted at line 1, enables the code to read the GDP from the user?
public static void main (String [ ] args) throws IOException {
BufferedReader br = new BufferedReader (new InputStremReader (System.in));
System.out.print ("Enter GDP: ");
/ /line 1
}
Which code fragment, when inserted at line 1, enables the code to read the GDP from the user?
Question 107
Given:

and the code fragment:

The threads t1 and t2 execute asynchronously and possibly prints ABCA or AACB.
You have been asked to modify the code to make the threads execute synchronously and prints ABC.
Which modification meets the requirement?

and the code fragment:

The threads t1 and t2 execute asynchronously and possibly prints ABCA or AACB.
You have been asked to modify the code to make the threads execute synchronously and prints ABC.
Which modification meets the requirement?
Question 108
Which statement is true about java.util.stream.Stream?
Question 109
Given the code fragment:
public class FileThread implements Runnable {
String fName;
public FileThread(String fName) { this.fName = fName; }
public void run () System.out.println(fName);}
public static void main (String[] args) throws IOException, InterruptedException { ExecutorService executor = Executors.newCachedThreadPool(); Stream<Path> listOfFiles = Files.walk(Paths.get("Java Projects")); listOfFiles.forEach(line -> { executor.execute(new FileThread(line.getFileName().toString())); // line n1
});
executor.shutdown();
executor.awaitTermination(5, TimeUnit.DAYS);//
line n2
}
}
The Java Projects directory exists and contains a list of files.
What is the result?
public class FileThread implements Runnable {
String fName;
public FileThread(String fName) { this.fName = fName; }
public void run () System.out.println(fName);}
public static void main (String[] args) throws IOException, InterruptedException { ExecutorService executor = Executors.newCachedThreadPool(); Stream<Path> listOfFiles = Files.walk(Paths.get("Java Projects")); listOfFiles.forEach(line -> { executor.execute(new FileThread(line.getFileName().toString())); // line n1
});
executor.shutdown();
executor.awaitTermination(5, TimeUnit.DAYS);//
line n2
}
}
The Java Projects directory exists and contains a list of files.
What is the result?
Question 110
Given:

Given the code fragment:

Which two sets of actions, independently, enable the code fragment to print Fit?

Given the code fragment:

Which two sets of actions, independently, enable the code fragment to print Fit?