Question: 16. The method below is designed to print the smaller of two values received as arguments. Select the correct expression to complete the method. public

16. The method below is designed to print the smaller of two values received as arguments. Select the correct expression to complete the method.

public void showSmaller(Comparable value1, Comparable value2) 
{ 
 if ( _________________________ ) 
 System.out.println(value1 + " is smaller."); 
 else 
 System.out.println(value2 + " is smaller."); 

}

a) value1 < value2

b) value1.compareTo(value2) > 0

c) value1.compareTo(value2) == 0

d) value1.compareTo(value2) < 0

17. Which of the following is the correct syntax for creating a File object?

a) File inFile = File("input.txt")

b) File inFile = new File("input.txt")

c) File inFile = File.open("input.txt")

d) File inFile = new File.open("input.txt")

18. Insert the missing code in the following code fragment. This code is intended to open a file and handle the situation where the file cannot be found.

try 
{ 
 String filename = . . .; 
 Scanner in = new Scanner(new File(filename)); 
 . . . 
} 
___________________ 
{ 
 exception.printStackTrace(); 
} 

a) catch (IOException exception)

b) catch (new exception (IOException))

c) catch (IllegalArgumentException exception)

d) catch (IOException)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!