What would be the results of the following code value contai
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
====================================================

