CSIS-1340 Data Types Quiz
Value: "My dog has fleas!"
string fleas; //creation of string sting = "My dog has fleas!"; //initialization of variable in string
A variable that has been declared to be boolean type can be initialized with the value 0.
False
Class type names always begin with a small letter in Java.
False
String is a primitive data type in Java.
False
The statement that identifies the data type of a variable is known as initializing the variable.
False
Value: new Keyboard( )
Keyboard key; //Initialization of keyboard key = new Keyboard(); //assigning variable to keyboard
All data types in Java can be classified as either a primitive type or a class type.
True
All variables must be declared BEFORE the variable can be used in the program.
True
Data types are used by the compiler to identify the amount of space in memory that a variable of that type will need.
True
Every variable in a Java program must be declared.
True
Keyboard is a class type in Java.
True
Variable names always begin with a small letter in Java.
True
Consider the following Java if-then-else expression: if ( !done && (a > ( 3 + b ) ) ) { x = "ABC"; y = (5 < b); } else { done = z; } Use the context in the above code to declare the data type of the following variables. int done; double a; int b; String x; boolean y; char z;
int done: boolean double a: double int b: int String X: String boolean y: boolean char z: boolean
In questions 11-15 I will show you a value. You must declare a variable with any name you choose. The data type (either primitive or class type) must be correct. In a separate statement, assign the variable with the value. For example, if I show the follwing: Value: -578
int n1; //Variable Declaration n1 = -578 //Variable assignment