Starting from:

$45

CS5044-Final Quiz Part C Solved

 

Question 1  The access specifier in the declaration of instance variables should almost always be __________ .

protected

private

static

public

Question 2  When a button component is pushed then released in a GUI application, what kind of event is generated by the button?

ChangeEvent

MouseEvent

ActionEvent

ItemEvent

Question 3  Which of the following operations is least efficient in a Java LinkedList?

Adding an element in a position that has already been located

Locating the position of an element within the list

Removing an element when the element's position has already been located

Adding an element at the beginning of the list

Question  4

 Which of these Java collection classes allow you to specify their generics? I. HashMap II. LinkedList III. ArrayList

I and II only

II and III only

I, II and III

I and III only

Question 5 Consider the following code: String myString = "Hello"; String yourString = myString;string) yourString = yourString.toLowerCase(); What is the value of myString after this code finishes?

"hello"

null

"Hello"

"" (an empty

 Question 6 0 n / 2 2n n In an ArrayList of size n, what is the worst-case-scenario maximum number of elements that need to be moved when a new element is inserted into some position within the list? Question 7  false true In Java, it is most widely considered a best practice is to declare all of your local variables at the beginning of your method, rather than where they are first needed. Question 8   reduce() count() distinct() average() Which of the following is NOT a terminal operation of a Stream pipeline? Question 9 \pts Static types Constant types Primitive types Numeric types There are exactly eight of these types in Java; all other types are reference types. Question 10 s Cyclomatic complexity Problem coverage Code coverage Test correctness Which metric tells you the percentage of lines and/or branches that were exercised by running your tests against your own code. Question 11  An interface cannot have constants whereas an abstract class can. An interface cannot have instance variables whereas an abstract class can. An interface cannot be instantiated whereas an abstract class can. An interface can specify static methods whereas an abstract class cannot. Which of the following is true about interfaces and abstract classes? Question 12  AbstractList list = new ArrayList<(); List list = new ArrayList(); List list = new ArrayList<(); ArrayList list = new ArrayList(); All of the following declarations compile, but which one is generally considered the best and most common form to use? Question 13  myMap.put(3, "apple"); Assume that you have declared a map named myMap to hold String values associated with Integer keys. Which of the following statements will correctly add an association to myMap?  myMap.add(3, "apple"); myMap[3] = "apple"; myMap.push(3, "apple"); Question 14  non-static method type parameter local variable instance variable Another name for a non-static field of a class is: Question 15  static type immutable type enumeration type mutable type Which special type in Java allows a programmer to define a finite number of uniquelynamed values? Question 16  true false If we declare an array variable as final, it means that the contents of the array cannot change. Question 17  .limit(s.getGpa() = 3.8) .filter(getGpa() = 3.8) .filter(s - s.getGpa() = 3.8) .map(s - s.getGpa() = 3.8) Complete the following code snippet that returns a stream of Student objects, representing students who have a grade point average (GPA) of at least 3.8. Assume that studentStream is a stream of all Student objects, and that the getGpa() method returns a double representing the student's GPA. Stream highHonors = studentStream____________________; Question 18  anonymous inner class aggregate operation A(n) __________ declares exactly one abstract method. It may be implemented using classic techniques or lambda expressions.  method reference functional interface Question 19  A superclass is extended by a subclass. A superclass inherits from a subclass. A superclass is larger than its subclass. A superclass extends a subclass. Which of the following statements about superclasses and subclasses is true? Question 20 There is an error in this line of code. int Object Given the following declaration: public class MyClass { private final int value; public MyClass(int i) { value = i; } // . . . more fields and methods . . . } Consider the following line of code that calls the constructor above: MyClass obj = new MyClass(5044); what is the generic type parameter T in this line of code? 12/14/2019 

More products