2.99 See Answer

Question: Suppose a method named showValues accepts two


Suppose a method named showValues accepts two int arguments. Which of the following method headers is written correctly?
1. public static void showValues()
2. public static void showValues(int num1, num2)
3. public static void showValues(num1, num2)
4. public static void showValues(int num1, int num2)


> Describe the difference between the sequential search and the binary search.

> What’s wrong with the following array declarations? int[ ] readings = new int[−1]; double[ ] measurements = new double[4.5];

> How many times will the selection sort swap the smallest value in an array with another value?

> What value in an array does the selection sort algorithm look for first? When the selection sort finds this value, what does it do with it?

> Write a while loop that lets the user enter a number. The number should be multiplied by 10, and the result stored in the variable product. The loop should iterate as long as product contains a value less than 100.

> A video rental store keeps videos on 50 racks with 10 shelves each. Each shelf holds 25 videos. Declare a three-dimensional array large enough to represent the store’s storage system.

> Recall that we discussed a Rectangle class in Chapter6 . Write code that declares a Rectangle array with five elements. Instantiate each element with a Rectangle object. Use the Rectangle constructor to initialize each object with values for the length a

> 1. Write a statement that declares a String array initialized with the following strings: “Mercuryâ€, “Venusâ€, “Earthâ€, and “Marsâ€. 2. Write a loop that displays the contents of each element in the array you declared in A. 3. Write a loop that

> Write a method named zero, which accepts an int array as an argument and stores the value 0 in each element.

> Look at the following method header: public static void myMethod(double[] array) Here is an array declaration: double[] numbers = new double[100]; Write a statement that passes the numbers array to the myMethod method.

> Look at the following statements: int[] a = { 1, 2, 3, 4, 5, 6, 7 }; int[] b = new int[7]; Write code that copies the a array to the b array.

> A program has the following declaration: double[] values; Write code that asks the user for the size of the array and then creates an array of the specified size, referenced by the values variable.

> A program uses a variable named array that references an array of integers. You do not know the number of elements in the array. Write a for loop that stores −1 in each element of the array.

> Write statements that create the following arrays: 1. A 100-element int array referenced by the variable employeeNumbers. 2. A 25-element double array referenced by the variable payRates. 3. A 14-element float array referenced by the variable miles. 4. A

> In this chapter we used the metaphor of a kite attached to a spool of string to describe the relationship between an object and a reference variable. In this metaphor, does the kite represent an object, or a reference variable?

> Write an if-else statement that displays the String objects title1 and title2 in alphabetical order.

> You hear someone make the following comment: “A blueprint is a design for a house. A carpenter can use the blueprint to build the house. If the carpenter wishes, he or she can build several identical houses from the same blueprint.†Think of this as a

> How is the relationship between an object and a reference variable similar to a kite and a spool of string?

> What values do reference variables hold?

> What does the new operator do?

> You have programs that create Scanner, Random, and PrintWriter objects. Where are the Scanner, Random, and PrintWriter classes?

> Will all of a class’s actions always be directly mentioned in the problem domain description?

> How is a class like a blueprint?

> What two questions should you ask to determine a class’s responsibilities?

> What are a class’s responsibilities?

> How do you identify the potential classes in a problem domain description?

> Write an if statement that prints the message “The number is valid†if the variable temperature is within the range −50 through 150.

> When designing an object-oriented application, who should write a description of the problem domain?

> What is a problem domain?

> How many default constructors may a class have?

> Look at the following class: public class CheckPoint { public void message(int x) { System.out.print("This is the first version "); System.out.println("of the method."); } public void message(String x) { System.out.print("This is the second version "); S

> What is a method’s signature?

> Is it required that overloaded methods have different return values, different parameter lists, or both?

> Assume that the following is a constructor, which appears in a class: ClassAct(int number) { item = number; } 1. What is the name of the class that this constructor appears in? 2. Write a statement that creates an object from the class and passes the val

> What are an object’s methods?

> What is a constructor’s return type?

> How is a constructor named?

> A program has a float variable named total and a double variable named number. Write a statement that assigns number to total without causing an error when compiled. Answer: total = (float)number;

> Assume that r1 and r2 are variables that reference Rectangle objects, and the following statements are executed: r1.setLength(5.0); r2.setLength(10.0); r1.setWidth(20.0); r2.setWidth(15.0); Fill in the boxes in Figure6-21 that represent each object&Atild

> What is a stale data item?

> What is an accessor? What is a mutator?

> What does the key word new do?

> Assume that limo is a variable that references an instance of the class shown in ­Figure6-17 . Write a statement that calls setMake and passes the argument "Cadillac".

> Look at the UML diagram in Figure6-17 and answer the following questions: 1. What is the name of the class? 2. What are the fields? 3. What are the methods? 4. What are the private members? 5. What are the public members?

> A string literal, such as "Joe", causes what type of object to be created?

> When a variable is said to reference an object, what is actually stored in the variable?

> What does an object use its fields for?

> In Java, method arguments are passed by value. What does this mean?

> Assume the double variable number contains the value 12345.6789. Write a statement that uses System.out.printf to display the number as 12,345.68.

> Look at the following method header: public static void myMethod(int num) Which of the following calls to the method will cause a compiler error? 1. myMethod(7); 2. myMethod(6.2); 3. long x = 99; myMethod(x); 4. short s = 2; myMethod(s);

> What is the difference between an argument and a parameter?

> Write a void method that displays your full name. The method should be named myName.

> What message will the following program display if the user enters 5? What if the user enters 10? What if the user enters 100? import javax.swing.JOptionPane; public class Checkpoint { public static void main(String[] args) { String input; int number; in

> Is the following line of code a method header or a method call? public static void calcTotal()

> Is the following line of code a method header or a method call? calcTotal();

> Write the header for a method named lightYears. The method should return a long and have one long parameter variable: miles.

> Write the header for a method named distance. The method should return a double and have two double parameter variables: rate and time.

> Write the header for a method named days. The method should return an int and have three int parameter variables: years, months, and weeks.

> Write the code to set up all the necessary objects for reading keyboard input. Then write code that asks the user to enter his or her desired annual income. Store the input in a double variable.

> Look at the following method header. What type of value does the method return? public static double getValue(int a, float b, String c)

> What will the following program display? public class Checkpoint { public static void main(String[] args) { int num1 = 99; double num2 = 1.5; System.out.println(num1 + " " + num2); myMethod(num1, num2); System.out.println(num1 + " " + num2); } public sta

> What is the difference between a void method and a value-returning method?

> What will the following program segments display? 1. for (int count = 0; count < 6; count++) System.out.println(count + count); 2. for (int value = −5; value < 5; value++) System.out.println(value); 3. int x; for (x = 5; x

> You want to write a for loop that displays “I love to program†50 times. Assume that you will use a control variable named count. 1. What initialization expression will you use? 2. What test expression will you use? 3. What update expression will you

> Name the three expressions that appear inside the parentheses in the for loop’s header.

> Write an input validation loop that asks the user to enter “Yes†or “Noâ€.

> Write an input validation loop that asks the user to enter ‘Y’, ‘y’, ‘N’, or ‘n’.

> Write an input validation loop that asks the user to enter a number in the range of 10 through 24.

> How many times will "I love Java programming!" be printed in the following program segment? int count = 0; while (count < 10) System.out.println("I love Java programming!);

> Match the conditional expression with the if-else statement that performs the same operation. 1. q = x < y ? a + b : x * 2 ; 2. q = x < y ? x * 2 : a + b; 3. q = x < y ? 0 : 1; if (x < y)  q = 0; else  q = 1; if (x < y)  q = a + b; else  q = x *

> Assume x is a double variable, and rand references a Random object. What does the following statement do? x = rand.nextDouble();

> Assume x is an int variable, and rand references a Random object. What does the following statement do? x = rand.nextInt(9) + 1;

> Assume x is an int variable, and rand references a Random object. What does the following statement do? x = rand.nextInt(100);

> Assume x is an int variable, and rand references a Random object. What does the following statement do? x = rand.nextInt ();

> What clause must you write in the header of a method that performs a file operation?

> You are opening an existing file for output. How do you open the file without erasing it, and at the same time make sure that new data that is written to the file is appended to the end of the file’s existing data?

> Write code that does the following: opens a file named MyName.txt, reads the first line from the file and displays it, and then closes the file.

> What classes do you use to read data from a file?

> How many times will "Hello World" be printed in the following program segment? int count = 10; while (count < 1) { System.out.println("Hello World"); count++; }

> Write code that does the following: opens a file named MyName.txt, writes your first name to the file, and then closes the file.

> Convert the following pseudocode to Java code. Be sure to declare the appropriate variables. Store 20 in the speed variable. Store 10 in the time variable. Multiply speed by time and store the result in the distance variable. Display the contents of the

> What class do you use to write data to a file?

> What import statement will you need in a program that performs file operations?

> What is the difference between an input file and an output file?

> In a controller class, the variable radio1 references a RadioButton component, and outputLabel references a Label component. Write an if statement that determines whether the RadioButton is selected. If the RadioButton is selected, display “Selectedâ€

> You created a GUI in Scene Builder and saved it to a file named MyGUI.fxml. Write a main application class that loads the FXML file, builds the scene graph, and displays the GUI.

> Rewrite the following mouse motion listener so it uses an adapter class: private class MyMouseMotionListener implements MouseMotionListener { public void mouseDragged(MouseEvent e) { } public void mouseMoved(MouseEvent e) { mouseMovements += 1; } }

> Look at the following GUI application class and indicate by line number the changes that should be made to convert this to an applet using Swing: public class SimpleWindow extends JFrame { public SimpleWindow() { // Set the title setTitle("A Simple Windo

> Write the text and HTML tags necessary to display “My Home Page” as a level one header, centered in the browser window.

> Write code that displays a file open dialog box. If the user selects a file, the code should store the file’s path and name in a String variable.

> Assume that label references an existing JLabel object. Write code that stores the image in the file picture.gif in the label.

> Write nested if statements that perform the following tests: If amount1 is greater than 10 and amount2 is less than 100, display the greater of the two.

> Write pseudocode algorithms for the program described as follows: Available Credit A program that calculates a customer’s available credit should ask the user for the following: - The customer’s maximum amount of credit - The amount of credit used by

> ConocoPhillips is an integrated energy company engaged in four core businesses: 1. petroleum exploration and production; 2. midstream natural gas processes and marketing; 3. petroleum refining, marketing, supply, and trans potation; and 4. chemical

> The U.S. Postal Service (USPS) employs roughly 700,000 workers, with a fleet of over 200,000 vehicles driven about a billion miles a year to deliver more than 206 billion pieces of mail to over 142 million delivery points. It operates one of the largest

> Company A was a very large, privately owned company with diverse business units, mostly related to the hospitality industry. The deployment champion at this company had been successful in deploying Six Sigma at a smaller organization. In his new position

> In the film The Wizard of Oz, Dorothy learned many lessons. Surprisingly, managers can learn a lot also. For each of the following summaries of scenes in the film, discuss the lessons that organizations can learn in pursuing change and a TQ culture . 1.

> Two neighbors in a new development make a wager on who will be the first to have a lush lawn. Mr. Fast N. Furious immediately buys the most expensive seed he can find because everyone knows that quality improves with price. Next, he stands knee-deep in h

> What is the balanced scorecard? Describe its four components.

> Explain the role of analytics and big data in quality management and performance excellence.

2.99

See Answer