Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

What is the output of the following code public class ComputeResult { public sta

ID: 3885781 • Letter: W

Question

What is the output of the following code

public class ComputeResult {

    public static void main(String[] agrs){

        Computer a= new Computer();

        Computer b= new Computer();

       

       a.y=5;

       b.y=6;

       a.x=1;

       b.x=2;

     

       System.out.println("a.y = " + a.y);

       System.out.println("b.y = " + b.y);

       System.out.println("a.x = " + a.x);

       System.out.println("b.y = " + b.x);

       System.out.println("Computer.x = " + Computer.x)

       

    }

}

Consider the following string:

            String bellah = “Did bellah see bees? Hannah did.”:

What is the value displayed by the expression bellah.lenth()?

What is the value returned by the method call bellah.chatAt(12)?

Write an expression that refers to the letter b in the string referred to by bellah

Conside the code

Char                vowel0 = ”a”;

Final Char      vowel1 = vowel0;

String             vowel2 = vowel1 + “eiou”;

Final String    vowel3 = vowel2;

Char []                        vowel4 = new Char[] { vowel0, ‘e’, ‘i’ , ‘o’ , ‘u’};

Final Char[]    vowel5 = vowel4”;

Which of the following statements are legal java?

vowel3[0]= ‘x’;

vowel4= vowel5;

vowel5= vowel4;

vowel4[0]= ‘x’;

vowel5[0]= ‘z’;

Explanation / Answer

If both x and y are static variables in the class Computer
output would be
a.y = 6
b.y = 6
a.x = 2
b.y = 2
Computer.x = 2

bellah.lengh() method call returns the length of the string bellah, that is 32
Metho call bellah.charAt(12) returns the character at position 13, i.e 'e'
bellah.charAt(4) returns 'b'

The below statements are valid
vowel4 = vowel5 ** Assigning char array to another char array
vowel4[0] = 'x'

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote