The data.doc, data.txt and data.xml files are accessible and contain text.Given the code fragment:Stream<Path> paths = Stream.of (Paths. get("data.doc"),Paths. get("data.txt"),Paths. get("data.xml"));paths.filter(s-> s.toString().endWith("txt")).forEach(s -> {try {Files.readAllLines(s).stream().forEach(System.out::println); //line n1} catch (IOException e) {System.out.println("Exception");}});What is the result?data.txt file.
Given:final class Folder { //line n1//line n2public void open () {System.out.print("Open");}}public class Test {public static void main (String [] args) throws Exception { try (Folder f = new Folder()) { f.open();}}}Open Close?Which two modifications enable the code to printline n1 with:
Given:public class Emp {String fName;String lName;public Emp (String fn, String ln) {fName = fn;lName = ln;}public String getfName() { return fName; }public String getlName() { return lName; }}and the code fragment:List<Emp> emp = Arrays.asList (new Emp ("John", "Smith"),new Emp ("Peter", "Sam"),new Emp ("Thomas", "Wale"));emp.stream()//line n1.collect(Collectors.toList());Which code fragment, when inserted at line n1, sorts the employees list in descending order of fName and then ascending order of lName?
You want to create a singleton class by using the Singleton design pattern.Which two statements enforce the singleton nature of the design?
Given:public enum USCurrency {PENNY (1),NICKLE(5),DIME (10),QUARTER(25);private int value;public USCurrency(int value) {this.value = value;}public int getValue() {return value;}}public class Coin {public static void main (String[] args) {USCurrency usCoin =new USCurrency.DIME;System.out.println(usCoin.getValue()):}}Which two modifications enable the given code to compile? (Choose two.)
Given the definition of the Vehicle class:Class Vehhicle {int distance; //line n1Vehicle (int x) {this distance = x;}public void increSpeed(int time) { //line n2int timeTravel = time; //line n3class Car {int value = 0;public void speed () {value = distance /timeTravel;System.out.println ("Velocity with new speed"+value+"kmph");}}new Car().speed();}}and this code fragment:Vehicle v = new Vehicle (100);v.increSpeed(60);What is the result?Velocity with new speed -