What is the output of the following piece of code int data

 What is the output of the following piece of code?         int[] data = {1, 2, 3, 4};         int count = 5;          if(count < data.length)                 System.out.println(\"There are four elements in the array\");         else                 System.out.println(\"Array is full.\");          

Solution

The output is :

Array is full

Explanation:

data.length = 4 so count>data.length so it will print Array is full

 What is the output of the following piece of code? int[] data = {1, 2, 3, 4}; int count = 5; if(count < data.length) System.out.println(\

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site