Quiz
Starter Test Rough Spots
This quiz has question types that open in the usual player.
Questions in this quiz (44)
1You can change 'this' in classes
[EX: this = new Class();]- ATrue
- BFalse
2Select the correct methods/constructors for Random + correct explanations for each
- ARandom() creates a new random number generator that has no seed
- BRandom(long num) creates a new random number generator with num as its seed
- CRandom(long num) creates a new random number generator with 0 as its lower bound [inclusive] and num as its upper bound [exclusive] for range
- DRandom(long num1, long num2) creates a new random number generator with num1 as its lower bound [inclusive] and num2 as its upper bound [exclusive] for range
- EsetSeed(long num) is needed to set the seed of a Random object
- FRandom() creates a new random number generator that has the current system time as the seed
- GWe get a randomly generated int by calling nextInt() on a Random object
- HWe get a randomly generated number by calling generate() on a Random object
- InextInt(int num) returns a random number between 0 [inclusive] and num [exclusive]
- Jgenerate(int num) returns a random number between 0 [inclusive] and num [exclusive]
3Methods and variables can have the same name as the class they're in
- ATrue
- BFalse
4Select the valid null reference declaration
- AFile f = null;
- BDate d(null);
- CObject obj = NULL;
- DString str : null;
5Java will define a default constructor for every class, even if it already has a parameterized constructor
- ATrue
- BFalse
6Java will construct a default constructor ONLY if the class doesn't define any explicitly
- ATrue
- BFalse
7What will happen if we try to run the following for loop?
for (int i=0; ; i++) break;- AThe loop runs once and stops due to the break statement. i will not increment, as the break statement is before it could.
- BThe code will fail to compile
- CThe loop runs once and stops due to the break statement. i will increment, as i++ is called before break
8What is the default access modifier for methods and variables?
- Apackage-private
- Bprivate
- Cprotected
- Dpublic
9What does the package-private access modifier do?
- AClasses in the same package can access that method/variable
- BOnly the class itself can access that method/variable
- CClasses in the same folder can access that method/variable
10Main can return something other than void
- ATrue
- BFalse
11Main can take in something other than a String array
- ATrue
- BFalse
12What does the break statement do when within a switch statement or loop?
- ACompletely ends running through the switch/loop
- BSkips the rest of the code in that iteration/section to go to the next iteration/section
13What does the continue statement do when within a switch statement?
- ACompletely ends running through the switch/loop
- BSkips the rest of the code in that iteration/section to go to the next iteration/section
- CContinue can't be used in a switch statement
14What does the continue statement do when within a loop?
- ACompletely ends running through the loop
- BSkips the rest of the code in that iteration to start the next iteration
15Fill in the following switch statement
int num = 1;
switch ([blank_start]num[blank_end]) {
[blank_start]case 1[blank_end]:
System.out.println("1");
[blank_start]break[blank_end];
[blank_start]case 2[blank_end]:
System.out.println("2");
[blank_start]break[blank_end];
[blank_start]default[blank_end]:
System.out.println("Neither 1 or 2");
}- Anum
- Bcase 1
- Cbreak
- Dcase 2
- Ebreak
- Fdefault
16You can use labels outside of loops/switch statements
- ATrue
- BFalse
17You can use labels with break outside of loops/switch statements
- ATrue
- BFalse
18You can use labels with continue outside of loops/switch statements
- ATrue
- BFalse
19Select the correct range for ints
- A4 bytes, signed (two's complement). -2,147,483,648 to 2,147,483,647.
- B8 bytes signed (two's complement). Ranges from -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807.
- C2 bytes, signed (two's complement), -32,768 to 32,767
- D1 signed byte (two's complement). Covers values from -128 to 127.
- E4 bytes, IEEE 754. Covers a range from 1.40129846432481707e-45 to 3.40282346638528860e+38 (positive or negative).
- F8 bytes IEEE 754. Covers a range from 4.94065645841246544e-324d to 1.79769313486231570e+308d (positive or negative).
- G2 bytes, unsigned, Unicode, 0 to 65,535
20Select the correct range for longs
- A4 bytes, signed (two's complement). -2,147,483,648 to 2,147,483,647.
- B8 bytes signed (two's complement). Ranges from -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807.
- C2 bytes, signed (two's complement), -32,768 to 32,767
- D1 signed byte (two's complement). Covers values from -128 to 127.
- E4 bytes, IEEE 754. Covers a range from 1.40129846432481707e-45 to 3.40282346638528860e+38 (positive or negative).
- F8 bytes IEEE 754. Covers a range from 4.94065645841246544e-324d to 1.79769313486231570e+308d (positive or negative).
- G2 bytes, unsigned, Unicode, 0 to 65,535
21Select the correct range for shorts
- A4 bytes, signed (two's complement). -2,147,483,648 to 2,147,483,647.
- B8 bytes signed (two's complement). Ranges from -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807.
- C2 bytes, signed (two's complement), -32,768 to 32,767
- D1 signed byte (two's complement). Covers values from -128 to 127.
- E4 bytes, IEEE 754. Covers a range from 1.40129846432481707e-45 to 3.40282346638528860e+38 (positive or negative).
- F8 bytes IEEE 754. Covers a range from 4.94065645841246544e-324d to 1.79769313486231570e+308d (positive or negative).
- G2 bytes, unsigned, Unicode, 0 to 65,535
22Select the correct range for bytes
- A4 bytes, signed (two's complement). -2,147,483,648 to 2,147,483,647.
- B8 bytes signed (two's complement). Ranges from -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807.
- C2 bytes, signed (two's complement), -32,768 to 32,767
- D1 signed byte (two's complement). Covers values from -128 to 127.
- E4 bytes, IEEE 754. Covers a range from 1.40129846432481707e-45 to 3.40282346638528860e+38 (positive or negative).
- F8 bytes IEEE 754. Covers a range from 4.94065645841246544e-324d to 1.79769313486231570e+308d (positive or negative).
- G2 bytes, unsigned, Unicode, 0 to 65,535
23Select the correct range for floats
- A4 bytes, signed (two's complement). -2,147,483,648 to 2,147,483,647.
- B8 bytes signed (two's complement). Ranges from -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807.
- C2 bytes, signed (two's complement), -32,768 to 32,767
- D1 signed byte (two's complement). Covers values from -128 to 127.
- E4 bytes, IEEE 754. Covers a range from 1.40129846432481707e-45 to 3.40282346638528860e+38 (positive or negative).
- F8 bytes IEEE 754. Covers a range from 4.94065645841246544e-324d to 1.79769313486231570e+308d (positive or negative).
- G2 bytes, unsigned, Unicode, 0 to 65,535
24Select the correct range for doubles
- A4 bytes, signed (two's complement). -2,147,483,648 to 2,147,483,647.
- B8 bytes signed (two's complement). Ranges from -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807.
- C2 bytes, signed (two's complement), -32,768 to 32,767
- D1 signed byte (two's complement). Covers values from -128 to 127.
- E4 bytes, IEEE 754. Covers a range from 1.40129846432481707e-45 to 3.40282346638528860e+38 (positive or negative).
- F8 bytes IEEE 754. Covers a range from 4.94065645841246544e-324d to 1.79769313486231570e+308d (positive or negative).
- G2 bytes, unsigned, Unicode, 0 to 65,535
25Select the correct range for chars
- A4 bytes, signed (two's complement). -2,147,483,648 to 2,147,483,647.
- B8 bytes signed (two's complement). Ranges from -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807.
- C2 bytes, signed (two's complement), -32,768 to 32,767
- D1 signed byte (two's complement). Covers values from -128 to 127.
- E4 bytes, IEEE 754. Covers a range from 1.40129846432481707e-45 to 3.40282346638528860e+38 (positive or negative).
- F8 bytes IEEE 754. Covers a range from 4.94065645841246544e-324d to 1.79769313486231570e+308d (positive or negative).
- G2 bytes, unsigned, Unicode, 0 to 65,535
26The following will throw a NullPointerException
static int num;
int x = num;- ATrue
- BFalse
27The following will throw a NullPointerException. [Note: num is a local variable]
int num;
int x = num;- ATrue
- BFalse
28The following will throw a NullPointerException. [Note: num is an instance variable]
static int num;
int x = num;- ATrue
- BFalse
29ALL primitive variables are initialized to their equivalent to 0 when they aren't explicitly initialized
- ATrue
- BFalse
30All instance/static primitive variables are initialized to their equivalent of 0 when they aren't explicitly initialized
- ATrue
- BFalse
31What is an instance variable?
- AThe variables declared within a class to be part of an instance of a class, but outside of a method
- BThe variables declared within methods
32Static methods can refer to non-static variables
- ATrue
- BFalse
33Instance variables can be static
- ATrue
- BFalse
34Select the example of method overloading that will compile
- Avoid perform_work(int time){ }
int perform_work(int time, int speed){ return time*speed ;} - Bvoid perform_work(int time){ }
int perform_work(int speed){return speed ;} - Cvoid perform_work(int time){ }
void Perform_work(int time){ }
- Avoid perform_work(int time){ }
35Java allows arrays of length 0 to be created
- ATrue
- BFalse
36Order the try catch block correctly
[blank_start]try[blank_end] {}
[blank_start]catch(e)[blank_end] {}
[blank_start]finally[blank_end] {}- Atry
- Bcatch(e)
- Cfinally
37What will happen when running the following code?
int i = 5;
float f = 5.5f;
if (i ==f) {//}- AThe code will fail to compile
- Bi will be cast to a float for comparison
- Cf will be cast to an int for comparison
38What is wrong with this code?
import java.util.*;
package test;
public class TestClass {
public OtherClass oc = new OtherClass();
}
class OtherClass {
int value;
}- AThe package declaration comes after the import statement
- BTestClass and OtherClass are in the same file
- COtherClass is used before it's defined
39OCL is looking for best-fit answers, not what is *technically* correct
- ATrue
- BFalse
40The following code will compile
boolean bool;
if (bool = false) {}- ATrue
- BFalse
41Convert the following code into ternary operator format:
int time = 20;
if (time < 18) {
System.out.println("Good day.");
} else {
System.out.println("Good evening.");
}
Ternary operator format:
int time = 20;
String result = [blank_start](time < 18)[blank_end] [blank_start]?[blank_end] [blank_start]"Good day."[blank_end] [blank_start]:[blank_end] [blank_start]"Good evening."[blank_end];
System.out.println(result);- A(time < 18)
- B?
- C"Good day."
- D:
- E"Good evening."
42The following code will compile:
int x = 0;
if (x == 10 ? true:false) {}- ATrue
- BFalse
43Select the examples of char literals
- A'a'
- B"a"
- C'\n'
- D'\uDEAF'
- E/a/
44The following code will compile:
if ((a + b)++ > 1) {} //assume a and b are ints that have been declared- ATrue
- BFalse
Information
- Description
- Full Stack Development OCL Java 8 Foundations Exam Quiz on Starter Test Rough Spots, created by myc elium on 30/11/2025.
- Author
- myc elium
- Language
- English
- Views
- 5
- Tags
- Rating
- No ratings yet Rate this quiz