CSE 410 22wi Homework 4
Compiling and Boolean Circuits

Out: Saturday, 29 January
Due: Friday, 4 February
Turnin: Gradescope

Question 1

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.

Question 2

Draw a boolean circuit that evaluates this function, using only and, or, and not gates:
ABCOutput
0001
0010
0100
0111
1000
1011
1101
1110

Question 3

(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

Turnin a pdf file with your answers on Canvas.