English

Given: int KH[] = {0, 0, 0, 0, 0, 0} int len = KH.length; system.out.print("array length="+len); The output will be ______.

Advertisements
Advertisements

Question

Given:

int KH[] = {0, 0, 0, 0, 0, 0}
int len = KH.length;
system.out.print("array length="+len);

The output will be ______.

Options

  • array length = 6

  • array length = 0

  • array length = 7

  • array length = 5

MCQ
Fill in the Blanks
Advertisements

Solution

The output will be array length = 6.

Explanation:

  • Counting Elements: The array variable KH explicitly contains six zero values enclosed within its curly brackets.
  • Length Property: The built-in .length property in Java accurately counts the total number of allocated storage slots inside an array regardless of the values stored in them.
  • Final Print: The program prints out the text literal exactly as specified, displaying array length=6 on the console screens.
shaalaa.com
  Is there an error in this question or solution?
Chapter 7: Arrays - One Dimension - Exercises [Page 173]

APPEARS IN

Rupa Pandit Computer Applications [English] Class 10 ICSE
Chapter 7 Arrays - One Dimension
Exercises | Q 1. (vii) | Page 173
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×