Practice Exam 1 + 2 - Sara's Errors Flashcards
T/F: The expressions 1.0/2, 1/2.0, and 1.0/2.0 each values to the value (1/2)
FALSE because 1.0/2, 1.0/2.0 (DOUBLES) and 1.0/2.0 each evaluates to the value (1/2) (INTERGERS)
T/F: Run-time errors are detected by the compiler
FALSE because run time errors only occur during running and happen if an unexpected value is entered
T/F: Identifiers are symbolic names for classes, methods, and data
TRUE: Identifiers (names) are symbolic names (representation) for classes, methods, and data
T/F: The clients of a class are programs that use it
TRUE
T/F: An object reference is a variable name for an object and points to the data of that object
TRUE: you’re referencing the data of that object
T/F: The data of a class consists of only static variables
FALSE: the data of a class doesn’t only have to be static variables.
T/F: Accessor methods are also called getter methods
TRUE
T/F: The garbage collector deletes objects thats have no object reference pointing to them.
TRUE: Removes it from runtime
T/F: Static methods of a class can be called without instantiating an object
TRUE: because the methods are static
T/F: The NumberFormat class provides static methods for creating objects to format numeric output such as percentage
TRUE: Number format is static –> don’t create an object to use it
T/F: The character wrapper class provides a method for testing whether a character is a digit
TRUE: Wrapper class (Full words like Character or Interger) provides support methods for primitive types
T/F: The character wrapper class provides a method for converting letters to lowercase
TRUE: It’s static
T/F: The expressions 1.0/2.0 (0.5) and 1/2 (0 remainder 1 but ignore the remainder) evaluate to the same value
FALSE: because the first one is a floating point division and the second is integer division.
T/F: Variables must be declared before they are used
TRUE
T/F: Java packages are groups of classes arranged according to functionality
TRUE: Related classes are grouped
T/F: Static methods of a class are also called the class methods
TRUE: because you don’t create an object to use those methods
T/F: The NumberFormat class provides static methods for creating objects to format numeric output such as currency
TRUE
T/F: The double wrapper class provides a method for converting between doubles and Strings
TRUE: Use double.tostring
T/F: A variable’s scope is the part of the program that has access to the variable
TRUE: because scope of that variable is where you can access the variable
A/B/C/D: Which of the following will correctly convert the data type, if x is an integer and y is a double?
a) x= y;
b) x = int y;
c) x = (int)y; –> has to have brackets to type cast
d) x = y;