AT&T; LTE * 14% 2:52 PM elearn.tnstate.edu 1. What is wrong in the following Mai
ID: 3589890 • Letter: A
Question
AT&T; LTE * 14% 2:52 PM elearn.tnstate.edu 1. What is wrong in the following Main method? public static void Main) intl] ai a[2] = 5; 2. Correct any errors in the following declaration. char[] vowel {a, e, i, o, u); Write C# code to swap integer array elements a [i] and aj 3. 4. Consider inti v-(23, 44, 78, 58 int[] w = v; w[1] = 99; What is the value of v[1]? Answer: 5. Diagram the memory usage resulting from the execution of int[] int a= {88, b-ai 89, 33, 55, 77); 6. Write C# code to make a copy of the array a in question 5.Explanation / Answer
1) Here, we should write
public static void main(String args[])
\ it is necessary to write the String args[] because when we run a java program from command prompt,we can pass some input to our Java program. Those inputs are stored in this String args array and "main" should be written in small letters.
{
int[] a= new int {3,4,5}; \ here the elements in the array is declared
a[2] = 5;
}
............................................................................................................................................
2)
Since the vowels are characters that's why the should be declared like this
char[] vowel = { ' a ' , ' e ' , ' i ' , ' o ' , ' u ' };
..........................................................................................................................................................
3)The code for swapping the integers in an array is
.......................................................................................................................................................................................
4) the value of v[1] will also be 99, as v[1] gets the value of w[1]
The program is given below
class Myclass
{
public static void main (String args[])
{
int[] v = {23, 44, 78, 58};
int[] w = v;
w[1]=99;
{
System.out.println(v[1]);
}}}
The output was 99
..................................................................................................................................................................................
6)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.