

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
A quiz question for a computer science student in a cse 11 course, focusing on completing the point class definition and understanding array index out of bounds exceptions. It includes instructions for filling in the blanks of the point class, writing a java statement to change the first point's x value to the last point's y value without using extra variables, and identifying the exception that would be thrown if we tried to access points[55]. Additionally, it covers the implicit parts of a java class definition as an example.
Typology: Exercises
1 / 2
This page cannot be seen from the preview
Don't miss anything!


public class Point { private int x; private int y;
public Point( int x, int y ) { setX( x ); setY( y ); }
public int getX() { ____________________________; }
public int getY() { ____________________________; }
public void setX( int x ) { ___________________________; }
public void setY( int y ) { ___________________________; } }
Point[] points = new Point[10];
// Assume array points is properly and fully initialized here
public class Quiz { private int q5 = 5; }
public class Foo { public Foo() { System.out.println( "Foo ctor #1" ); }
public Foo( int x, int y ) { System.out.println( "Foo ctor #2" ); }
public String toString() { System.out.println( "Foo.toString" ); return "Foo.toString"; } }
public class Fubar extends Foo { public Fubar( int x, int y ) { this( x, y, -99 ); System.out.println( "Fubar ctor #1" ); }
public Fubar( int x, int y, int z ) { super( x, y ); System.out.println( "Fubar ctor #2" ); }
public String toString() { System.out.println( "Fubar.toString" ); return super.toString() + " + " + "Fubar.toString"; } }
public class FubarTest { public static void main( String[] args ) { Foo ref = new Fubar( 5, 10 );
System.out.println( "-----" );
System.out.println( ref.toString() ); } }