Chapter 2: Built in Data Types for Programming.
A Java char is _____ bits in size. 8 32 16 64
A char is 16 bits. A char is 16 bits. A char is 16 bits. A char is 16 bits. A char is 16 bits.
Java constants are usually named with upper case letters with an underscore between words. However, which of the following would also compile as the name for a constant? 1. ifElse 2. If 3. Last Name 4. If Else
ifElse. ifElse. ifElse. ifElse. ifElse. ifElse. ifElse.
The relational operators || and && (OR and AND) are called _____ operators 1. Boolean 2. Empty 3. Divisional 4. Binary
Boolean. Boolean. Boolean. Boolean. Boolean. Boolean because they test for a true/false condition. Boolean because they test for a true/false condition. Boolean because they test for a true/false condition. Boolean because they test for a true/false condition.
Which of the following is included in a Java API? 1. JavaScript plug-ins 2. Encryption 3. Classes and methods 4. USB Connector
Classes and methods are included in the Java API. Classes and methods are included in the Java API. Classes and methods are included in the Java API. Classes and methods are included in the Java API. Classes and methods are included in the Java API.
Which of the following is true about constant naming conventions in Java? a. Constants can have spaces in the names b. Constants can be any Java keyword c. Constants should be upper case with an underscore separating the words d. Constants cannot be represented by lower case
Constants should be upper case with an underscore separating the words. Constants should be upper case with an underscore separating the words. Constants should be upper case with an underscore separating the words.
Which data type is 1-bit in size? 1. long 2. boolean 3. short 4. char
Data type boolean is 1-bit in size. Data type boolean is 1-bit in size. Data type boolean is 1-bit in size. Data type boolean is 1-bit in size. Data type boolean is 1-bit in size. Data type boolean is 1-bit in size.
The Java Boolean data type is a/an _____ data type. a. Native b. Primitive c. Inherited d. Float
In Java, the Boolean data type is a primitive data type. In Java, the Boolean data type is a primitive data type. In Java, the Boolean data type is a primitive data type. In Java, the Boolean data type is a primitive data type. In Java, the Boolean data type is a primitive data type. In Java, the Boolean data type is a primitive data type.
Which data type is NOT an example of a primitive data type? a. int b. interface c. boolean d. char
Interface is a non-primitive data type, along with class and array. Interface is a non-primitive data type, along with class and array. Interface is a non-primitive data type, along with class and array. Interface. Interface. Interface.
Will the following code work? char myChar = 'ABC'; 1. Yes, but with AB. 2. Yes, myChar will display ABC. 3. No, you can only store one literal character in a char. 4. Yes, but only A.
No, you can only store one literal character in a char. No, you can only store one literal character in a char.
Examine the following code. What will the output of str3 be? String str1 = new String("Join us at 6"); String str2 = new String("for Happy Hour"); String str3 = str1 + str2; 1. Join us at 6 2. Join us at 6 for Happy Hour! 3. Join us at 6for Happy Hour! 4. Nothing, the compiler will error
Join us at 6for Happy Hour! Join us at 6for Happy Hour! Join us at 6for Happy Hour! Join us at 6for Happy Hour!
The values allowed for the boolean type are true and false, and they are _____. 1. Doubles 2. Variables 3. Keywords 4. Integers
Keywords. Keywords. Keywords. Keywords. Keywords. keywords that are reserved by the programming language. keywords that are reserved by the programming language. keywords that are reserved by the programming language.
Examine the following code. The programmer is not getting the same value for myNumber and myNumber2. Why? double myNumber = (20 - 10 /3); double myNumber2 = ((20 - 10) /3); 1. The compiler is broken 2. The numbers should be floats 3. The numbers should be integers 4. The order of operations is different in each
The order of operations is different in each. The order of operations is different in each. The order of operations is different in each. The order of operations is different in each. parentheses is the current issue.
What is the value of myNumber in the following code? int myNumber; a. -1 b. 0 c. NULL d. Undefined
Zero. Zero. Zero. Zero. Zero. Zero. Zero. Zero. Remember that the default value for short, int, or long is 0. Remember that the default value for short, int, or long is 0.
To move the contents of a variable declared as data type float into a variable declared as data type long requires the use of _____. 1. a comment 2. a type cast 3. a fraction 4. an implicit conversion
a type cast. a type cast. a type cast. a type cast. a type cast.
What kind of data type will you use for an object 'Pen'? 1. long 2. class 3. char 4. int
class. class. class. class. class. class. class. class. class is a user-defined data type. class is a user-defined data type. class is a user-defined data type. class is a user-defined data type.
Java will _____ move a value stored in a short data type into a variable declared as int. 1. explicitly 2. casually 3. never 4. implicitly
implicitly . implicitly . implicitly . implicitly . implicitly . Java will implicitly i.e., automatically move the value from a 16-bit short into a 32-bit int because there's no possible loss of information moving into a wider data type.
Which of the following correctly imports only the FileFilter interface of the java.io API? a. import java.FileFilter.*; b. import java.*.FileFilter; c. import java.io.*; d. import java.io.FileFilter;
import java.io.FileFilter; import java.io.FileFilter; java.io API package. java.io API package. java.io API package. java.io API package.
If you need to save a long (longnum) to an int (intnum), which of the following would be used? longnum1 = intnum; long intnum = longnum; intnum = (int)longnum; intnum = longnum;
intnum = (int)longnum;
Examine the following code. What relational operator is being used? while (currencyConversion != 1000) { //code here } a. OR b. Less than c. Not equal to d. Equal to
relational operator is Not Equal To. relational operator is Not Equal To. relational operator is Not Equal To. relational operator is Not Equal To. relational operator is Not Equal To.
What are these two symbols for: / and %. 1. Division and Remainder 2. Division and Modulo 3. Division and Square Root 4. Division and Pi
the forward slash, is used for division. The second symbol is the modulo operator. the forward slash, is used for division. The second symbol is the modulo operator. the forward slash, is used for division. The second symbol is the modulo operator.
Which of the following is an example of a floating point data type in Java? 1. x = 2.3; 2. x = -0.1; 3. x = -4.56899f; 4. x = 4/0;
x = -4.56899f; x = -4.56899f; Floating point data types in Java are represented by appending the letter f to the end of the decimal. Floating point data types in Java are represented by appending the letter f to the end of the decimal.
Which of the following is a double in Java? x = 5f; x = 1.234567891234567; x = 0. 0.12345f; x = 0.123456789123456789123;
x = 1.234567891234567; x = 1.234567891234567; A double in Java can store a maximum of 16 digits after the decimal. A double in Java can store a maximum of 16 digits after the decimal. A double in Java can store a maximum of 16 digits after the decimal.