1. (TCO 1) The javac command produces a file which(Points : 6)
2. (TCO 1) The JVM executes a Java application by(Points : 6)
3. (TCO 1) Which method call converts the value in variable stringVariable to a double?(Points : 6)
4. (TCO 1) What output does the following code generate?
int a = 10;
double d = 123.456;
String s = “Hi there!”;
System.out.printf(“%s %d %.2f”, s, a, d);(Points : 6)
int a = 10;
double d = 123.456;
String s = “Hi there!”;
System.out.printf(“%s %d %.2f”, s, a, d);(Points : 6)
5. (TCO 1) Which of the following gets a double value from the user?(Points : 6)
6. (TCO 1) When a Java method is passed an array as a parameter, how does the method know how many elements the array has?(Points : 6)
7. (TCO 2) Non-static methods of a class(Points : 6)
8. (TCO 2) What is a primary difference between inheritance in Java and inheritance in C++?(Points : 6)
9. (TCO 3) How would you set the layout of a JFrame to create 64 equal sized areas arranged like a chess board?(Points : 6)
10. (TCO 3) One way to display a set of three JButtons horizontally arranged on the top of the display is to add the buttons to a JPanel with(Points : 6)
11. (TCO 3) Given a JFrame object named frame with a default layout manager, what would the display look like given the following code?
frame.add(button1, BorderLayout.NORTH);
frame.add(button2, BorderLayout.NORTH);(Points : 6)
frame.add(button1, BorderLayout.NORTH);
frame.add(button2, BorderLayout.NORTH);(Points : 6)
12. (TCO 4) To handle the event generated by typing the enter key in a JTextField, you would need to (Points : 6)
13. (TCO 4) What can you say about the following Java class definition?
public class MyClass extends JFrame
{
…….
private class RadioButtonHandler implements ItemListener { … }
}(Points : 6)
public class MyClass extends JFrame
{
…….
private class RadioButtonHandler implements ItemListener { … }
}(Points : 6)
14. (TCO 3) Which of the following is true for a JLabel?(Points : 6)
15. (TCO 3) A JTextArea(Points : 6)
1. (TCO 4) In order to handle an event from a JLabel object label1, what does a programmer need to do?(Points : 6)
2. (TCO 5) To draw a single line from (0, 15) to (20, 25), call the method _________ of the Graphics class in the paintComponent method or in the paint method.(Points : 6)
3. (TCO 5) In Java graphics, the coordinates 20, 40 are located(Points : 6)
4. (TCO 5) Which of the following sets the Font to SanSerif, size 14, and bold? Assume g is an object of the Graphics class.(Points : 6)
5. (TCO 5) A Java Timer object generates events which are handled by an object which implements(Points : 6)
6. (TCO 5) If you are just interested in handling events when a key is typed, the easiest implementation is to(Points : 6)
7. (TCO 6) Where does code need to be to handle a specific exception type?(Points : 6)
8. (TCO 6) Which of the following statements is false?(Points : 6)
9. (TCO 6) The purpose of the try block is to(Points : 6)
10. (TCO 7) Which of the following creates a data stream for reading bytes from a file?(Points : 6)
11. (TCO 7) What is the purpose of a BufferedOutputStream?(Points : 6)
12. (TCO 7) Which of the following classes are serializable?(Points : 6)
13. (TCO 8) Javadoc comments are(Points : 6)
14. (TCO 8) The @param and @return tags are commonly used at what Javadoc documentation level?(Points : 6)
15. (TCO 8) What command is used to bundle a group of related class files and other resources together into a single file?(Points : 6)
Question 16)(TCO 1) Write a simple Java application which calculates the RC time constant in a simple RC circuit. Your application should ask the user to enter the capacitor and resistor values of the circuit. You must use the JOptionPane class to collect the user's input. The capacitor and resistor values should be treated as floating point values. Calculate the time constant in seconds: tc = capacitor (in farads) * resistor (in ohms). You must use the JOptionPane class to output the result. Your output must show four digits after the decimal point and contain explanatory text. Make sure you remember to import what your program will use.(Points : 40)
Question 17 .(TCO 3, 4) Assume the existence of the following Java GUI application. There are two text fields for user input. The first JTextField variable is named res1 and is used to input a resistance value in ohms. The second JTextField variable named tol is used to input a tolerance percentage. All input values and calculations use integer values. The tolerance value is entered as an integer percentage between 1 and 100. The user clicks a JButton to perform a calculation. One JButton called min causes the program to calculate and display the minimum value of the resistor, Rmin = R - R * tolerance. Another JButton called max causes the program to calculate the maximum value of the resistor, Rmax = R + R * tolerance. The result of the selected calculation is displayed in an output text area variable named output. The output string should say something like this: "The max resistance value of a 100 ohm resistor with a 10 percent tolerance is 110 ohms". Clicking one of the buttons generates the event which causes the program to do the selected calculation and update the output area. Assume the user interface has already been implemented and the member variables listed above exist. Your job is to write the ButtonHandler inner class which handles the events from the two buttons, does the requested calculation and displays the appropriate result.(Points : 60)

Комментариев нет:
Отправить комментарий