Ask Question
19 July, 20:33

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

+3
Answers (1)
  1. 19 July, 21:51
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers