4. What output does the following code generate? int a = 10; double d = 123.456;
ID: 3538272 • Letter: 4
Question
4. What output does the following code generate?
int a = 10;
double d = 123.456;
String s = %u201CHi there!%u201D;
String res = String.format(%u201C%s %d %.2f %u201D, s, a, d);
System.out.print(res); (Points : 6)
A.Hi there! 10 123.46
B.%s %d %.2f Hi there! 10 123.456
C.s a d
D.None of the above.
5. Which of the following gets a double value from the user?
A.double x = JOptionPane.getDouble(%u201CEnter a double value%u201D);
B.double x = Double.parseDouble(JOptionPane.showInputDialog(%u201CEnter a double value%u201D));
C.double x = Scanner.getNextDouble(%u201CEnter a double value%u201D);
D.double x = String.toDouble(JOptionPane.showMessageDialog(%u201CEnter a double value%u201D));
6.When a Java method is passed an array as a parameter, how does the method know how many elements the array has?
A. The method can use the length member of the array object to find out the number of elements.
B.The size of the array must be passed as a separate parameter to the method.
C.The method can simply ask the user for the size of the array.
D. The method has no way of knowing since it did not create the array.
7. When is the memory space for dynamically allocated objects reclaimed by the JVM?
A.When there are no references to the object left in the program.
B.When the programmer deletes the object.
C.When the object tells the JVM its time to die.
D.When the program is finished, all dynamically allocated objects are reclaimed.
8. How does a Java method which overrides a base class method access the base class version of the method from the derived class version of the method?
A.Use the base class name, the dot operator, and the method name.
B.The derived class version is not allowed to access the base class version.
C.Copy the base class code into the derived class version of the method.
D. Use the super keyword, the dot operator, and the method name
12. (TCO 4) In order to implement the ActionListener interface, what do you need to import?
A.java.events.ActionListener
B.javax.GUI.events
C.java.event.ActionListener
D.java.awt.event
15. Which of the following adds scrolling ability to a multiline display?
A.JLabel display = new JLabel(%u201CEnter text%u201D);
B.JTextField display = new JTextField(%u201CEnter text%u201D);
C.JTextArea display = new JTextArea(20, 20);
D.JScrollPane display = new JScrollPane(textArea);
Explanation / Answer
4) A
5) B
6) A
7) A
12) D
15) C
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.