Java Programming
primer-original-v2mediumJava Programming04 Arrays And Stringsprimer-original-v2

Given a one-dimensional array arr, what is the correct way of getting the number of elements in arr?

Answer options

A
arr.length()
B
arr.length()-1
C
arr.length
D
arr.length-1

Correct answer: arr.length()

Explanation

Quick AnswerThe correct answer is arr.length() because it directly addresses the core logic of Java Programming.

This question has been retained as-is due to its unique context.

Related Java Programming questions

Practice more Java Programming questions

PrimerPrep has independently reviewed practice questions and coding exercises — all free.