2.99 See Answer

Question: What import statement do you write in


What import statement do you write in a program that uses the JOptionPane class?


> Modify the statement you wrote in response to Checkpoint3.20 so it performs a case-insensitive comparison. Data from Checkpoint 3.20: Assume the variable name references a String object. Write an if statement that displays “Do I know you?†if the Str

> Assume the variables name1 and name2 reference two different String objects, containing different strings. Write code that displays the strings referenced by these variables in alphabetical order.

> Assume the variable name references a String object. Write an if statement that displays “Do I know you?†if the String object contains “Timothyâ€.

> Write a statement, after the following code, that creates an HBox container, adds the label1, label2, and label3 controls to it, and has 10 pixels of spacing between the controls. Label label1 = new Label("One"); Label label2 = new Label("Two"); Label la

> Write an if statement that multiplies payRate by 1.5 if hours is greater than 40.

> Write an if statement that displays the message "The number is not valid" if the variable speed is outside the range 0 through 200.

> Write an if statement that displays the message "The number is valid" if the variable speed is within the range 0 through 200.

> Assume the variables a = 2, b = 4, and c = 6. Circle the T or F for each of the ­following conditions to indicate whether it is true or false.

> The following truth table shows various combinations of the values true and false connected by a logical operator. Complete the table by circling T or F to indicate whether the result of such a combination is true or false.

> The following program is used in a bookstore to determine how many discount ­coupons a customer gets. Complete the table that appears after the program. import javax.swing.JOptionPane; public class CheckPoint { public static void main(String[] args) { i

> What will the following program display? public class CheckPoint { public static void main(String[] args) { int funny = 7, serious = 15; funny = serious % 2; if (funny != 1) { funny = 0; serious = 0; } else if (funny == 2) { funny = 10; serious = 10; } E

> Write code that tests the variable x to determine whether it is greater than 0. If x is greater than 0, the code should test the variable y to determine whether it is less than 20. If y is less than 20, the code should assign 1 to the variable z. If y is

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

> Write an if-else statement that assigns 0 to the variable b and assigns 1 to the variable c if the variable a is less than 10. Otherwise, it should assign −99 to the variable b and assign 0 to the variable c.

> Assume your JavaFX application is in the same directory as an image file named Cat.png. Write the code to create the Image and ImageView objects you will need to display the image.

> Write an if-else statement that assigns 0.10 to commission unless sales is greater than or equal to 50000.0, in which case it assigns 0.2 to commission.

> Write an if statement that assigns 0 to x when y is equal to 20.

> On paper, write a program that will display your name on the first line; your street address on the second line; your city, state, and ZIP code on the third line; and your telephone number on the fourth line. Place a comment with today’s date at the to

> Study the following program and show what it will print on the screen. // The Works of Wolfgang public class Wolfgang { public static void main(String[] args) { System.out.print("The works of Wolfgang\ninclude "); System.out.print("the following"); Syste

> The following program will not compile because the lines have been mixed up. System.out.print("Success\n"); } public class Success { System.out.print("Success\n"); public static void main(String[] args) System.out.print("Success "); } // It's a mad, mad

> Every Java application program must have ___. a. a method named main b. more than one class definition c. one or more comments

> All Java source code filenames must end with ____. a. a semicolon b. .class c. .java d. none of the above

> On paper, write a program that will display your name on the screen. Place a ­comment with today’s date at the top of the program. Test your program by ­entering, compiling, and running it.

> Complete the following program skeleton so it displays the message “Hello World†on the screen. public class Hello { public static void main(String[] args) { // Insert code here to complete the program } }

> Assume that stringLength is an int variable. Write a statement that stores the length of the string referenced by the city variable in stringLength.

> Assume primaryStage references the Stage object, and scene references your Scene object. Write a statement that adds the scene to the stage.

> Write a statement that declares a String variable named city. The variable should be initialized so it references an object with the string “San Franciscoâ€.

> The variable a is a float and the variable b is a double. Write a statement that will assign the value of b to a without causing an error when the program is compiled.

> The following declaration appears in a program: short totalPay, basePay = 500, bonus = 1000; The following statement appears in the same program: totalPay = basePay + bonus; 1. Will the statement compile properly or cause an error? 2. If the statement ca

> Write statements using combined assignment operators to perform the following: 1. Add 6 to x 2. Subtract 4 from amount 3. Multiply y by 4 4. Divide total by 27 5. Store in x the remainder of x divided by 7

> Is the division statement in the following code an example of integer division or floating-point division? What value will be stored in portion? double portion; portion = 70 / 3;

> Complete the following table by writing the value of each expression in the Value column.

> What is wrong with the following statement? char letter = "Z";

> Which is a character literal, 'B' or "B"?

> When the program is saved to a file, what should the file be named?

> What are the Unicode codes for the characters ‘C’, ‘F’, and ‘W’?

> In question 11, you wrote the code for an event handler class, and in question 12, you wrote the code to register an instance of that class with the myButton control. Rewrite the code as a lambda expression.

> Write statements that do the following: 1. Declare a char variable named letter. 2. Assign the letter A to the letter variable. 3. Display the contents of the letter variable.

> What values can boolean variables hold?

> A program declares a float variable named number, and the following statement causes an error. What can be done to fix the error? number = 7.4;

> How would the number 6.31×1017 be represented in E notation?

> Refer to the Java primitive data types for this question. 1. If a variable needs to hold whole numbers in the range 32 to 6,000, what primitive data type would be best? 2. If a variable needs to hold whole numbers in the range −40,000 to +40,000, what

> Is the variable name Sales the same as sales? Why or why not?

> Which of the following are illegal variable names and why? x 99bottles july97 theSalesFigureForFiscalYear98 r&d grade_report

> What will the following program display on the screen? public class CheckPoint { public static void main(String[] args) { int number; number = 712; System.out.println("The value is " + "number"); } }

> Examine the following program. // This program uses variables and literals. public class BigLittle { public static void main(String[] args) { int little; int big; little = 2; big = 2000; System.out.println("The little number is " + little); System.out.pr

> The following program will not compile because the lines have been mixed up. public static void main(String[] args) } // A crazy mixed up program public class Columbus { System.out.println("In 1492 Columbus sailed the ocean blue."); } } When the lines ar

> Assume a JavaFX application has a Button control named myButton, and a Label control named outputLabel. Write an event handler class that can be used with the Button control. The event handler class should display the string “Hello World†in outputLab

> Write an if statement that assigns 100 to x when y is equal to 0.

> Write code that displays an input dialog asking the user to enter his or her age. Convert the input value to an int and store it in an int variable named age.

> Write code that will display each of the dialog boxes shown in Figure2-19.

> What is the purpose of the following types of dialog boxes? Message dialog Input dialog

> How are documentation comments different from other types of comments?

> How do you write a single line comment? How do you write a multi-line comment? How do you write a documentation comment?

> Assume that lowerCity is a String reference variable. Write a statement that stores the lowercase equivalent of the string referenced by the city variable in lowerCity.

> Assume that upperCity is a String reference variable. Write a statement that stores the uppercase equivalent of the string referenced by the city variable in upperCity.

> Assume that oneChar is a char variable. Write a statement that stores the first character in the string referenced by the city variable in oneChar.

> What is data hiding?

> Write a statement, after the following code, that creates an HBox container, and adds the label1, label2, and label3 controls to it: Label label1 = new Label("One"); Label label2 = new Label("Two"); Label label3 = new Label("Three");

> What is encapsulation?

> What are an object’s methods?

> What are an object’s attributes?

> In procedural programming, what two parts of a program are typically separated?

> What is the purpose of testing a program with sample data or input?

> Is a syntax error (such as misspelling a key word) found by the compiler or when the program is running?

> What is a runtime error?

> Describe what a compiler does with a program’s source code.

> What is pseudocode?

> What does it mean to “visualize a program running� What is the value of such an activity?

> Write a statement that creates an object that can be used to write binary data to the file Configuration.dat.

> What four items should you identify when defining what a program is to do?

> What is the JVM?

> What is byte code?

> What is a syntax error?

> What is a compiler?

> What happens to a variable’s current contents when a new value is stored there?

> Why are variables called “variable�

> Describe the difference between a program line and a statement.

> Describe the difference between operators and punctuation symbols.

> Describe the difference between a key word and a programmer-defined symbol.

> The method getValueFromFile is public and returns an int. It accepts no arguments. The method is capable of throwing an IOException and a FileNotFoundException. Write the header for this method.

> What type of file does Scene Builder save a GUI to?

> What is FXML?

> What type of scene graph node can have children? What type cannot?

> What are the three types of nodes in a scene graph?

> What is a scene graph?

> What is an event? What is an event listener?

> What is a component?

> What method do you call to change an ImageView’s image?

> What ImageView property do you set in the Inspector panel to display an image?

> Do you normally add RadioButtons or CheckBoxes to a toggle group?

> Write an exception class that can be thrown when a negative number is passed to a method.

> What is the purpose of a toggle group?

> You want the user to be able to select any number of items from a group of items. Which type of component would you use for the items, RadioButtons or CheckBoxes?

> You want the user to be able to select only one item from a group of items. Which type of component would you use for the items, RadioButtons or CheckBoxes?

> What is JavaFX?

> How do you register an event listener to a component in Scene Builder?

> How do you register a controller class to an application’s GUI in Scene Builder?

> What is an event listener?

> What is the controller class?

2.99

See Answer