Ch 6 & 7 Quiz 4 Flashcards
Study #2
2
T/F: the interface of a class describes what a class does and how it can be used by showing the implementation
F: the interface of a class describes what a class does and how it can be used without showing the implementation
The word interface in Java can be used as___
Class interface
Graphical User Interface
Method interface
Language construct
Study #6
Study #6
Question 7
Q 7
T/F: an object is said to be immutable if it’s contents or state cannot be changed once it has been created. Strings are an example of immutable objects.
T
Will this code compile and if not what line would cause the error?
…
String userAnswer = reader.getInput().trim().toLowerCase();
String rightAnswer = “java is democratic” + 3;
int calcResult = 5 + 1;
int rightResult = 5;
if (calcResult == rightResult && userAnswer == rightAnswer)
{
System.out.println(“Maybe you are right”)
}
…
Code will compile because the syntax is correct
Auto-boxing
Where the compiler take the decision to convert a primitive value (ex: int) into an object of its wrapper class (ex: Integer)
Study #12
Auto-unboxing
Where the compiler take a decision to covert an object of a wrapper class (ex: Integer) into its primitive value (ex: int)
Study #12
javadoc comment
The comment start symbol must have 2 asterisks.
/**
This is a javadoc comment
*/
Study 15
Study 15
T/F: The following code will compile correctly:
…
public class MyVote
{
private static int voteResult = 0;
private int voteID = 0;
private static final int voteTruth = voteResult + voteID;
}
F: static variable can’t refer to non-static variable. voteTruth (static variable) is referring to voteID (non-static)
17
17
Study #20
20