CMSC 131 Study Questions 2 Flashcards
When your Java program is compiled, what type of file is created? (Hint: It is NOT machine language.)
bytecode
What does it mean for someone to say that a Java program is “portable”?
The same bytecode will run successfully on any platform (provided that the Java Virtual Machine (JVM) is available.)
TRUE/FALSE: Inserting unnecessary spaces and/or blank lines could cause your Java program to malfunction.
FALSE
What is the difference between “syntax errors” and “logical errors”?
Syntax errors are due to your failure to follow the rules of the language. Logical errors are where you have written a valid Java program, but it does not behave the way it should.
If your program compiles and runs, but behaves incorrectly, are you probably suffering from “syntax” or “logical” errors?
logical
If Eclipse flags your code with a red mark and won’t let you compile it, are you suffering from “syntax” or “logical” errors?
syntax
List the four Java primitive types that can be used to store integer values.
long, int, short, byte
How much memory is required to store each of the four types mentioned in the previous question?
long 8, int 4, short 2, byte 1
What advantage do you gain from using one of the types of integer types that requires MORE memory?
You can store a wider range of values (larger values).
List the two Java primitive types that can be used to store floating point values.
float and double
How much memory is required to store each of the two types mentioned in the previous question?
float 4, double 8
What advantage do you gain from using one of the floating point types that requires MORE memory?
more precision (it will retain more digits)
List the two Java types that are used to store values that are not numbers.
char and boolean
Write a statement that declares a variable named counter of type int, and stores the value 182 in the variable.
int conter = 182;
Write a statement that simultaneously declares three variables of type boolean , named x, y, and z.
boolean x, y, z;