1.
What is an array?
Correct Answer
C. A sequence of values.
Explanation
An array is a data structure that stores a sequence of values. It allows multiple values of the same data type to be stored in a contiguous memory space, which can be accessed using an index. This makes it easier to organize and manipulate large amounts of data efficiently.
2.
How do you access an array element?
Correct Answer
A. By the name of the array followed by the index value in brackets.
Explanation
To access an array element, you use the name of the array followed by the index value in brackets. This is the correct way to access a specific element in an array.
3.
What is the index value of the first element?
Correct Answer
B. 0
Explanation
The index value of the first element is 0 because in most programming languages, arrays and lists are zero-indexed, meaning that the first element is located at index 0. Therefore, the correct answer is 0.
4.
What is the Enhanced for Loop?
Correct Answer
B. It transverses all elements of a collection.
Explanation
The enhanced for loop is a control flow statement that allows for easy iteration over elements of a collection. It automatically traverses all the elements in the collection without the need for explicit indexing or boundary checks. This loop is commonly used when there is a need to access each element sequentially in a collection, such as an array or a list. It simplifies the code and improves readability by eliminating the need for manual iteration control.
5.
What does a Two-Dimensional Array do?
Correct Answer
A. It forms a tabular, two dimensional arrangement.
Explanation
A two-dimensional array is a data structure that stores values in a tabular format with rows and columns. It allows for the organization of data in a grid-like structure, where each element can be accessed using two indices, representing the row and column positions. This arrangement is useful for representing data that has multiple dimensions, such as a matrix or a spreadsheet.
6.
How do you access an array element?
Correct Answer
C. Variable = name.get(i);
Explanation
To access an array element, the correct way is to use the syntax "variable = name.get(i)". This is because arrays in many programming languages are zero-indexed, meaning the first element is at index 0. By using the "get" method with the index as the parameter, we can retrieve the value at the specified index in the array named "name" and assign it to the variable. The other options provided, "variable = name[i]" and "variable = i.name", are incorrect syntax for accessing array elements.
7.
Which is true about wrapper classes?
i) All wrapper class names start with upper case letters.ii) They are used to treat primitive type values as objects for array lists.iii) They are imperitive to use whenever an array is used.
Correct Answer
D. I, ii only
Explanation
Wrapper classes are classes that encapsulate primitive data types and allow them to be treated as objects. The statement "All wrapper class names start with upper case letters" is true because all wrapper class names, such as Integer, Double, and Boolean, start with an uppercase letter. The statement "They are used to treat primitive type values as objects for array lists" is also true because wrapper classes are commonly used when working with collections like ArrayList, which can only store objects and not primitive types. However, the statement "They are imperative to use whenever an array is used" is false because arrays can directly store primitive types without the need for wrapper classes.
8.
What is auto-boxing?
Correct Answer
A. It is the automatic conversion between primitive types and the corresponding wrapper classes.
Explanation
Auto-boxing refers to the automatic conversion of primitive types (such as int, float, etc.) to their corresponding wrapper classes (Integer, Float, etc.) in Java. This conversion allows primitive types to be used in situations where objects are required, such as when using collections or generics. It simplifies the code by eliminating the need for manual conversion between primitive types and their wrapper classes.
9.
True or False: Auto-wrapping is another name for auto-boxing.
Correct Answer
A. True
Explanation
Auto-wrapping is another name for auto-boxing because both terms refer to the automatic conversion of a primitive data type to its corresponding wrapper class object. Auto-wrapping is commonly used in object-oriented programming languages to simplify the process of converting between primitive types and their object representations. Therefore, the statement "Auto-wrapping is another name for auto-boxing" is true.
10.
Which is not true about regression testing?
Correct Answer
B. Regression testing disgards old test cases, therefore it is difficult to get feedback.
Explanation
Regression testing involves repeating previously run tests to ensure that known failures of prior versions do not appear in new versions of the software. It does not discard old test cases, but rather includes them along with new test cases to ensure that the software still functions correctly. This allows for feedback on the performance of the software across different versions. Regression testing can be used anytime you are able to test two versions of the same program, making it a valuable technique in software development.
11.
Which of the following are common errors when using arrays and array lists?i) Bounds errorsii) Underestimating the size of a data setiii) Confusing length and size
Correct Answer
D. I, ii, and iii
Explanation
Common errors when using arrays and array lists include bounds errors, underestimating the size of a data set, and confusing length and size. Bounds errors occur when trying to access an element outside the valid range of indices. Underestimating the size of a data set can lead to insufficient memory allocation and potential data loss. Confusing length and size can result in incorrect calculations or assumptions about the number of elements in the array or array list. Therefore, the correct answer is i, ii, and iii.