Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive / Question 1 (1 point) Event listeners are often installed as ____ classes so that they can have access to the surrounding fields, methods, and final variables

Question 1 (1 point) Event listeners are often installed as ____ classes so that they can have access to the surrounding fields, methods, and final variables

Computer Science

Question 1 (1 point)

Event listeners are often installed as ____ classes so that they can have access to the surrounding fields, methods, and final variables.

O interface

O helper

O inner

O abstract

Question 2 (1 point) The ArrayList class implements the ____ interface.

O Stack O Queue O List O Set

Question 3 (1 point) which of the following statements about checked and unchecked exceptions is true?

O Checked exceptions are handled by the Java runtime.

O The compiler ensures that the program is handling unchecked exceptions.

O The compiler ensures that the program is handling checked exceptions.

O All exceptions that are descendants of RunTimeException are checked ----1 exceptions.

Question 4 (1 point)

Interfaces offer a capability requiring that unrelated classes implement a set of common methods. They define and standardize the way in which things can interact with one another.

O True O False

Question 5 (2 points) Consider the code snippet shown below. Assume that nurseldentities is an instance of type LinkedList<String>.  For (String name: nurseldentities) {II Do something with identities at this place which element(s) of nurseldentities does this loop process?

O elements meeting a condition

O the most recently added elements

O no elements

O all elements

Question 6 (1 point)

Which nodes need to be updated when we insert a new node to become the fourth node from the beginning of a doubly-linked list?

0 The current third and fourth nodes. 0 The current fourth and fifth nodes. 0 The current first node. 0 The current third node.

Question 7 (1 point)

The Lambda expression can stand alone and must be assigned to a variable whose type is a functional interface.

0 True O False

Question 8 (1 point) To build a user interface that contains graphical components, the components ____:

0 must each be added to a separate panel. O must be added directly to a frame component. O must be added to a panel that is contained within a frame. O must be added to a frame that is contained within a panel.

Question 9 (2 points) Consider the following code snippet:

LinkedList<String> words = new LinkedList<>0; words.addLast("abc"); words.addLast("def"); words.addLast("ghi"); System.out.print(words.removeLastQ); System.out.print(words.removeFirst()); System.out.print(words.removeLastQ);

What will this code print when it is executed? 0 a bcdefghi 0 defghiabc 0 ghiabcdef 0 abcghidef

Question 10 (2 points) Consider the following code component:

Nurse a Nurse = new Hourly Nurse (); aNurse.increaseSalary (2500);

If the Hourly Nurse class inherits from the Nurse class, and only the Nurse class has an implementation of the increase Salary method, which statement is correct?

0 The increase Salary method call will cause a run-time error. 0 The increase Salary method of the Nurse class will be executed. 0 The Hourly Nurse class is required to provide an implementation of the increase Salary method. 0 Hourly Nurse objects must be cast to Nurse Objects before the method call can me made.

Question 11 (1 point)

To associate an event listener with a JButton component, which method of the JButton class must you use?

O addActionListener

O addButtonListener O addListener O addEventListener

Question 12 (1 point)

An interface declaration begins with the keyword interface and contains only abstract methods and no constants.

0 True O False

Question 13 (1 point) How do you specify what the program should do when the user clicks a button?

Which of the following statements about a priority queue structure is NOT correct?

0 The insert method is used to add a new element to the priority queue. 0 The remove method is used to remove an element from the priority queue. n Elements added to a priority queue must belong to a class that implements the '--1 Comparable interface.

0 New elements can be inserted in any order.

Question 15 (1 point)

Which of the following is an example of a functional interface, having a single abstract method?

0 ActionListener 0 KeyListener 0 MouseListener 0 MouseAdapter

Question 16 (1 point)

When using a list iterator, on which condition will the IllegalStateException be thrown?

0 Calling remove after calling next.

Calling remove after calling add. 0 Calling add after calling previous. 0 Calling previous after calling previous.

n Specify the actions to take in a class that implements the Button Listener ' interface. n Specify the actions to take in a class that implements the Event Listener ' interface.

O Specify the actions to take in a class that implements the Button Event interface. n Specify the actions to take in a class that implements the Action Listener ' interface

Question 17 (1 point)

Which method of an exception object will retrieve a description of the exception that occurred?

0 printStackTrace() 0 printMessage() 0 getDescription() 0 getMessage()

Question 18 (1 point) which statement about handling exceptions is true?

0 If an exception has no handler, the program will be terminated. 0 If an exception has no handler, the error will be ignored. 0 Statements to handle exceptions should be placed inside a try clause. 0 Statements that may cause exceptions should be placed inside a catch clause.

Question 19 (1 point) When writing a method, which of the following statements about exception handling is true?

OThe throws clause must list all checked exceptions that this method may throw,  and may also list unchecked exceptions. OThe throws clause must list all checked exceptions, but cannot list unchecked  exceptions. OThe throws clause must list all unchecked exceptions, and cannot list checked  exceptions. OThe throws clause must list all unchecked exceptions, and may also list checked  exceptions that this method may throw.

Question 20 (1 point)

Which of the following statements about checked and unchecked exceptions is NOT true?

0 Handling of checked exceptions is enforced by the compiler. 0 Unchecked exceptions are the programmer's fault. n Unchecked exceptions belonging to subclasses of the RunTimeException class ' are beyond the control of the programmer. n Internal errors belonging to subclasses of the Error class are beyond the control ' of the programmer.

Question 21 (1 point)

Polymorphism helps in simplfying programming. This is because it enables the programmer to write programs that process objects which share different superclasses as if they were all objects of the same superclass.

0 True 0 False

Question 22 (1 point) Which of the following statements about the try/finally statement is NOT true?

0 The finally clause is executed if the body of the try completes without exception. 0 The finally clause is executed if the body of the try throws exception. 0 The finally clause is executed after the exception is propagated to its handler. rTh The finally clause typically represents cleanup code that is to be executed ' whether or not an exception occurs.

Question 23 (2 points) Assuming that names is a Queue of String objects, select a statement to complete the code segment below. The code is designed to remove the last element from the queue, which is guaranteed to have at least one element:

Queue<String> aQueue = new LinkedList<>(); while (names.size() > 1) C aQueue.add(names.removeQ); ) names.removeQ; while (aQueue.size() > 0) C

1 O aQueue.add(names.peek()); O aQueue.add(names.removeQ); O names.add(aQueue.peek()); O names.add(aQueue.remove())

Question 24 (1 point) The Java compiler requires that your program handle which type of exceptions?

O severe O fatal O checked O unchecked

Question 25 (1 point) What is the purpose of the throw statement?

0 It is used to pass control to an error handler when an error situation is detected. O It is used to discard erroneous input. 0 It is used to detect an error situation. 0 It is used to pass arguments to another method.

Question 26 (1 point) Assume that you have declared a queue named myQueue to hold String elements. Which of the following statements will correctly delete an element from myQueue?

O mYQueue.delete(); 0 mYQueue.remove(); 0 mYQueue.get(); 0 mYQueue.pop();

Question 27 (1. point)

Which of the following statements about exception handling is correct?

O Statements that may cause an exception should be placed within a catch block.

O Statements that may cause an exception should be placed within a try block.

O The main method of a Java program will handle any error encountered in the program.

O Statements that may cause an exception should be placed within a throws block.

Question 28 (1 point) You need to access values in objects by a key that is not part of the object. Which collection type should you use?

0 Hashtable

0 ArrayList

0 Map

0 Queue

Question 29 (1 point)

Which of the following statements about assertions is NOT true?

0 An assertion is always checked during program execution. O If an executed assertion fails, then the assert statement throws an Assertion Error exception. Q Assertion checking is particularly useful during program development and testing. Q An assertion checks that a condition is true in a particular program location.

Question 30 (2 points) Consider the following code snippet:  public class Auto extends Vehicle public Auto(int numberTyres)

super(numberTyres):  What does this code do?

It invokes the constructor of the Vehicle class from within the constructor of the Auto class.

("D It invokes the constructor of the Auto class from within the constructor of the Vehicle class.

Q It invokes a private method of the Vehicle class from within a method of the Auto class.  This code will not compile.

Question 31 (1 point)

In which condition will the Scanner constructor generate a FileNotFoundException?

O If the input file already exists, but is empty. ("D If the input file does not exist. O If any I/O error occurs while opening the file. O If the input file already exists, but has data in it.

Question 32 (2 points) Review the following code snippet: throw new IllegalArgumentException("This operation is not allowed!"); Which of the following statements about this code is correct?

("D This code throws an existing Illegal Argument Exception object.

O This code will not compile.

This code constructs an object of type Illegal Argument Exception and throws the object.

(0 This code constructs an object of type Illegal Argument Exception and reserves it for future use.

Question 33 (1 point)

Which class in the javax.swing package generates a sequence of events, spaced apart at even time intervals?

O Clock 0 Time Clock 0 Timer • Stopwatch

Question 34 (2 points) Assuming that the Click Listener class implements the Action Listener interface, what statement should be used to complete the following code segment?

Click Listener listener = new Click Listener (); JButton myButton = new JButton("Submit"); JPanel myPanel = new JPanel(); myPanel.add(myButton);  //missing statement

• myButton.addActionListener(listener); • myPancl.addActionListcner(myButton): • myPancl.addActionListener(listener); O myButton.addActionListener(ClickListener);

Question 35 (1 point)

If a subclass defines the same method name and the same parameter types for a method that appears in its superclass, which statement is true?

O the subclass method overloads the superclass method. O the subclass method overrides the superclass method. O the subclass has implemented the method on behalf of the superclass. 0 a compiler error will occur.

Question 36 (2 points) suppose the abstract class Message is defined below public abstract class Message private String value: public Message (String initial) value = initial:  public String getMessage() return value:  public abstract String translate():

A concrete subclass of Message, called Spanish Message, is defined. Which methods must Spanish Message define? Q translate () only 0 getMessage() only Q The Spanish Message constructor and translate() only Q The Spanish Message constructor, getMessage(), and translate()

Question 37 (1 point) Select an expression to complete the program segment below, which displays an error message and terminates normally if the String variable accountNumber does not contain an integer value. try { int number = Integer.parseInt(accountNumber); catch (  { System.out.println("Account number is not an integer value"):

O Number Format Exception exception O Input Mismatch Exception exception O Arithmetic Exception exception O Exception exception

Question 38 (1 point) which of the following statements about exception handling is recommended? Throw an exception as soon as a problem is detected, but only catch exceptions when the problem can be handled. 0 All exceptions should be handled at the top of the chain of methods. 0 All exceptions should be handled where they are first detected. 0 Throw an exception only when the problem can be handled.

You need to write a program to simulate the effect of adding an additional cashier in a supermarket to reduce the length of time customers must wait to check out. Which data structure would be most appropriate to simulate the waiting customers?

O map O stack O linked list O queue

Question 40 (1 point)

Assume you have created a linked list named myList that currently holds some number of String objects. Which of the following statements correctly adds a new element to the beginning of myList?

• myList.insert("Harry"); • myList.addFirst("Harry"); • myList.add("Harry"); • myList.put("Harry");

Question 41 (1 point) When a program throws an exception within a method that has no try-catch block, which of the following statements about exception handling is true?

0 The user must decide whether to continue or terminate the program. 0 The current method must decide whether to continue or terminate. 0 The current method terminates immediately. 0 Execution will continue with the next statement in the method.

Question 42 (1 point)

Which method is NOT part of the Listlterator interface?

O delete O add O previous

Question 43 (1 point)

The methods of an describe the actions to be taken when an event occurs.

O event source O event interface Q action source Q event listener

Question 44 (2 points) Consider the following code segment: public static void main(Stringn args) throws File Not Found Exception Which of the following statements about this code is correct?

0 The main method is designed to catch and handle all types of exceptions. 0 The main method will not terminate if any exception occurs. 0 The main method is designed to catch and handle the File Not Found Exception. The main method terminates if the File Not Found Exception occurs.

Question 45 (1 point) Which of the following code statements creates a graphical button that has "Calculate" as its label?

Q JButton button = new JButtoralabel("Calculate");

0 JButton button = new JButton().add("Calculate"); 0 JButton button = new JButton("Calculate"); 0 Button button = new Button("Calculate");

Question 46 (1 point) To ensure that an instance variable can only be accessed by the class that declared it, how should the variable be declared?

O public 0 private 0 protected 0 final

Question 47 (2 points) Complete the code fragment below, which is designed to throw an exception if String variable accountNumber has more than nine characters.

if (accountNumber.length() > 9) {

)

0 throws new IllegalArgumentException("Account number exceeds maximum length");

Q throw new Illegal Argument Exception("Account number exceeds maximum length"); Q throws Illegal Argument Exception("Account number exceeds maximum length"); Q throw Illegal Argument Exception("Account number exceeds maximum length");

Question 48 (1 point) What is recommended if the standard library does not have an exception class that describes your particular error situation?

0 Design your own exception class as a subclass of an existing exception class. O Choose Run Time Exception from the standard library because it is unchecked and '1 represents a generic exception. 0 Design your own exception class by implementing the Throw able interface. 0 Design your own exception class as a superclass of an existing exception class.

Question 49 (1 point)

A collection that allows speedy insertion and removal of already-located elements in the middle of it is called a:

O linked list

O stack

O set

O queue

Question 50 (1 point)

What is the preferred way to implement event listeners?

O) Use interfaces as event listeners.

O) Use inner classes as event listeners.

O) Use methods as event listeners.

O) Use containers as event listeners.

Option 1

Low Cost Option
Download this past answer in few clicks

9.99 USD

PURCHASE SOLUTION

Already member?


Option 2

Custom new solution created by our subject matter experts

GET A QUOTE

Related Questions