# IT 15 Semi Finals!

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
| By Yubabs94
Y
Yubabs94
Community Contributor
Quizzes Created: 3 | Total Attempts: 176
Questions: 23 | Attempts: 60

Settings

.

• 1.

### It is a collection of values with the same data type.

• A.

Variable

• B.

Array

• C.

Functions

• D.

Constants

B. Array
Explanation
An array is a collection of values with the same data type. It allows us to store multiple values of the same type in a single variable, making it easier to manage and access the data. Arrays are commonly used in programming to store and manipulate large sets of data efficiently.

Rate this question:

• 2.

### The number of elements an array can hold depends on

• A.

Type of an Array

• B.

Index of an Array

• C.

Strength of an Array

• D.

Size of an Array

D. Size of an Array
Explanation
The number of elements an array can hold depends on the size of the array. The size of an array determines the amount of memory allocated for storing its elements. The size is specified when the array is declared and cannot be changed during runtime. Therefore, the size of an array directly affects the number of elements it can hold. The other options listed (type of array, index of array, and strength of array) do not determine the number of elements an array can hold.

Rate this question:

• 3.

### How are arrays identified

• A.

By their array sizes

• B.

By their indexes

• C.

By their array names

• D.

By their array locations

C. By their array names
Explanation
Arrays are identified by their array names because the name of an array serves as a reference to the memory location where the array is stored. By using the array name, we can access and manipulate the elements of the array. The array name acts as a pointer to the first element of the array, allowing us to perform operations on the entire array using the name. Therefore, the array name is crucial in identifying and working with arrays in programming.

Rate this question:

• 4.

### This tells what kind of values an array can hold

• A.

Index of an array

• B.

Strength of an Array

• C.

Size of an Array

• D.

Type of an array

D. Type of an array
Explanation
The correct answer is "Type of an array" because the type of an array determines the kind of values it can hold. The type of an array specifies the data type of its elements, such as integers, strings, or objects. This is important because it determines the operations that can be performed on the array and the memory allocation required for each element.

Rate this question:

• 5.

### What type of values can the array String[] places = new String[20] hold?

• A.

Integers

• B.

Characters

• C.

Floating point

• D.

String

D. String
Explanation
The array "places" is declared as a String array with a size of 20. This means that each element in the array can hold a value of type String. Therefore, the array can hold String values and not integers, characters, or floating point numbers.

Rate this question:

• 6.

### In the array String[] places = new String[20], how many values can be stored in it?

• A.

19

• B.

20

• C.

String

• D.

Places

B. 20
Explanation
The given code creates an array of type String with a size of 20. The size of an array determines the number of elements it can store. In this case, since the size is 20, the array can store 20 values. Therefore, the correct answer is 20.

Rate this question:

• 7.

### The first index of an array should be always be ________?

• A.

3

• B.

The size of the array

• C.

. the size of the array -1

Explanation
The first index of an array should always be 0. This is because in most programming languages, arrays are zero-indexed, meaning that the first element is accessed using the index 0. Therefore, the correct answer is 0.

Rate this question:

• 8.

### The highest possible index of an array should always be?

• A.

3

• B.

The size of the array

• C.

. the size of the array -2

C. . the size of the array -2
Explanation
The highest possible index of an array should always be the size of the array minus 1. This is because arrays are zero-indexed, meaning that the first element of the array is at index 0. Therefore, the last element of the array will be at index size of the array minus 1. For example, if an array has a size of 5, the highest possible index would be 4.

Rate this question:

• 9.

### It is used to access a value in array. In other words, it serves as the address of value in an array

• A.

Array location

• B.

Array index

• C.

Array Size

• D.

Array Type

B. Array index
Explanation
The array index is used to access a specific value within an array. It represents the position or address of the value within the array. By using the array index, we can retrieve or modify the value at that particular location in the array. It is an essential concept in array manipulation and allows us to efficiently work with the elements stored in an array.

Rate this question:

• 10.

### Which of the following is the proper way of assigning values in an array?

• A.

Int ages[1,2,3,4,5];

• B.

Int ages = {1,2,3,4,5};

• C.

Int[5] ages = new int[{1,2,3,4,5}];

• D.

Int[] ages = {1.9, 2.9, 3.4, 3.5};;

D. Int[] ages = {1.9, 2.9, 3.4, 3.5};;
Explanation
The correct way of assigning values in an array is by using the syntax "int[] ages = {1.9, 2.9, 3.4, 3.5}". This creates an array named "ages" of type int[], and assigns the values 1.9, 2.9, 3.4, and 3.5 to the elements of the array. The other options are incorrect: "int ages[1,2,3,4,5]" uses incorrect syntax for assigning values in an array, "int ages = {1,2,3,4,5}" is incorrect because the variable "ages" is declared as an int and not an array, and "int[5] ages = new int[{1,2,3,4,5}]" also uses incorrect syntax for assigning values in an array.

Rate this question:

• 11.

### It is a kind of array which contains another array(s). In other words, it is an array of arrays.

• A.

One-dimensional

• B.

Two-way

• C.

Three-type

• D.

Multidimensional

D. Multidimensional
Explanation
A multidimensional array is a type of array that contains other arrays within it. It is often used to store data in a tabular format, such as a matrix or a grid. Unlike a one-dimensional array, which has a single row or column, a multidimensional array can have multiple dimensions, allowing for more complex data structures. This type of array is useful when dealing with data that has multiple dimensions or when organizing data in a hierarchical manner.

Rate this question:

• 12.

### It is form of array which can be represented in a tabular format - it has a row and a column

• A.

One-dimensional

• B.

Two-dimensional

• C.

Three-dimensional

• D.

Multidimensional

B. Two-dimensional
Explanation
A two-dimensional array is a form of array that can be represented in a tabular format with rows and columns. Unlike a one-dimensional array, which only has a single row or column, a two-dimensional array allows for multiple rows and columns. This makes it suitable for representing data that has a two-dimensional structure, such as a grid or a matrix. In a two-dimensional array, elements are accessed using two indices, one for the row and one for the column.

Rate this question:

• 13.

### In the array int[][] temp = new int[5][7] how many rows can the array hold?

• A.

1

• B.

5

• C.

4

• D.

7

B. 5
Explanation
The given array, int[][] temp = new int[5][7], can hold 5 rows. This is because the first dimension of the array declaration specifies the number of rows, which is 5 in this case. The second dimension specifies the number of columns, which is 7. Therefore, the array can hold 5 rows and 7 columns.

Rate this question:

• 14.

### In the array int[][] temp = new int[5][7] how many columns can the array hold?

• A.

1

• B.

5

• C.

4

• D.

7

D. 7
Explanation
The given array declaration `int[][] temp = new int[5][7]` creates a 2-dimensional array with 5 rows and 7 columns. Therefore, the array can hold a maximum of 7 columns.

Rate this question:

• 15.

### It is an access modifier that lets the method be seen by other classes and methods

• A.

Public

• B.

Private

• C.

Prototype

• D.

Protected

A. Public
Explanation
Public is an access modifier that allows the method to be visible and accessible by other classes and methods. This means that any class or method in the program can call and use the public method. It is the most permissive access modifier, providing the widest accessibility to the method.

Rate this question:

• 16.

### Say we have a method public double add (double x, double y), what is the correct way to call this method in the main Java method

• A.

• B.

• C.

• D.

Explanation
The correct way to call the method "add" in the main Java method is by using the syntax "add(x, y)". This means that we are passing two arguments, x and y, to the add method.

Rate this question:

• 17.

### It is an access modifier that lets the method be seen by other classes and methods but with reservations

• A.

Public

• B.

Private

• C.

Prototype

• D.

Protected

D. Protected
Explanation
The access modifier "protected" allows the method to be visible to other classes and methods within the same package or subclass, but not to classes outside the package. It provides a level of accessibility between the public and private access modifiers, allowing limited visibility and control over the method's usage.

Rate this question:

• 18.

### It refers to the type of data returned or accepted by the method

• A.

Method prototype

• B.

Method definition

• C.

Method call

• D.

Return type

D. Return type
Explanation
The return type of a method refers to the type of data that the method will return or accept. It specifies the data type of the value that the method will produce as output. In other words, it indicates the type of value that the method will "return" to the caller. The return type is an essential part of the method's signature and is declared in the method prototype and definition. It helps in determining the type of value that can be assigned or used when calling the method.

Rate this question:

• 19.

### This is used to execute a method. When invoked, the method body will then be executed

• A.

Method prototype

• B.

Method definition

• C.

Method call

• D.

Return type

C. Method call
Explanation
A method call is used to execute a method. When a method call is invoked, the method body will be executed. In other words, it is the action of actually running the code within a method. This is done by using the method's name followed by parentheses, which may include any necessary arguments or parameters.

Rate this question:

• 20.

### Int[] foo= {10, 12, 13, 15, 18};int n, result=0;int main (){for ( n=0 ; n<5 ; ++n )result += foo[n];}}What is the output of this program

145, 1 4 5, 145.
Explanation
The output of this program is 145. The program initializes an integer array called "foo" with the values 10, 12, 13, 15, and 18. It then declares two integers, "n" and "result", with "result" initially set to 0. In the main function, a for loop is used to iterate through the elements of the "foo" array. On each iteration, the value of the current element is added to the "result" variable. After the loop completes, the final value of "result" is 145.

Rate this question:

• 21.

### Public class TestArray {     public static void main(String[] args) {      double[] myList = {1.9, 2.9, 3.4, 3.5};        // Print all the array elements      for (int i = 0; i < myList.length; i++) {         System.out.println(myList[i] + " ");      }      // Summing all elements      double total = 0;      for (int i = 0; i < myList.length; i++) {         total += myList[i];      }      System.out.println("Total is " + total);      // Finding the largest element      double max = myList[0];      for (int i = 1; i < myList.length; i++) {         if (myList[i] > max) max = myList[i];      }      System.out.println("Max is " + max);   }} What is the output of this source code?

1.9 2.9 3.4 3.5 Total is 11.7 Max is 3.5
Explanation
The given source code creates an array called "myList" with the values 1.9, 2.9, 3.4, and 3.5. It then prints each element of the array using a for loop. After that, it calculates the sum of all the elements in the array and prints the total. Finally, it finds the largest element in the array and prints it as the maximum. Therefore, the output of the source code will be:
1.9
2.9
3.4
3.5
Total is 11.7
Max is 3.5

Rate this question:

• 22.

### Public static void main(String[] args){ Scanner console = new Scanner(System.in);  int n, temp=0;  S.O.P("Enter a positive  integer: ");  n=console.nextInt();  temp = mysteryFunction (n);    if(temp==0)    S.O.P( n + " is a prime number.");  else    S.O.P( n +" is not a prime number.");  return 0;} public int mysteryFunction(int n){   int i, flag=0;        for(i=2;i<=n/2;++i)        {                if(n%i==0)                {               flag=1;               break;               }        }  return flag;}          What will be the output if the user inputs the value of the ffg as the value of n?  1.) n = 5      2.) n=-2 3.) n = 250    4.) n=05.) n = 10

5 is a prime number Error 250 is not a prime number 0 is not a prime number 10 is not prime number
Explanation
The correct answer is 5 is a prime number. The mysteryFunction is checking if the input number is divisible by any number from 2 to n/2. If it is divisible by any number, the flag variable is set to 1, indicating that the number is not a prime. If the flag variable remains 0, it means that the number is not divisible by any number and hence it is a prime number. In this case, the input number is 5, which is not divisible by any number from 2 to 5/2 (which is 2), so the flag remains 0 and the output is "5 is a prime number".

Rate this question:

• 23.