7 java questions Solution
1) When debugging a class, you can step through the code to follow the flow of the program. There are four ways you can step through the code. Explain each option for stepping through the code of a class. 2) Compare using exception handling for input data validation with using if and switch statements. When would you use each technique? Give concrete examples. 3) Give an example of an if-else statement. Give an example of a switch-case statement. Explain when using a switch-case would be more appropriate than using an if-else and vice versa. 4) You have in your program an ArrayList that contains employee salaries (double type) in arbitrary order. You need to display the employees’ salaries ordered in descending order. Provide detailed steps how you plan to accomplish this task. You do not need to give correct Java code (a detailed pseudocode is sufficient), but indicate which method(s) and which Java class(es) you would use. 5) Suppose that you have an array of student scores (type double) called Scores. The values in the array are ordered from largest to smallest. You need to find the average score, how many scores are less or equal to the average, and how many are greater than the average. Write a code fragment to accomplish it, or at the very least, write a detailed plan (pseudocode). 6) Do we need to format our program output? Does formatting only apply to numeric values? What about percent values and currencies? Give an example that uses the NumberFormat class in the java.text package that formats numbers. 7) Classes and objects are the fundamental concepts of object-oriented programming language. What are classes and objects? Explain the relationship between a class and an object.
You'll get 1 file (24.0KB)