COMP-274 Week 1 Homework Assignment

1. What is the Java source filename extension? What is the Java bytecode filename extension
Java source filename extension is “.java”. The Java bytecode filename extension is “.class”.2. Write a Java statement to display the string “The value is 100” to a user in a plain dialog box.JOptionPane.showMessageDialog(null, “The value is 100”);3. What is the command you would use to compile the file Addition.java
javac Addition.java4. What is the command you would use to execute the Addition class
java Addition5. What does a Java class contain that identifies it as a Java application
A Java class contains a main method to make it a complete application. public static void main (String[] args)6. Write a Java statement that declares a constant called MAX which has a value of 1000. final int MAX = 1000;7. How do C++ chars differ from Java chars
In C++ char is an integer type that is 8 bits and uses the ASCII character set. In Java char is 16 bits and uses the Unicode character set.8. Given a double variable called dval, write a single Java statement to prompt the user to enter the price of an item using JOptionPanes, convert the result and store it into dval. double dval = double.parse.Double(JoptionPane.showlnputDialog(“Enter price of item”));9. Write one Java statement to display the string “The average is xxx” to the console, where the xxx displays the value from the double variable sum divided by 3. Make sure the value is displayed with 3 digits following the decimal point. System.out.printf(“The average is %3.6f”,(sum/3));10. Write one Java statement to create a string containing “The average is xxx” where the xxx contains the formatted value from the double variable sum divided by 3. Make sure the formatted string contains only 2 digits following the decimal point. Store the formatted string into a String variable called str.DecimalFormat format=new DecimalFormat(“#0.00”);…