True or false: A class provides a description of the layout of data values?
A class provides a description of how object actions are performed?
A class provides a description of how object actions are available?
Each object has its own copy of instance variables defined in the corresponding class?
A static method may access instance variables?
An instance method may access static variables
It is possible for two array variables to alias the same data
It is possible for two double variables to alias the same data
Why do we call a list an abstract data type whereas we call an array a data structure?
Question one prizes to be won all all three what is the output of all three. Show work.
Question 1:
trace and describe whats happening...
public class TestQuestionOne{
public static void main(String[]args){
int []data={5,2,6,1};
int y=17;
int z= y%10
int temp= testMethod(y,z,data);
for (int i=data.lenth; i>=0; i--)
System.out.print(data[i]+ "");
System.out.println(y+ ""+z++temp);
}
public static int testMethod(int x, int y, int a[]){
int temp=x;
for (int i=0; i<a.length; i++){
temp-= a[i];
}
x-=y;
y%= temp;
int [] data= new int[3];
data[1]=13;
a=data;
return y;
}
/////new question question 2 What is the output:
public class TestQuestionTwo{
public static double doesWhat(double x, int terms){
if (terms==0) return 0;
else if (terms ==1) return 1;
else if (terms ==2) return 1-x;
else return 1-z* doesWhat(x, terms/2);
}
public static void main(String[]args){
System.out.println(doesWhat (2,13)0;
}
}
Last question ! Extra prizes!
Consider the following rectangle class:
public class Rectangle {
private int x;
private int y;
private int width
private int height;
private Rectangle (int xPos, int yPos, int w, int h){
this.x = xPos; this.y=yPos; this.width=w; this.height=h;
public String toString{
String s="Rectangle Top left ("; s+- this.x + "," this.y +") Bottom Right =("; s += (this.x +this.width)+ "," (this.y+this.height)+ )"
public void move to (int newX, int newY){
this.x=newX; this.y= newY;
}
public boolean equals (Rectangle r)
{
**** create two rectangle objects
one starting at location (3,3) and has height 8 and width 2
the other starting at location (0,0) and has height 3 and width 2.
moves the second rectangle to location to (9,9)
Output each rectangle