Halaman

Monday, July 20, 2020

Section 3 Quiz Java Programming 2019 Learner - English

Section 3
(Answer all questions in this section)

Bubble Sort is a sorting algorithm that involves swapping the smallest value into the first index, finding the next smallest value and swapping it into the next index and so on until the array is sorted.
True or false?


True


False (*)




Selection sort is efficient for large arrays.
True or false?


True


False (*)


Which of the following best describes lexicographical order?


A simple sorting algorithm that is inefficient on large arrays.


A complex sorting algorithm that is efficient on large arrays.


The order of indicies after an array has been sorted.


An order based on the ASCII value of characters. (*)



Why might a sequential search be inefficient?


It utilizes the "divide and conquer" method, which makes the algorithm more error prone.


It requires incrementing through the entire array in the worst case, which is inefficient on large data sets. (*)


It involves looping through the array multiple times before finding the value, which is inefficient on large data sets.


It is never inefficient.



An example of an upper bounded wildcard is.


ArrayList


ArrayList


ArrayList


ArrayList (*)


Which of the following would initialize a generic class "Cell" using a String type?
I. Cell cell = new Cell(); .
II. Cell cell = new Cell(); .
III. Cell cell = new String;



II and III


I and II (*)


II only


III only


I only



Examine the code below.  Which statement about this code is true?

1.class Shape {  }
2.class Circle extends Shape {  }
3.class Rectangle extends Shape { }

4.class Node {  }

5.public class Test{

6.public static void main(String[] args){

7.Node nc = new Node<>();
8.Node  ns = nc;
}
}


An error at line 7 causes compilation to fail.


An error at line 8 causes compilation to fail. (*)


The code compiles.


An error at line 4 causes compilation to fail.


The local petting zoo is writing a program to be able to collect group animals according to species to better keep track of what animals they have.
Which of the following correctly defines a collection that may create these types of groupings for each species at the zoo?


public class
animalCollection {...} (*)


public class
animalCollection(AnimalType T) {...}


public class
animalCollection {...}


public class
animalCollection(animalType) {...}


None of the these.



What is the result from the following code snippet?

interface Shape {}
class Circle implements Shape{}
class Rectangle implements Shape{}
public class Test{
 public static void main(String[] args) {
  List ls= new ArrayList();//line 1
  ls.add(new Circle());
  ls.add(new Rectangle());// line 2
  ls.add(new Integer(1));// line 3
  System.out.println(ls.size());// line 4
 }


Compilation error at line 2


Compilation error at line 4


Compilation error at line 3


Compilation error at line 1


3 (*)


Which code inserted into the code below guarantees that the program will output [1,2]?
import java.util.*;
 public class Example{
 public static void main(String[] args){
//insert code here
 set.add(2);
 set.add(1);
 System.out.println(set);
 }
 }


List set = new SortedList();


Set set = new TreeSet(); (*)


Set set = new LinkedHashSet();


Set set = new SortedSet();


Set set = new HashSet();


Choose the best definiton for a collection.


It is a special type of class that is associated with one or more non-specified Java type.


It is a subclass of List.


It enables you to create a generic class without specifying a type between angle brackets <>.


It is an interface in the java.util package that is used to define a group of objects. (*)


Stacks are identical to Queues.
True or false?


True


False (*)


A LinkedList is a type of Stack.
True or false?


True (*)


False


What are maps that link a Key to a Value?


ArrayLists


HashMaps (*)


Arrays


HashSets


Which of the following is a list of elements that have a first in last out ordering.


Stacks (*)


Arrays


Enums


HashMaps

No comments:

Post a Comment

Final Exam Java Programming 2019 Learner - English

Final Exam