Given the code fragment:public void recDelete (String dirName) throws IOException {File [ ] listOfFiles = new File (dirName) .listFiles();if (listOfFiles ! = null && listOfFiles.length >0) {for (File aFile : listOfFiles) {if (aFile.isDirectory ()) {recDelete (aFile.getAbsolutePath ());} else {if (aFile.getName ().endsWith (".class"))aFile.delete ();}}}}Assume that Projects contains subdirectories that contain .class files and is passed as an argument to the recDelete () method when it is invoked.What is the result?
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());fName and then ascending order of lName?Which code fragment, when inserted at line n1, sorts the employees list in descending order of
Given the code fragments:4. void doStuff() throws ArithmeticException, NumberFormatException, Exception {5. if (Math.random() >-1 throw new Exception ("Try again");6. }and24. try {25. doStuff ( ):26. } catch (ArithmeticException | NumberFormatException | Exception e) {27. System.out.println (e.getMessage()); }28. catch (Exception e) {29. System.out.println (e.getMessage()); }30. }Which modification enables the code to print Try again?
Given the definition of the Country class:public class country {public enum Continent {ASIA, EUROPE}String name;Continent region;public Country (String na, Continent reg) {name = na, region = reg;}public String getName () {return name;}public Continent getRegion () {return region;}}and the code fragment:List<Country> couList = Arrays.asList (new Country ("Japan", Country.Continent.ASIA),new Country ("Italy", Country.Continent.EUROPE),new Country ("Germany", Country.Continent.EUROPE));Map<Country.Continent, List<String>> regionNames = couList.stream ().collect(Collectors.groupingBy (Country ::getRegion,Collectors.mapping(Country::getName, Collectors.toList()))));System.out.println(regionNames);
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?USCurrency enumeration declaration within the Coin class.
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 -