Out: Saturday, 29 January
Due: Friday, 4 February
Turnin: Gradescope
This Java program is expected to print (10.0,20.0) when run:
public class Animal {
protected double xPosition;
protected double yPosition;
public Animal() { xPosition=0.0; yPosition=0.0; }
public void MoveTo(float xNew, float yNew) { SwimTo(xNew, yNew); }
public void PrintPosition() { System.out.println("("+xPostion+", "+yPosition+")"); }
public static void main(String[] args) {
Fish f = new Fish();
f.MoveTo(10, 20);
f.PrintPosition();
}
}
public class Fish extends Animal {
public Fish() {}
public void SwimTo(double xNew, double yNew) { xPosition = xNew; yPosition = yNew; }
}
However, it doesn't even compile.
Based on that, is Java statically typed or dynamically typed? Briefly explain, using the specific example of the sample code having an error during compilation.
Draw a boolean circuit that evaluates this function, using only and, or, and not gates:
| A | B | C | Output |
| 0 | 0 | 0 | 1 |
| 0 | 0 | 1 | 0 |
| 0 | 1 | 0 | 0 |
| 0 | 1 | 1 | 1 |
| 1 | 0 | 0 | 0 |
| 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 1 |
| 1 | 1 | 1 | 0 |
(A) What is the function evaluated at B by this circuit? Give a truth table as your answer.
(B) Give a high level, English description of the meaning of output B. What property of the inputs is true if output B is 1?
Turnin a pdf file with your answers on Canvas.