

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


This quiz is to be taken by yourself with closed books, closed notes, no calculators.
Write a method named dSum() that takes an array of doubles as a parameter and returns the sum of all elements in the array. Use the standard for loop; do not use the enhanced for/foreach loop. (I will ask you to use the enhanced for/foreach loop on the Final.)
Fill in the blanks to complete this method definition.
public _______________ dSum( __________________ array ) { ___________ sum = ____________;
for ( _________________; _____________________; _________________ ) { ______________________________________; }
return ________________; }
Fill in the blanks in the code to correctly produce the multiple array layout below:
int[][] a; a a = new int[___][];
a[] = new int[];
a[0] = new int[___];
a[___] = new int[4];
Write the assignment statement to set the array element marked by the X to the value 42.
(Over)
X
The Java keyword which denotes inheritance of implementation is _______________________.
The Java keyword which denotes inheritance of interface is _______________________.
_____________________ gives a "has a" relationship while _____________________ gives us an "is a" relationship.
The two main features of a constructor definition which distinguishes it from a method definition are:
In the last HW assignment with the Shapes hierarchy, indicate which statements are valid and which are invalid.
ARectangle ref1 = new Square( 100, 200, 50 );
Point p = ref1.getUpperLeft(); ____________
int length = ref1.getSide(); ____________
ref1 = new ARectangle( "Rectangle", 100, 200 ); ____________
In a toString() method defined in a subclass, how do you get the String representation of the superclass private parts assuming the superclass toString() is defined correctly and there are no non-private accessor methods?
In the equals() method, how do you check for exact type equality between this object and the object referenced by the parameter reference o?
if ( _______________________ ______ _______________________ ) { return false; }
Given the following class definition:
public class Quiz { private int q5 = 5; }
Write the equivalent class definition explicitly showing what the Java compiler implicitly inserts by default.