Ask Question
8 November, 03:04

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

+1
Answers (1)
  1. 8 November, 04:53
    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?
Get 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 there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers