IT 15 Semi Finals!

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Yubabs94
Y
Yubabs94
Community Contributor
Quizzes Created: 2 | Total Attempts: 120
| Attempts: 71 | Questions: 23
Please wait...
Question 1 / 23
0 %
0/100
Score 0/100
1. 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=0
5.) n = 10

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".

Submit
Please wait...
About This Quiz
IT 15 Semi Finals! - Quiz

This quiz titled 'IT 15 SEMI FINALS!' tests knowledge on arrays, focusing on their properties, identification, and usage in programming.

2. Type question here. Example: Practice makes you _____

Explanation

not-available-via-ai

Submit
3. 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

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.

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

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.

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

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.

Submit
6. It refers to the type of data returned or accepted by the method

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.

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

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.

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

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.

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

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.

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

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.

Submit
11. The number of elements an array can hold depends on

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.

Submit
12. Which of the following is the proper way of assigning values in an array?

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.

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

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.

Submit
14. How are arrays identified

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.

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

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.

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

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.

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

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.

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

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.

Submit
19. The highest possible index of an array should always be?

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.

Submit
20. This tells what kind of values an array can hold

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.

Submit
21. The first index of an array should be always be ________?

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.

Submit
22. 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
  •  

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.

Submit
23.
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?

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

Submit
View My Results

Quiz Review Timeline (Updated): May 26, 2023 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • May 26, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Feb 17, 2016
    Quiz Created by
    Yubabs94
Cancel
  • All
    All (23)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
Public static void main(String[] args){ Scanner console = new...
Type question here. Example: Practice makes you _____
Say we have a method public double add (double x, double y), what is...
It is an access modifier that lets the method be seen by other classes...
In the array String[] places = new String[20], how many values can be...
It refers to the type of data returned or accepted by the method
It is form of array which can be represented in a tabular format - it...
It is a collection of values with the same data type.
What type of values can the array String[] places = new String[20]...
It is a kind of array which contains another array(s). In other words,...
The number of elements an array can hold depends on
Which of the following is the proper way of assigning values in an...
In the array int[][] temp = new int[5][7] how many rows can the array...
How are arrays identified
It is an access modifier that lets the method be seen by other classes...
In the array int[][] temp = new int[5][7] how many columns can the...
It is used to access a value in array. In other words, it serves as...
This is used to execute a method. When invoked, the method body will...
The highest possible index of an array should always be?
This tells what kind of values an array can hold
The first index of an array should be always be ________?
Int[] foo= {10, 12, 13, 15, 18};int n, result=0;int main (){for ( n=0...
Public class TestArray { ...
Alert!

Advertisement