SJSU/Udacity CS046

Problem Set 8

  1. 2D Arrays
  2. Print 2D
  3. Fill 2D
  4. Class Design
  5. Static Method
  6. Manipulating Pictures
  7. Window Glass
  8. Robot

Class Design

When all the features of the public interface are relatedto the concept the class represents, we say the public interface is ______________. cohesive
When a class has no mutators, we say the class is __________________. immutable
Look at the code for a method getBalance of a BankAccount class. This method transfers $100 to my account before returning the balance.
public double getBalance()
{
    this.tranfer(kathleenAccount , 100);
    return this.balance;
}
This is an extreme example of a method that has adverse _____________ _______________, something the person calling the method did not expect and that you want to minimize.
side effect
A(n) ______________ method is not invoked on any object. static
Assume there is a class named Dinner that has a method with this header
public static double tip(double amount){...}
You are writing a program and want to call this method to calculate the tip on a meal costing $24.55. Complete the code below to accomplish this.
double tip = _______________________ ;
Dinner.tip(24.55)
You are writing a class SalesInvoice. It needs to have a double constant for a tax rate that can be accessed by the metods of any other class. Complete the code below to define such a constant.
___________________________ TAX_RATE = 0.085;
public static final double
Which twwo static variables of the System class have we used in this course? System.in and System.out
What is printed by this main method?
public static void main(String[] args)
{
    int x = 2;
    int y = 15;
    swap(x, y);
    System.out.println(x + " " + y);
}

public static void swap(int a, int b)
{
    int temp = a;
    a = b;
    b = temp;
}
12 5 Note that the values aren't swapped.

Problem on this page?

Your name:

Your email address:

Problem description:

To protect against spam robots, please answer this simple math problem:
× =