

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!


The first quiz for the course will be on Friday, June 8. The following list provides more information about the quiz:
The following exercises cover the material to be included in this quiz. Solutions to these exercises will not be provided, but you are welcome to discuss your solutions with the TA or instructor during office hours. We strongly recommend you DO NOT use Eclipse to write the code associated with these exercises. Try to answer the exercises in a piece of paper and then use Eclipse to verify your solutions. This approach will better prepare you for the quiz.
General Questions
final static int SIZE = 10;
final int SIZE = 10;
int y = 4; int z = ( y < 10? (y > 2? 1 : 2 ) : 3 );
try { String x = null; System.out.println( x.length() ); } catch ( NullPointerException e ) { System.out.println( "Null Exception" ); } catch ( Exception e ) { System.out.println( "Exception" ); } System.out.println( "Why are we here?" );
Code Analysis
You be the compiler. All these following classes appear in the same package. For each statement of the main program, indicate whether it generates a compilation error, and if not, what is printed. (When showing the execution, assume that all statements generating compilation errors have been removed.)
// in file Foo.java public class Foo { protected void pro( int x ) { System.out.println("Foo:pro:" + x); } public void pub( int x ) { System.out.println("Foo:pub:" + x); }
}
// in file Bar.java public class Bar extends Foo { protected void pro( int x ) { System.out.println("Bar:pro:" + x); } public void pub( int x ) { System.out.println("Bar:pub:int:" + x); } public void pub( double d ) { System.out.println("Bar:pub:dbl:" + d); } }
// in file Driver.java public static void main(String[] args) { Foo a = new Foo( ); Foo b = new Bar( ); Bar c = new Bar( ); a.pro( 1 ); a.pub( 2 ); a.pub( 3.0 ); b.pro( 4 ); b.pub( 5 ); b.pub( 6.0 ); c.pro( 7 ); c.pub( 8 ); c.pub( 9.0 ); }
Implementation
public static double[][] duplicate(double[][] array);
array[i][0] < array[i][1] < array[i][2] < ...
If such a row exists, a copy of the contents of that row is returned as a one dimensional array. Otherwise null is returned. The signature of the method is:
public static double[] firstIncreasing(double[][] array);