Question

In: Computer Science

1. If the 4-bit two's complement representations of integers J and K are 0100 and 1001,...

1. If the 4-bit two's complement representations of integers J and K are 0100 and 1001, respectively, then the decimal representation of integer (J - K) (K subtracted from J) is

  1. 11
  2. -2
  3. 2
  4. -3
  5. other (state the number)

2. The "correctness" core quality of software refers to the fact that ...

  1. programs efficiently support the insertion of new features, improvements, corrections
  2. programs answer to requested user actions within acceptable time delays.
  3. programs compile without any syntax errors.
  4. programs accurately meet the specifications of behaviour and required outputs

3. Running class TwoDSum, whose code is:

public class TwoDSum {
   public static void main(String[] args) {
      int[][] table = {-1,7,-3},{0,2,-4},{9,-6,5};
      int sum = 0;

      for (int i = 0; i < table.length; i++)
         if (i != table.length - i)
            sum += table[i][i] + table[table.length - i-1][i];

      System.out.println("Sum is " + sum);

   }
}

will display on the user console ...

  1. Sum is 14
  2. Sum is 20
  3. Sum is -2

4. The code of class Det below:

public class Det {
   public static void main(String[] args) {
      int[][] a = new int[2][];
      a[0] = new int[2];
      a[1] = new int[2];
      a[0][0] = 2;
      a[0][1] = 1;
      a[1][0] = 5;
      a[1][1] = 3;
      int det = a[0][0]*a[1][1] - a[0][1]*a[1][0];

      System.out.println("Determinant is " + det);
   }
}

will ...

  1. display "Determinant is 1" on the user console.
  2. issue a "missing ]" compilation error
  3. display "Determinant is 11" on the user console

5. Given the two code fragments A) an B), below, to compute the final value of a variable grandTotal, of type double and a 0 initial value:

A)

double delta = 0.1;

for (int i=0; i<10000; i++)

    grandTotal += delta;

B)

double delta = 0.001;

for (int i=0; i<1000000; i++)

    grandTotal += delta;

Then variable grandTotal is...

  1. Both code fragments, A and B, compute grandTotal without any round-off error
  2. Computed with less round-off error in code fragment A
  3. Computed with less round-off error in code fragment B

6. An interface...

  1. Cannot be extended.
  2. can be used as a type in the instantiation/declaration line of an anonymous class.
  3. Cannot be implemented by an abstract class.

Solutions

Expert Solution

Dear Student ,

As per the requirement submitted above , kindly find the below solution.

Question 3:

Answer :a.Sum is 14

Explanation :Below is the correct code and output on the console.

*******************************

Question 4:

Answer :a.display "Determinant is 1" on the user console.

Explanation :Line int det = a[0][0]*a[1][1] - a[0][1]*a[1][0]; will print 1 because 2*3-5*1=1.Below screen shows the output

*******************************

Question 5:

Answer :a.Both code fragments, A and B, compute grandTotal without any round-off error

Explanation :Below screen shows the output of both the code fragment

A.

B.

*******************************

Question 6:

Answer :a.Cannot be extended.

Explanation :An interface can only implemented can not be extended.

*******************************

NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.


Related Solutions

1. Add the following binary numbers in 4-bit, two's complement notation. Identify any overflow errors. 01102...
1. Add the following binary numbers in 4-bit, two's complement notation. Identify any overflow errors. 01102 + 01002 2.Add the following binary numbers in 4-bit, two's complement notation. Identify any overflow errors. 10102 + 11112 3.Add the following binary numbers in 4-bit, two's complement notation. Identify any overflow errors. 10112 + 01112
Write the MIPS assembly code that creates the 32-bit constant 0010 0000 0000 0001 0100 1001...
Write the MIPS assembly code that creates the 32-bit constant 0010 0000 0000 0001 0100 1001 0010 0100two and stores that value to register $t1, and print the value of $t1 to stdout in binary - i.e., as a 32 bit sequence of '1's and '0's (use the MIPS syscall functionality for I/O). Please don't answer if you don't know how to solve it, and don't just copy the previous answer.
Represent the following numbers in binary 8-bit representation using singed magnitude, one's complement, two's complement, and...
Represent the following numbers in binary 8-bit representation using singed magnitude, one's complement, two's complement, and excess-127 representations: a) 48 b) -35
Show the decimal integer -143 in 10-bit sign magnitude, one's complement, two's complement and excess-511 respectively...
Show the decimal integer -143 in 10-bit sign magnitude, one's complement, two's complement and excess-511 respectively in the given order
Show the decimal integer 79 in 8-bit sign magnitude, one's complement, two's complement and excess-127 respectively...
Show the decimal integer 79 in 8-bit sign magnitude, one's complement, two's complement and excess-127 respectively in the given order, separated by comma.
Show the decimal integer 44 in 7-bit sign magnitude, one's complement, two's complement and excess-63 respectively...
Show the decimal integer 44 in 7-bit sign magnitude, one's complement, two's complement and excess-63 respectively in the given order, separated by comma.
Show the decimal integer -126 in 8-bit sign magnitude, one's complement, two's complement and excess-127 respectively...
Show the decimal integer -126 in 8-bit sign magnitude, one's complement, two's complement and excess-127 respectively in the given order, separated by comma.
Find the decimal equivalents for the following 8-bit two’s complement numbers. a. 0010 0100 Decimal Equivalent...
Find the decimal equivalents for the following 8-bit two’s complement numbers. a. 0010 0100 Decimal Equivalent ___________ b. 1010 1001 Decimal Equivalent ___________ c. 1100 0011 Decimal Equivalent ___________ d. 0101 0101 Decimal Equivalent ___________
2) Show how each of the following signed, decimal integers would be stored in 16-bit two's...
2) Show how each of the following signed, decimal integers would be stored in 16-bit two's complement format. Give your answer in hexadecimal. a) -21 (5 points) b) 4096 (5 points)
(16) Convert the following numbers into 8-bit hexadecimal values. Number Binary Complemented Two's Complement Hex -102...
(16) Convert the following numbers into 8-bit hexadecimal values. Number Binary Complemented Two's Complement Hex -102 -87 -31 (17) Add up the first two binary numbers from the previous problem in Two’s complement form.   (17a) What is the sum in hex? (17b) What is the sign bit? (17c) Did overflow occur? (17d) Code this up in 68K and include a screenshot of the output here as well as your source & listing files. What happens? Please show work! If you...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT