1. Name the Four (Eight) Primitive Types in Java

1. Name the Four (Eight) Primitive Types in Java

Anna Chesson C-212 Homework 6

1. Name the four (eight) primitive types in Java : int, short, long, double, float, boolean, char, byte

2. The output of this program would be false. The reason is because the operator “==” performs a check and returns a Boolean value. If you call it with two of the same arguments (tomato tomato) it will return false also because == compares two objects. The strings tomato and tomato look the same but they are not actually the same object. By using the .equals method you could check if they are equal to the eye. 3. There is only 1, private char[][] board; 4. There are 3 static variables, 2 instance methods, and 1 static method. 5. The program does not compile because math random returns a decimal (double) value, and thus math floor operating on the decimal value also returns a double, and in the instance variables of diceOne and diceTwo we defined them to be ints. 6. Math.floor always returns a double 7. (int)(Math.random() * 100) – 50. This converts the math.random value to an integer 8. public boolean sorted(int[] arr) { for(int i = 0; i < arr.length – 1; i++) { if(i = arr.length – 1) { return true; } if(arr[i]

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    1 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us