Langsung ke konten utama

Section 3 Generics and collection Oracle Java Programming

Section 3 Generics and collection
                (Answer all questions in this section)

1.            A generic class is a type of class that associates one or more non-specific Java types with it. The types are determined when an object of that class is created.
True or false?    Mark for Review
                True (*)
                False

2.            Which of the following are true about a Type Interface Diamond? 
                                                (Choose all correct answers)      
                It allows you to create a generic method as you would an ordinary method, without specifying a type between angle brackets. (*)
                It is represented by the angle brackets <>. (*)
                It is an extension of the Collections class that creates a list.
                It is a keyword in Java that prints a diamond to the console screen.
                None of the above.

3.            Choose the instance where it would be preferable to use a collection without generics.   Mark for Review
                When you have a List.
                When the Java type doesn't matter.
                When you wish to use the collection for more than one Java type.
                When you already know the Java type that the collection will hold. (*)

4.            Collections are used with generics when you already know what type you will be collecting and you are only collecting that one type.
True or false?    Mark for Review
                True
                False (*)

5.            Which of the following are true about Lists?         Mark for Review
                They grow and shrink as you add and remove objects.
                They maintain a specific order.
                They allow duplicates.
                They extend Collections.
                All of the above. (*)

6.            ArrayList is a Collection that already exists in Java and is very similar to an array.
True or false?    Mark for Review
                True (*)
                False

7.            Which of these could be a set? Why?      Mark for Review
                {1, 1, 2, 22, 305, 26} because a set may contain duplicates and all its elements are of the same type.
                {"Apple", 1, "Carrot", 2} because it records the index of the elements with following integers.
                {1, 2, 5, 178, 259} because it contains no duplicates and all its elements are of the same type. (*)
                All of the above are sets because they are collections that can be made to fit any of the choices.

8.            A HashMap is initialized with a KeyType and a ValueType inside angle brackets.
True or false?    Mark for Review
                True (*)
                False

9.            Which of the following are true about deque?    Mark for Review
                It is pronounced "deck" for short.
                It implements a stack.
                Allows for insertion or deletion of elements from the first element added or the last one
                All of the above. (*)

10.          What is the correct definition of Enumeration (or enum)?             Mark for Review
                A list of elements that is dynamically stored.
                A Double-Ended Queue.
                A keyword that specifies a class whose objects are defined inside the class. (*)

                Code that initializes a HashSet.

Komentar

Postingan populer dari blog ini

Section 6 Quiz Oracle Database Programming with SQL

Section 6 Quiz             (Answer all questions in this section)                                                             1.         Given the following descriptions of the employees and jobs tables, which of the following scripts will display each employee ï¾’ s possible minimum and maximum salaries based on their job title? EMPLOYEES Table: Name   Null?    Type EMPLOYEE_ID          NOT NULL     NUMBER (6) FIRST_NAME             VARCHAR2 (20) ...

Section 10 Quiz Database Programming With SQL

Section 10 Quiz             (Answer all questions in this section) 1.         A multiple-row operator expects how many values?   Mark for Review (1) Points             One or more (*)             Only one             Two or more             None 2.         The salary column of the f_staffs table contains the following values: 4000 5050 6000 11000 23000 Which of the following statements will return the last_name and first_name of those employees who earn more than 5000?  Mark for Review (1) Points             SELECT last_name, first_name ...

Section 6 Quiz Database Design Oracle

Section 6 Quiz             (Answer all questions in this section) 1.         Examine the following Entity and decide which rule of Normal Form is being violated: ENTITY: CLIENT ATTRIBUTES:     # CLIENT ID     FIRST NAME     LAST NAME     STREET     CITY     ZIP CODE  Mark for Review (1) Points             1st Normal Form.             2nd Normal Form.             3rd Normal Form.             None of the above, the entity is fully normalised. (*) 2.         A transitive dependency exists when any attribute in an entity...