GIAC
GSSP-JAVA · Question #158
Mary works as a Software Developer for XYZ Inc. She writes the following code. 1. class Alpha { 2. public static class Beta { } 3. } 4. class Delta { 5. // insert code here 6. } Which of the…
The correct answer is D. The class Beta cannot be instantiated at line 5. See the full explanation below for the reasoning.
Question
Mary works as a Software Developer for XYZ Inc. She writes the following code. 1. class Alpha { 2. public static class Beta { } 3. } 4. class Delta { 5. // insert code here 6. } Which of the following code statements can be inserted at line 5 to create an instance of the Beta class defined in the class Alpha?
Options
- ABeta b = new Beta();
- BAlpha a = new Alpha();
- CBeta = new a.Beta();
- DThe class Beta cannot be instantiated at line 5.
- EAlpha.Beta b = new Alpha.Beta();
How the community answered
(22 responses)- A9% (2)
- C5% (1)
- D82% (18)
- E5% (1)
Community Discussion
No community discussion yet for this question.