{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# fa08M1 - 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 – Fall 2008 2 Questions C through F make use of the following methods. public int b(int x){ x *= 2; return x; } public int b(int x, int y){ x--; y++; return x * y; } public int c(int x){ x /= 2; return x; } C. What is output by the following client code? int x = 3; b(x); System.out.println(x); D. What is output by the following client code? int y = 3; int z = c( b(y, y) ); System.out.println(z); E. What is output by the following client code? int m = 4; int n = 3; int p = b(m) + b(n, m); System.out.println(p); F. What is output by the following client code? int[] list = {4, 2, 6}; list[0] = b(list[1], list[2]); list[1] = c(list[1]); System.out.println( Arrays.toString(list) ); // prints out elements
3 For questions G – O consider the following classes and interfaces. public interface Taxable{ public int rate(); } public abstract class Item implements Taxable{ private String unit; public Item(String s){ unit = s; } public String baseUnit(){ return unit; } public abstract int basePrice(); public int cost(){ int tax = (int)(basePrice() * (rate() / 100.0)); return basePrice() + tax; } public String toString(){ return "item"; } } public class Shoes extends Item{ private int price; private int taxRate; public Shoes(int p, int r){ super("pair"); price = p; taxRate = r; } public int basePrice(){

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.

{[ snackBarMessage ]}

### Page1 / 20

fa08M1 - 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