What is the result?

Given:
public class Vowel { private char var;
public static void main(String[] args) { char var1 = 1 a 1 ; char var2 = varl; var2 = 1 e 1 ;
Vowel obj1 = new Vowel ();
Vowel obj2 = objl; obj1.var = 1 i 1 ; obj 2.var = ‘o’;
System.out.println(varl + ", " +var2);
System.out.print(obj1.var + ", " +obj2.var);
}
}
What is the result?
A. e,e i, o
B. a, e i, o
C. a, e o, o
D. e, e o, o

Download Printable PDF. VALID exam to help you PASS.

5 thoughts on “What is the result?

  1. Answer C:

    This is because obj2 is referring to obj1. Therefore, the assignment obj2.var = ‘o’ is reflected in obj1.

    5
    1
  2. Answer is C

    public class Vowel {
    private char var;

    public static void main(String[] args) {
    char var1 = ‘a’;
    char var2 = var1;
    var2 = ‘e’;
    Vowel obj1 = new Vowel();
    Vowel obj2 = obj1;
    obj1.var = ‘i’;
    obj2.var = ‘o’;
    System.out.println(var1 + “, ” + var2);
    System.out.print(obj1.var + “, ” + obj2.var);
    }
    }

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.