Insert the missing code in the following code fragment. This fragment is intended to read a file named dataIn.txt and write to a file named dataOut.txt. public static void main(String[] args) throws FileNotFoundException { String inputFileName = “dataIn.txt”; String outputFileName = “dataOut.txt”; File inputFile = new File(inputFileName); Scanner in = new Scanner(inputFile); PrintWriter out = _____________; . . . }
Blog
Consider the method powerOfTwo shown below: public boolean p…
Consider the method powerOfTwo shown below: public boolean powerOfTwo(int n) { if (n == 1) // line #1 { return true; } else if (n % 2 == 1) // line #2 { return false; } else { return powerOfTwo(n / 2); // line #3 } } How many recursive calls are made from the original call powerOfTwo(63) (not including the original call)?
When using a combo box, the _______ displays the name of the…
When using a combo box, the _______ displays the name of the current selection.
Consider the following code snippet: public class Vehicle {…
Consider the following code snippet: public class Vehicle { . . . public void setVehicleClass(double numberAxles) { . . . } } public class Motorcycle extends Vehicle { . . . public void setModelName(String model) { . . . } public void setVehicleClass(double numberAxles) { . . . } } Which of the following statements is NOT correct?
The method below generates all nonempty substrings of a word…
The method below generates all nonempty substrings of a word passed as argument. Assuming that the string contains no duplicate characters, select the statement to complete the method so that it prints all nonempty substrings correctly. public static void printSubstrings(String word) { if (word.length() > 0) { for (int j = 1; j
Consider the following code snippet: public interface Measur…
Consider the following code snippet: public interface Measurable { double getMeasure(); ____________ double sum(Measurable[] objects) { // implementation to compute the sum of the Measurable objects } } Which of the following completes the interface declaration correctly?
The method below generates all nonempty substrings of a word…
The method below generates all nonempty substrings of a word passed as argument. Assuming that the string contains no duplicate characters, select the statement to complete the method so that it prints all nonempty substrings correctly. public static void printSubstrings(String word) { if (word.length() > 0) { for (int j = 1; j
What features do GUI builders have to speed the development…
What features do GUI builders have to speed the development of the graphical user interface of the program? I setting properties of dialog boxes II automated event-handling code generation III drag and drop of visual components
What features do GUI builders have to speed the development…
What features do GUI builders have to speed the development of the graphical user interface of the program? I setting properties of dialog boxes II automated event-handling code generation III drag and drop of visual components
Consider the Counter class below. public class Counter { p…
Consider the Counter class below. public class Counter { public int count = 0; public int getCount() { return count; } public void increment() { count++; } } Using the class above and the variables declared below, what is the value of num1.equals(num2)? Counter num1 = new Counter(); Counter num2 = num1;