1. Define Primitive Data Type. List 4 primitive data types in Java.
2. Which takes up more memory, an int or a double?
3. Correct the following. Write no correction if the code is correct.
int val = 7.5;
double score = 89;
double avg = test1 + test2 /2;
4. What is output?
System.out.println("Answer = " + 67 + 3);
5. What characters do each of the following represent?
What characters are allowed in Java variable names?
You have two integer variables, minutes and hours. Minutes moves up by one. update hour and minutes?
minutes = minutes % 60;
minutes = minutes + hours % 60;
hours = hours + minutes / 60; minutes = minutes % 60;
hours = hours + minutes % 60; minutes = minutes / 60;
hours = hours + minutes / 60;
6%6 =
8%6 =
4%7 =
6%3 =
9%7 =
What is roundoff error?
Correct the following code so that it does not trigger roundoff error:
double val = scan.nextDouble();
System.out.println(val - 13.89);
11. When do you need to cast or when don't you? Give an example of each
need to cast
do not need to cast
12 Basic Demorgan's Law: What is
!( a || B),
!( X && Y),
!( c < d),
!( e>=f)
13 Use If/Else logic. Write the code to test if the int variable x has a value that is between 10 and 20 exclusive.
14. Basic binary conversion with numbers from 0-32 (no calculator needed)
1101 =
19 =