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.
QUESTION 7 10 points Save Answer Given is a java class 'lustrate'. 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 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 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 // 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 */ 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) 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 ; 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; 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 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 = 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...