What would be the results of the following code value contai

What would be the results of the following code? value contains the highest value in array1 value contains the lowest value in array1 value contains the sum of all the values in array1 value contains the average of the value in array 1 What will he printed after the following code is executed? For the following code, how many times would the while loop execute? Assuming the following declaration exists:

Solution

====================================================
12.
------------
Answer:
-----------

       b. value contains the lowest value in array1
  
------------------
Explanation:
------------------

      
       //Assigns the first element value i.e array1[0] to value variable
       int value = array1[0];
      
       //Reapeats loop from index 1 to end of the array1 size
       for(int a=1;a<array1;a++) {
      
           //This if conditions check for every element , If found any lowest in array1
           //updates value to the lowest value of array1
           if(array1[a]<value)   
               value = array1[i];
       }

====================================================
13.
------------
Answer:
-----------

       b. ABC
  
------------------
Explanation:
------------------

      
       //Assigns a string to str with value abc456
       String str = \"abc456\";

       int m=0;
      
       //Reapeats loop from m value to 0 to 5
       while(m<6) {  
      
           //Checks if the current character is of type letter, If of type
           //Character prints the character in upper case form
           if(Character.isLetter(str.charAt(m)))
                   System.out.print(Character.toUpperCase(str.charAt(m)));
                  
          
           m++;
          
       }
====================================================
14.
------------
Answer:
-----------

       d. 9
  
------------------
Explanation:
------------------

  
   //Definings tokenizer
   StringTokenizer strToken = new StringTokenizer(\"Cars, trucks, and SUVs \" +
           \"are all types of automobiles.\");
  
   //Printing all tokens
   while(strToken.hasMoreTokens()) {
       System.out.println(strToken.nextToken());
   }
  
   Loop repeats for 9 times. Since there are total of 9 tokens.
   Each token is seperated by space.
  
====================================================
15.
------------
Answer:
-----------

       c. OAK
  
------------------
Explanation:
------------------

       Prints OAK since enum represent named constants.
      
       Hence , Tree.OAK prints OAK
====================================================

 What would be the results of the following code? value contains the highest value in array1 value contains the lowest value in array1 value contains the sum of
 What would be the results of the following code? value contains the highest value in array1 value contains the lowest value in array1 value contains the sum of

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site