Worksheetsjava datatype
Total questions: 14
Worksheet time: 8mins
Which three are legal array declarations?
2, 3, 4
2, 4, 5
1, 2, 4
All are correct.
Which will legally declare, construct, and initialize an array?
int [] myList = {"1", "2", "3"};
int [] myList = (5, 8, 2);
int myList [] [] = {4,9,7,0};
int myList [] = {4, 3, 7};
Which four options describe the correct default values for array elements of the types indicated?
1, 2, 3, 4
1, 3, 4, 5
2, 4, 5, 6
3, 4, 5, 6
What is the numerical range of a char?
-128 to 127
-(215) to (215) - 1
0 to 32767
0 to 65535
What will be the output of the program?
small
huge
tiny
Compilation fails
Which expression evaluates to false?
15 % 3 < 2
3 * 3 % 2 <= 0
false == false
false == false == false == false
Which expression evaluates to true?
false == false
true != true
4 < 4
true == true != true
How would you declare a variable that tells you that someone passed a class?
boolean passed = 'true';
boolean passed = true;
passed = true;
String passed = "true";
How would you declare a variable storing the tax rate?
int taxRate = 5.1;
taxRate = "5.1";
double taxRate = 5.1;
double taxRate = "5.1";
What data type would you use for storing the number of students in a class?
boolean
String
double
int
Name the data type: '3'
int
char
String
None of the above
Which declaration with throw an error?
String name = "1 1233 141";
double num = 1;
int bigNumber = 1234567890;
char random = '7';
Which declaration will throw an error?
double num = 8;
int averageGrade = 89.7;
boolean done = false;
String done = "true";
What prints out "I love Java" successfully?
System.out.println(I love Java);
Systemoutprintln("I love Java);
System.out.println("I love" + " Java");
System.out.println("I love Java")
