Question

In: Computer Science

Is List type is an interface in the Java collections framework? Classes Vector, ArrayList, and LinkedList...

  1. Is List type is an interface in the Java collections framework?
  2. Classes Vector, ArrayList, and LinkedList are the same data structure but implement data storage in different ways.
  3. Classes, that implement Map interface in Java collections framework are used for storing what type of data?
  4. Declare and instantiate a list of elements of type String. Name this list myArray.
  5. what type of data structure is Stack?
  6. LinkedList data structure in Java collections is implemented as doubly linked lists.
  7. In PriorityQueue data structure how are the elements placed at the front of the queue?
  8. What type of data structure is a set?

Solutions

Expert Solution

Ans1

  • Yes List type is an interface in java Collection Framework
  • List is a child iterface of collection
  • if we want to represent a group of individual object as a sing entity where duplicte are allowed and inserrtion order must be preserve the we go for List interface

Ans 2:

  • MAp is not a child interface of collection
  • If we want ot repreent a group of object as key value pairs then we should go for map interface
  • Duplicate keys are not allowed but we can store duplicate values.
  • the child iterface of map consist of Hashmap,IdentityHashmap,SotedMap.

Ans 3:

Declare and instantiate a list of elements of type String

we can declare list using mainly 3 classes because this 3 classes has implemented list interface.This 3 classes are ArrayList,LinkedList,Stack.There are other classes also which implemented List interface.

Hence lets initialise List interface using this 3 classes

Example:

  1. List<String> myArray=new ArrayList<String>();
  2. List<String> myArray=new LinkedList<String>();
    
  3. List<String> myArray=new Stack<String>();
    

what type of data structure is Stack?

ans: Stack is a Linear Data Structure in which order of data can be LIFO(Last In First Out) or FILO(First In Last Out)

Ans 4:

  • Yes Likedlist in java collection framework has doubly Linkedlist data structure implemented
  • If our frequent operation is insertion and deletion then linkedlist is best choice

Ans 5:

  • we can use priority quee to represent a group of individual object prior to processing according to some priority
  • the priority order can be either default natural sorting order or customized sorting order
  • if we are depending on default sorting order then object must be homogeneouus(same) or compaable otherwise we will get classcatexception
  • Duplicate objects are not allowed
  • Null is not allowed in priorty Queue

Ans 6:

Set is an abstract data type that can store unique values, without any particular order.

Thank You!


Related Solutions

Java OVERVIEW This program primarily focuses on the implementation of a ArrayList type interface and the...
Java OVERVIEW This program primarily focuses on the implementation of a ArrayList type interface and the necessary methods to implement the ArrayList. It also includes polymorphism and class comparison. INSTRUCTIONS Your deliverable will be to turn in three files. The files will be named Card.java, PremiumCard.java and the last file will be called CardArrayList.java. For this assignment, any use of a data control structure other than a simple Arrary or String will result in no credit. I am aware that...
Find a method of ArrayList that is not in the List interface, specifically a method that...
Find a method of ArrayList that is not in the List interface, specifically a method that trims the internal array down to fit exactly. A Google search for this did work, but the JDK API of course is the definitive source. Give the method header for the method. Add a call to this method to TestArrayList.java (which is available online in TestArrayList.zip), and see that it compiles and runs fine. Now change the line creating the ArrayList to use type...
java programming Concepts ArrayList - Collections Sorting Enhanced For Loop Collections Class Auto-boxing Programming Assignment 1....
java programming Concepts ArrayList - Collections Sorting Enhanced For Loop Collections Class Auto-boxing Programming Assignment 1. Describe auto-boxing, including why it is useful. (Google for this one) Write a few lines of code that auto-box an int into an Integer, and un-box an Integer to an int. 2. Declare an ArrayList of Strings. Add 5 names to the collection. "Bob" "Susan" ... Output the Strings onto the console using the enhanced for loop. 3. Sort the list using the method...
JAVA: when input is type ArrayList<ArrayList<Integer>> how to use java to get this solution [ [a,b,c]...
JAVA: when input is type ArrayList<ArrayList<Integer>> how to use java to get this solution [ [a,b,c] , [d,e], [f] ] ----> [ [a,d,f], [a,e,f], [b,d,f], [b,e,f], [c,d,f], [c,e,f]] [ [a,b], [a,b,c]] ----->[[a,a],[a,b],[a,c], [b,a],[b,b],[b,c] assuming abc are integer Thanks in advance!
Java: Determine the ouotput of this code ArrayList<String>list=new ArrayList<String>();             list.add("Namath");           &
Java: Determine the ouotput of this code ArrayList<String>list=new ArrayList<String>();             list.add("Namath");             list.add("Sauer");             list.add("Maynard");             list.add("Namath");             list.add("Boozer");             list.add("Snell");             list.add("Namath");             list.add("Atkinson");             list.add("Lammonds");             list.add("Dockery");             list.add("Darnold");             list.remove(2);             list.set(2, "Brady");             list.remove(2);             list.set(4,"Unitas");             list.add(1,"Lamomica");             list.add(3,"Hanratty");             list.remove("Namath");             list.remove(list.size()-1);             list.remove(2);             list.set(7, "Riggins");             Iterator iter = list.iterator();           while (iter.hasNext())         {   System.out.print(iter.next() + " ");                         }                     } }
This program focuses on programming with Java Collections classes. You will implement a module that finds...
This program focuses on programming with Java Collections classes. You will implement a module that finds a simplified Levenshtein distance between two words represented by strings. Your program will need support files LevenDistanceFinder.Java, dictionary.txt, while you will be implementing your code in the LevenDistanceFinder.java file. INSTRUCTIONS The Levenshtein distance, named for it's creator Vladimir Levenshtein, is a measure of the distance between two words. The edit distance between two strings is the minimum number of operations that are needed to...
Write code in java using the LinkedList connecting two different classes. For example, Employee and EmployeeList...
Write code in java using the LinkedList connecting two different classes. For example, Employee and EmployeeList are two different classes that are used to create the assignment.
Move all zeros in an arraylist to the end of the list using a temp(java). if...
Move all zeros in an arraylist to the end of the list using a temp(java). if it is an array the code would look like the code below, change it to fit an arraylist int count = 0;     int temp;     for (int i = 0; i < n; i++) {     if ((arr[i] != 0)) {         temp = arr[count];         arr[count] = arr[i];         arr[i] = temp;         count = count + 1;     }     } }
Java The List ADT has an interface and a linked list implementation whose source code is...
Java The List ADT has an interface and a linked list implementation whose source code is given at the bottom of this programming lab description. You are to modify the List ADT's source code by adding the method corresponding to the following UML: +hasRepeats() : boolean hasRepeats() returns true if the list has a value that occurs more than once in the list hasRepeats() returns false if no value in the list occurs more than once in the list For...
Java The List ADT has an interface and a linked list implementation whose source code is...
Java The List ADT has an interface and a linked list implementation whose source code is given at the bottom of this programming lab description. You are to modify the List ADT's source code by adding the method corresponding to the following UML: +hasRepeats() : boolean hasRepeats() returns true if the list has a value that occurs more than once in the list hasRepeats() returns false if no value in the list occurs more than once in the list For...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT