Ask Question

To print the number of elements in the array named ar, you can write:

A. System. out. println (length);

B. System. out. println (ar. length ());

C. System. out. println (ar. length);

D. System. out. println (ar. length-1);

+5
Answers (1)
  1. 3 January, 10:35
    0
    Option c is correct.

    Example:

    public class Subject

    {

    public static void main (String [] args)

    {

    int ar[]={5,4,6,7,8};

    System. out. println ("the number of array elements are: ", ar. length);

    }

    }

    Explanation:

    The above program is created in java language in which Subject is a class name. Inside Subject class, there is main method.

    Inside the main method, there is An array named 'ar' which data type is an integer and we have assigned the value to this array.

    in the next line, we are printing the total no. of the element in the array with the length function which displays the length of an array or variable.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “To print the number of elements in the array named ar, you can write: A. System. out. println (length); B. System. out. println (ar. length ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers