Title: Data Types
Course: CPS 189: Java Certification - Review, Practice & Prepare (Development)

Q: A variable of type boolean can be explicitly converted to that of type int.
- True
- False
A: False

Q: In Java, Strings are immutable objects. Immutable objects can be changed.
- True
- False
A: False

Q: List the primitive data types Java supports. Indicate the kind of values each type can store.

Q: Objects of type String are strings of characters that are written within single quotes.
- True
- False
A: False

Q: What does the String method trim() do? Give an example of its use.

Q: What is the output of the following Java statements?
//String method examplesString str = "Java Programming!";
System.out.println(str.equals("Java Programming!"));
System.out.println(str.toLowerCase());
System.out.println(str.toUpperCase());
System.out.println(str.substring(5,8));
System.out.println(str.lastIndexOf("m"));

Q: What is the value of the variable c in the statements that follow?
String phrase = "Make hay while the sun is shining.";
char c = phrase.charAt(10);
- w
- h
- i
- None of the above
A: h

Q: Write a Java statement to access the 7th character in the String variable myString and place it in the char variable [c].
A: c = myString.charAt(6);

Q: Write a Java statement to determine the length of a string variable called input. Store the result in an integer variable called strLength. int strLength =
A: input.length();