Question

QUESTION 7 10 points Save Answer Given is a java class lustrate. What are the contents of the object 13 right after line 13 in the main method? publie class Illustrate publie atatie void main (Stringl argo private int x private static int y 0; public statie int count-0 public Illustrate0) 1. Illustrate 11 -new 1llustrate(3) 2. Illustrate 12·new Illustrate(5); Illustrate.incrementy public Illustrate(int a) 9. Illustrate.count 10 public Illustrate(Illustrate I) 12 13. Illustrate 13·new Illustrate(11); 14 15. Illustrate 14-13; 16. Illustrate.count 17. 13.setx(2) 18. I1-14 19 20 21 this.x I.x public void setx(int a) x-a public String tostring) return(x+yy countcount) public static veld incrementyc) ywo 013: x = 3, y = 0, count = 1 013: x=3. у = 1.count : 1 O 13: x 3, y 1, count o 013: x 3, y = 0, count = 0
media%2F95d%2F95d7ff6e-5059-4881-a121-43
media%2F1b7%2F1b79b508-fbf8-4e50-8c6c-8d
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Question 7: Illustrate I3 is a copy constructor and the values are exactly equal to that of variable I1,
as this variable is instantiated with I1.
As, I1 is instantiated with x value of 3 in line 1 of main().
x value is 3.
y value is initialized with 0.
As incrementY() is called at line 4 of main(), the variable y is revised to 1.
As count variable is incremented at line 9, the variable count is incremented from 0 to 1.
So, at line 13, the values are:
I3: x = 3, y = 1, count = 1

Next Question:

A is an array of type ArrayClass of size 2 elements, at line 31.
A[0] is initialized with values in object A1, at line 32.
A[1] is initialized with values in object A2, at line 33.
   Just to mention, A2 is an object with values with x, and y both set to 5 at line 30.
A[0].x value is incremented, which updates x value to 6 at line 34.

However, as you didn't updated A[1] value, it will remain the same, and therefore,
after line 34, the contents of object A[1] are:
x = 5, y = 5.

Question 10:

At line 1, I1 is initialized with x = 3, y = 0, count = 0.
At line 2, I2 is initialized with x = 5, y = 0, count = 0.
At line 4, incrementY() will increment the y value of Illustrate class from 0 to 1.
Therefore, after line 4,
I1: x = 3, y = 1, count = 0.
I2: x = 5, y = 1, count = 0.

Note that y is a static variable and will be the same for all instances.

Add a comment
Know the answer?
Add Answer to:
QUESTION 7 10 points Save Answer Given is a java class 'lustrate'. What are the contents...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please Explain, Thanks :) QUESTION 2 Ghen is a java class าน¡strate, what are the contents...

    Please Explain, Thanks :) QUESTION 2 Ghen is a java class าน¡strate, what are the contents of the object right after line 13 in the main method ? public class Illustrate public ธtatic void main (String[] args) int xj private statie int y o public statie int count 0; public 1llustrate() 1. Illustrate I1 2. Illustrate 12 new Illustrate(3); new Illustrate(5): 4. Illustrate.incrementY) public Illustrate(int a) 9. Illustrate.count 10 public Illustrate(Illustrate 1) this.x I.x public vold setx(inta) 12. 13. Illustrate...

  • output What is the output of the following: class Access public int x; private int y...

    output What is the output of the following: class Access public int x; private int y public void cal(int x, int y) { this.x = x + 1; this.y = y; } public void print() { System.out.print(""+y); } } class AccessSpecifier { public static void main(String args[]) { Access obj = new Access(); obj.cal(2, 3); System.out.print(obj.x); obj.print(); } } 33 Compilation error 23 None of the available choices Runtime error

  • Which of the following are valid array declarations? a. int[] array- new int[10]; b. double [array...

    Which of the following are valid array declarations? a. int[] array- new int[10]; b. double [array double[10]; c. charl charArray "Computer Science"; None of the above Analyze the following code: class Test public static void main(Stringl] args) System.out.println(xMethod(10); public static int xMethod(int n) System.out.println("int"); return n; public static long xMethod(long n) System.out.,println("long"); return n The program displays int followed by 10 The program displays long followed by 10. The program does not compile. None of the above. tions 3-4 are...

  • I need help with my java code i am having a hard time compiling it //...

    I need help with my java code i am having a hard time compiling it // Cristian Benitez import java.awt.Color; import java.awt.Graphics; import java.util.ArrayList; import javax.swing.JPanel; Face class public class FaceDraw{ int width; int height; int x; int y; String smileStatus; //default constructor public FaceDraw(){ } // Getters and Setters for width,height,x,y public int getWidth(){ return width; } public void setWidth(int width){ this.width=width; } public int getHeight(){ return height; } public void setHeight(int height){ this.height=height; } public int getX(){ return...

  • (JAVA NetBeans) Write programs in java Example 10.21-24 //Animal.java /** Animal class * Anderson. Franceschi */...

    (JAVA NetBeans) Write programs in java Example 10.21-24 //Animal.java /** Animal class * Anderson. Franceschi */ import java.awt.Graphics; public abstract class Animal { private int x; // x position private int y; // y position private String ID; // animal ID /** default constructor * Sets ID to empty String */ public Animal( ) { ID = ""; } /** Constructor * @param rID Animal ID * @param rX x position * @param rY y position */ public Animal( String...

  • **JAVA*JAVA Question 1 How many k's values will be printed out? public static void main(Stringl args)...

    **JAVA*JAVA Question 1 How many k's values will be printed out? public static void main(Stringl args) for (int k-1: k10:k if (k8) continue: System.out.println k) Question 2 3.5 pts Analyze the following code. Which one is correct? package p public class A package p2: import p1. public class B extends Af int i- 5 private int j- 10: public A0I public static void main(Stringll args) B b new B0: System.out.println(a.i+", "+ajt", "+b.it""+bj): a.i is printable None of them b.i is...

  • Java Inner class class Outer {    private int x=10;    private static int y=20 ;...

    Java Inner class class Outer {    private int x=10;    private static int y=20 ;    publics void M1( ) {          int z=30;        class Inner           {             public void M2()              {                                                                              Sytem.out.println(“sum: ”+ (x+y+z));               }         } Inner i=new Inner();    i.M2() ; /// first call    i.M2(); // second call i.M2(); // third call }   // end of M1        publics static void main(String[] args)       {           Outer O = new...

  • What is the final value of the count field? public class Person { private String name;...

    What is the final value of the count field? public class Person { private String name; private int age; private static int count=0; public Person(String name, int age) { this.name = name; this.age age; count++; } public static void main(String[] args) { Person a - new Person("John Doe". 35): Person b new Person("Jane Doe", 38): for(int i=0;i<5;i++) Person tempa

  • JAVA 1.            Given the following class definition, what are the contents of the fields x and...

    JAVA 1.            Given the following class definition, what are the contents of the fields x and y of the object p ?    class MyPoint {      int x;      int y; public MyPoint (int x, int y){        x = x;        y = y;      } --------------------------------------- MyPoint p = new MyPoint( 100, 88 ); 2.            static and non-static members What would happen if you tried to compile and run the following code ? public class Driver {...

  • please evaluate the following code. this is JAVA a. class Car { public int i =...

    please evaluate the following code. this is JAVA a. class Car { public int i = 3; public Car(int i) { this.i = i; } } ... Car x = new Car(7), y = new Car(5); x = y; y.i = 9; System.out.println(x.i); b. class Driver { public static void main(String[] args) { int[] x = {5, 2, 3, 6, 5}; int n = x.length; for (int j = n-2; j > 0; j--) x[j] = x[j-1]; for (int j...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT