23 What output is produced by the following code if user ent
Solution
(23)
In the given program,
-> outer do-while loops till user enters some negative number
-> Inner while loops till user enters an integer
----------------------------------------------------------------------------------
ANS: (1):
User entered 3
Output Produced:
This program shows how to verify I/P data using Scanner methods
Enter a positive integer value! (enter -1 to end): 3
Good! You entered: 3 (User entered)
Enter a positive integer value! (enter -1 to end):
( Continue to prompt the same until user enters -1 to end)
----------------------------------------------------------------------------------
ANS: (2):
User entered five
Output Produced:
This program shows how to verify I/P data using Scanner methods
Enter a positive integer value! (enter -1 to end): five
That\'s not a member!
Enter a positive integer value:
( Continue to prompt the same until user enters -1 to end)
----------------------------------------------------------------------------------
ANS: (3):
User entered 7
Output Produced:
This program shows how to verify I/P data using Scanner methods
Enter a positive integer value! (enter -1 to end): 7
Good! You entered: 7 (User entered)
Enter a positive integer value! (enter -1 to end):
( Continue to prompt the same until user enters -1 to end)
----------------------------------------------------------------------------------
ANS: (4):
User entered -1
Output Produced:
This program shows how to verify I/P data using Scanner methods
Enter a positive integer value! (enter -1 to end): -1
Good! You entered: -1
End of Program
( Program stops here as Sentinel value is encountered )
______________________________________________________________________________________________
_______________________________________________________________________________________________
(24)
Given two statements are same way of declaring array.
Statements:
int[] weight = new int[100];
int weight1[] = new int[100];
creates an array with name weight of capacity 100
In order to declare am array named income of capacity 20 elements:
int[] income = new int[20];
(or)
int income[] = new int[20]
Since given two statements are same for declaring an array, answer is \"Yes\"

