# sp08M1 - Points off 1 2 3 4 5 Total off Net Score CS 307...

This preview shows pages 1–4. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
CS 307 – Midterm 1 – Spring 2008 2 C. Consider the following method. public int process(int[] data, int m1, int m2){ int t = 0; for(int i = 0; i < data.length; i++){ if( data[i] < m1 || data[i] > m2 ){ t++; } } return t; } What is printed out by the following code? int[] list = {5, 8, 13, 10, -5, 0, 9, 7, 12}; System.out.println( process(list, 3, 10) ); D. This question uses the method named process from part C. What is the output of the following code? int[] list2 = null; System.out.println( process(list2, 0, 12) ); E. Consider the following method. public void manip(int[][] mat){ for(int i = 0; i < mat[0].length; i++){ for(int j = i + 1; j < mat.length; j++){ mat[j][i] += mat[j - 1][i]; } } } Consider the following code. int[][] cells = {{1, 2, 3}, {-4, 5, 7}, {2, 5, 4}}; manip( cells ); What are the contents of the 2d array of ints named cells after the code above completes?
CS 307 – Midterm 1 – Spring 2008 3 For questions F – M consider the following classes. public class School{ private int numStudents; public School(int numStudents){ this.numStudents = numStudents; } public int getSize(){ return numStudents; } public String toString(){ return "Size: " + this.numStudents; } public void graduate(){ this.numStudents -= this.numStudents / 4; } } public class HighSchool extends School{ private String classification; public HighSchool(int numStudents, String classification){ super( numStudents ); assert validClassification( classification ); this.classification = classification; } public String toString(){ return "class: " + this.classification; } public static boolean validClassification(String s){

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 11/30/2010 for the course CS 307 taught by Professor Scott during the Spring '08 term at University of Texas at Austin.

### Page1 / 21

sp08M1 - Points off 1 2 3 4 5 Total off Net Score CS 307...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online