Convert 32 to binary
100000
String s = "hello";
System.out.println(s.charAt(0));
What will print?
h
To access the first element of an array use this command.
array[0]
What does this statement evaluate to?
!(true && false) || ((false || false) && true)
true
What type of error prevents the code from compiling?
Syntax Error
Convert 10011001 to decimal
153
How do we find out how long a String variable called word is?
word.length()
An array of length 7 would have positions for elements up to #_.
6
When will this statement evaluate to true?
!B && A
When A is true and B is false
What type of error prevents the code from running successfully?
Runtime Error
Convert 26 to hexadecimal
1A
If we wanted to separate only the first three characters from String word for some coding purpose, we could call:
To find out how many elements are contained in an array, we call
array.length
!(a <= b) && (a * b > 0)
This statement will always evaluate to true if what condition is also true?
A) a = b
B) a > b
C) a < b
D) a > b and b > 0
E) a > b and b < 0
a > b and b > 0
What type of error results in unexpected or incorrect output?
Logic Error
There are 10 types of people in the world. Those who understand binary and ???
those who don't.
Consider this code:
String x = "abcdefg";
int y = x.indexOf(d);
What is the value of y?
3
To access the last element of an array without knowing how many elements are in an array, we would call
array[array.length - 1]
If boolean variables A,B, and C are all true, what will this statment evaluate to?
!(!A && !B && !C)
true
What type of error is shown here:
String[] array = {"hi", "hey there", "hello"};
array[3] = "salutations";
Runtime Error
Convert 8D to binary
10001101
Consider this code:
String x = "hello";
String y = new String("hello");
boolean z = x == y;
What is the value of z?
false
To access the second to last element of an array without knowing how many elements are in an array, we would call
array[array.length - 2]
Create a truth table for the following statement:
(A && !B) || C
What type of error is shown below (Disregard any unintialized variables)?
int n = kb.nextInt();
while(n >= 0){
System.out.println("That's a nonnegative number!");
}
Logic Error