The red circle Question only. Please explain the right anwser. 1. When you write
ID: 3727037 • Letter: T
Question
The red circle Question only. Please explain the right anwser.1. When you write an action listener class for a JButton component, it mus t: A) have a method named buttonClicked B) implement the ActionLIstener interface C) have a method named actionPerformed which must take an argument type D) both B and C 2. Given the following statement, which statement will write "Calvin" to the file DiskFile.txt? PrintWriter diskOut- new PrintWriter("DiskFile.txt") A) System.out.printin(diskOut, "Calvin") B) DiskFile.printin("Calvin") rintWriter.printin("Calvin"); diskOut.printin("Calvin"); 3. In a try/catch construct, after the catch statement is executed: A) the program returns to the statement following the statement in which the exception occurred B) the program terminates C) the program resumes at the statement that immediately follows the try/catch construct D) the program resumes at the first statement of the try statement 4. The compareTo method of the Comparable interface Xreturns true when the calling object is "less than" the object passed as the parameter B) returns a negative integer when the calling object is "less than" the object passed as the parameter C) returns zero when the calling object fails to equal the object passed as parameter D) None of the above 5. An array of 4 elements is being sorted in ascending order using the insertion sort algorithm. Hox y comparisons will insertion sort perform if the array was originally sorted in descending order án A) 2 comparisons comparisons comparisons D) None of the above
Explanation / Answer
Ques 2. Answer : (d)
The println() function of the PrintWriter class writes the content to the file. We can invoke the function using the object of the PrintWriter class.
SO, total no of comparisons = 3 + 2 + 1 = 6
Ques 4. Answer : (b)
It returns
Ques 5. (c) 6
First there would be 3 comparisons, then there would be 2 comparisons, then 1 comparison. Then the array would be sorted.
Ques 8. Answer : (C) 0
When we try to convert String to Integer, a NumberFormtException is thrown, so the first catch block is executed. Hence, the value of number is set to 0.
Ques 19. Answer : (C)
Listener are the classes which respong to any event like when a key is pressed or mouse is moved or any other event.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.