

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Solutions for a java quiz, including definitions of terms 'stack', 'heap', 'parameter/argument', and 'class/object'. It also includes instructions for creating and manipulating a 'dancer' object, and solving a comparison problem with strings.
Typology: Quizzes
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Name (printed):
Student ID #:
Section # (or TA’s: name and time)
(a) stack
(b) heap
(c) parameter/argument
(d) class/object
public class Dancer { public int height; public double weight;
public void spin(int count,String direction) { ... } }
(a) (2 points) Write a single statement that declares a Dancer variable and assigns to it a new Dancer object.
(b) (3 points) For the Dancer object created in part a, write statements that will set the height to 64 and the weight to 110.
(c) (3 points) Write a statement that will cause this same Dancer object to spin to the ”right” a total of 20 times by using the spin method.
String x = new String("dog"); String y = new String("dog"); String z = x;
if (x.equals(y)) { System.out.println("A"); } else { System.out.println("B"); } if (x == y) { System.out.println("C"); } else { System.out.println("D"); } if (z.equals(x)) { System.out.println("E"); } else { System.out.println("F"); } if (z == x) { System.out.println("G"); } else { System.out.println("H"); }