Question
Assume you have the following variable declarations: SimpleReader in = new SimpleReader1L(); SimpleWriter out = new SimpleWriter1L(); Write program fragments (i.e., you do not need
Assume you have the following variable declarations:
SimpleReader in = new SimpleReader1L(); SimpleWriter out = new SimpleWriter1L(); |
Write program fragments (i.e., you do not need to write complete programs) that read a line of input as a String and print:
Only the uppercase letters in the String
Every second letter of the String
The String with all vowels replaced by an underscore
The number of vowels in the String
The positions of all vowels in the String
Consider the following array:
int[] a = { 1, 2, 3, 4, 5, 4, 3, 2, 1, 0 }; |
What are the contents of the array a after the following loops complete?
1 2 3 4 5 | int i = 1; while (i < 10) { a[i] = a[i - 1]; i++; } |
1 2 3 4 5 | int i = 9; while (i > 0) { a[i] = a[i - 1]; i--; } |
1 2 3 4 5 | int i = 0; while (i < 9) { a[i] = a[i + 1]; i++; } |
1 2 3 4 5 | int i = 8; while (i >= 0) { a[i] = a[i + 1]; i--; } |
1 2 3 4 5 | int i = 1; while (i < 10) { a[i] = a[i] + a[i - 1]; i++; } |
1 2 3 4 5 | int i = 1; while (i < 10) { a[i] = 0; i = i + 2; } |
1 2 3 4 5 | int i = 0; while (i < 5) { a[i + 5] = a[i]; i++; } |
1 2 3 4 5 | int i = 1; while (i < 5) { a[i] = a[9 - i]; i++; } |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started