GradePack

    • Home
    • Blog
Skip to content
bg
bg
bg
bg

Author Archives: Anonymous

Consider the following code snippet which is supposed to sho…

Consider the following code snippet which is supposed to show the total order amount when the button is clicked: public static void main(String[] args) { final Order myOrder = new Order(); JButton button = new JButton(“Calculate”); final JLabel label = new JLabel(“Total amount due”); . . . class MyListener implements ActionListener { public void actionPerformed(ActionEvent event) { label.setText(“Total amount due ” + myOrder.getAmountDue()); } } ActionListener listener = new MyListener(); } What is wrong with this code?

Read Details

Which data structure would best be used for keeping track of…

Which data structure would best be used for keeping track of groceries to be purchased at the food market?

Read Details

Consider the following code snippet: public class Coin { pr…

Consider the following code snippet: public class Coin { private String name; . . . public boolean equals(Object otherCoin) { return name.equals(otherCoin.name); } . . . } What is wrong with this code?

Read Details

Assume inputFile is a Scanner object used to read data from…

Assume inputFile is a Scanner object used to read data from a text file that contains a series of double values. Select an expression to complete the following code segment, which reads the values and prints them in standard output, one per line, in a field 15 characters wide, with two digits after the decimal point. while (inputFile.hasNextDouble()) { double value = inputFile.nextDouble(); ___________________________________ // statement to display double value }

Read Details

What reserved word in a method definition ensures that subcl…

What reserved word in a method definition ensures that subclasses cannot override the method?

Read Details

The code segment below displays a pattern of asterisks.  Sel…

The code segment below displays a pattern of asterisks.  Select an expression to complete the code segment so that the resulting algorithm has O(n) running time. for (int k = 0; k < n; k++) { for _______________________ { System.out.print("*"); } System.out.println(); }

Read Details

Assume inputFile is a Scanner object used to read data from…

Assume inputFile is a Scanner object used to read data from a text file that contains a series of double values. Select an expression to complete the following code segment, which reads the values and prints them in standard output, one per line, in a field 15 characters wide, with two digits after the decimal point. while (inputFile.hasNextDouble()) { double value = inputFile.nextDouble(); ___________________________________ // statement to display double value }

Read Details

Consider the code snippet shown below: Stack words1 = new S…

Consider the code snippet shown below: Stack words1 = new Stack(); Stack words2 = new Stack(); words1.push(“abc”); words1.push(“def”); words1.push(“ghi”); while (!words1.empty()) { words2.push(words1.pop()); } while (!words2.empty()) { System.out.print(words2.pop()); } What will be printed when this code is executed?

Read Details

Consider the definition of the Measurable interface and the…

Consider the definition of the Measurable interface and the code snippet defining the Inventory class: public interface Measurable { double getMeasure(); } public class Inventory implements Measurable { . . . public double getMeasure() { return onHandCount; } } Why is it necessary to declare getMeasure as public in the Inventory class?

Read Details

Which of the following statements about superclasses and sub…

Which of the following statements about superclasses and subclasses is true?

Read Details

Posts pagination

Newer posts 1 … 76,274 76,275 76,276 76,277 76,278 … 81,550 Older posts

GradePack

  • Privacy Policy
  • Terms of Service
Top