The document discusses the concept of collections in programming, defining them as containers that group multiple elements. It contrasts collections with arrays, highlighting that collections can hold heterogeneous elements while arrays are limited to homogeneous data types. Additionally, it provides methods for adding elements to collections and explains the significance of array indices.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
4 views1 page
VII Coding Chap4 Homework
The document discusses the concept of collections in programming, defining them as containers that group multiple elements. It contrasts collections with arrays, highlighting that collections can hold heterogeneous elements while arrays are limited to homogeneous data types. Additionally, it provides methods for adding elements to collections and explains the significance of array indices.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1
LASS: VII
C SUBJECT: CODING
Ch 4: Understanding Array and Collections Term: 2
1. What is a Collection? Give two examples of the collection.
Q Ans. A collection is a container which groups multiple elements into a single object. Collections are used to store, retrieve and manipulate stored data. Examples 1) Collection of cards 2) Telephone directory
2. Write one difference between array and collection.
Q Ans Collection Array It can hold both homogeneous and rray is a collection of variables of A heterogeneous elements. similar data types.
3. How can you add an element to the collections?
Q Ans: To add elements while iterating, keep the new elements in a temporary list, set or map and then the elements are added once you finish iterating the collection.
4. What do you mean by “array index”?
Q Ans: Array index indicates the position of the element within the array. Array elements can be accessed by referring to its index number.
5. Write any two advantages of collection.
Q Ans. 1) It groups multiple elements into a common set. 2) It consumes less memory.