IT 15 Semi Finals Section 10

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.
Learn about Our Editorial Process
| By Yubabs94
Y
Yubabs94
Community Contributor
Quizzes Created: 2 | Total Attempts: 116
Questions: 22 | Attempts: 47

SettingsSettingsSettings
IT 15 Semi Finals Section 10 - Quiz

.


Questions and Answers
  • 1. 

    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?

  • 2. 

    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?

  • 3. 

    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

  • 4. 

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

    • A.

      Variable

    • B.

      Array

    • C.

      Functions

    • D.

      Constants

    Correct Answer
    B. Array
    Explanation
    An array is a data structure that allows you to store multiple values of the same data type under a single variable name. It provides a way to efficiently manage and access a collection of values. In an array, each value is assigned an index, starting from 0, which allows for easy retrieval and manipulation of specific elements within the collection. Therefore, an array is the correct answer as it fits the description of a collection of values with the same data type.

    Rate this question:

  • 5. 

    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

    Correct Answer
    D. Size of an Array
    Explanation
    The correct answer is "Size of an Array" because the number of elements an array can hold is determined by its size. The size of an array defines the total amount of memory allocated for storing its elements. Therefore, the larger the size of the array, the more elements it can hold. The type of the array, index of the array, and strength of the array do not directly affect the number of elements an array can hold.

    Rate this question:

  • 6. 

    How are arrays identified

    • A.

      By their array sizes

    • B.

      By their indexes

    • C.

      By their array names

    • D.

      By their array locations

    Correct Answer
    C. By their array names
    Explanation
    Arrays are identified by their array names because the name of an array is used to access and manipulate its elements. The array name acts as a reference to the memory location where the array is stored. By using the array name, we can easily access and modify the elements of the array. The array size determines the number of elements in the array, while indexes are used to access specific elements within the array. However, the primary identifier for an array is its name.

    Rate this question:

  • 7. 

    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

    Correct Answer
    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 that can be stored in it. The type of an array specifies the data type of its elements, such as integers, strings, or objects. This is important because it ensures that only compatible values can be assigned to the array, preventing type errors and ensuring data integrity.

    Rate this question:

  • 8. 

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

    • A.

      Integers

    • B.

      Characters

    • C.

      Floating point

    • D.

      String

    Correct Answer
    D. String
    Explanation
    The array "places" is declared as a String array and initialized with a size of 20. This means that each element in the array can hold a value of type String. Therefore, the correct answer is String.

    Rate this question:

  • 9. 

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

    • A.

      19

    • B.

      20

    • C.

      String

    • D.

      Places

    Correct Answer
    B. 20
    Explanation
    The given array declaration "String[] places = new String[20]" creates an array named "places" with a size of 20. This means that the array can store 20 values.

    Rate this question:

  • 10. 

    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

    • D.

      0

    Correct Answer
    D. 0
    Explanation
    The first index of an array should always be 0 because in most programming languages, arrays are zero-indexed, meaning the first element is accessed using the index 0. This convention allows for easier and more efficient manipulation of array elements using mathematical operations and simplifies the implementation of algorithms that rely on indexing.

    Rate this question:

  • 11. 

    The highest possible index of an array should always be?

    • A.

      3

    • B.

      The size of the array

    • C.

      The size of the array -1

    • D.

      0

    Correct Answer
    C. The size of the array -1
    Explanation
    In most programming languages, arrays are zero-indexed, meaning that the first element in the array has an index of 0. Therefore, the highest possible index of an array would be one less than the size of the array. For example, if the size of the array is 4, the highest possible index would be 3.

    Rate this question:

  • 12. 

    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

    Correct Answer
    B. Array index
    Explanation
    The array index is used to access a specific value in an array. It represents the position or address of the value within the array. By specifying the index, we can retrieve the desired element from the array.

    Rate this question:

  • 13. 

    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};;

    Correct Answer
    D. Int[] ages = {1.9, 2.9, 3.4, 3.5};;
    Explanation
    The proper way of assigning values in an array is by using the syntax "int[] ages = {1.9, 2.9, 3.4, 3.5}". This syntax declares an array of integers named "ages" and initializes it with the given values {1.9, 2.9, 3.4, 3.5}. The use of "int[]" indicates that it is an array of integers, and the curly braces {} are used to enclose the values that are being assigned to the array elements. The given option "int[] ages = {1.9, 2.9, 3.4, 3.5}" follows this correct syntax.

    Rate this question:

  • 14. 

    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

    Correct Answer
    D. Multidimensional
    Explanation
    A multidimensional array is a type of array that contains other arrays. It is used to store data in multiple dimensions, such as rows and columns. This allows for the organization and manipulation of complex data structures. Unlike a one-dimensional array, which only has a single row or column, a multidimensional array can have multiple rows and columns. It provides a way to represent and work with data that has multiple levels of depth and complexity.

    Rate this question:

  • 15. 

    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

    Correct Answer
    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 is a simple list of elements, a two-dimensional array allows for organizing data in a grid-like structure. It is commonly used to represent tables, matrices, and grids in programming. Each element in a two-dimensional array is accessed using two indices, one for the row and one for the column.

    Rate this question:

  • 16. 

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

    • A.

      1

    • B.

      5

    • C.

      4

    • D.

      7

    Correct Answer
    B. 5
    Explanation
    The given array declaration "int[][] temp = new int[5][7]" creates an array called "temp" with 5 rows and 7 columns. Therefore, the array can hold a total of 5 rows.

    Rate this question:

  • 17. 

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

    • A.

      1

    • B.

      5

    • C.

      4

    • D.

      7

    Correct Answer
    D. 7
    Explanation
    The array "temp" is declared as int[5][7], which means it is a two-dimensional array with 5 rows and 7 columns. Therefore, the array can hold a maximum of 7 columns.

    Rate this question:

  • 18. 

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

    • A.

      Public

    • B.

      Private

    • C.

      Prototype

    • D.

      Protected

    Correct Answer
    A. Public
    Explanation
    Public is an access modifier that allows the method to be visible and accessible to other classes and methods. It is the most permissive access modifier, as it provides the widest scope of visibility. With the public access modifier, the method can be called and used by any other class or method in the program. This allows for easy communication and interaction between different parts of the code.

    Rate this question:

  • 19. 

    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.

      Add(x)

    • B.

      Add(y,x)

    • C.

      Add(x,y)

    • D.

      Add(y)

    Correct Answer
    C. Add(x,y)
    Explanation
    The correct way to call the add method in the main Java method is by passing two double values, x and y, as arguments. This is indicated by the option "add(x,y)".

    Rate this question:

  • 20. 

    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

    Correct Answer
    D. Protected
    Explanation
    The correct answer is "Protected". Protected is an access modifier that allows the method to be visible to other classes and methods within the same package or subclass, but not to classes outside of the package. It provides a level of restriction, allowing limited access to the method.

    Rate this question:

  • 21. 

    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

    Correct Answer
    D. Return type
    Explanation
    The return type refers to the type of data that is expected to be returned or accepted by the method. It specifies the data type of the value that the method will return to the caller. The return type is defined in the method prototype and is used in the method definition to specify the type of the value that will be returned.

    Rate this question:

  • 22. 

    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

    Correct Answer
    C. Method call
    Explanation
    A method call is used to execute a method. When a method is invoked or called, the code within the method body will be executed. This allows the program to perform the actions or operations defined within the method. The method call is the statement that triggers the execution of the method and allows the program to utilize the functionality provided by that method.

    Rate this question:

Quiz Review Timeline +

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

  • Current Version
  • Apr 19, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Feb 18, 2016
    Quiz Created by
    Yubabs94
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.