Exam 1z0-808 All QuestionsBrowse all questions from this exam
Question 94

Given the code fragments:

Which modification enables the code to compile?

A.

B.

C.

D.

    Correct Answer:

    To compile the code provided, you need to ensure all classes are correctly imported in their respective packages. In `B.java`, `class B` needs to use `class A` from package `p1`, and in `C.java`, `class C` needs to use `class A` from package `p1` and `class B` from package `p1.p2`. Therefore, the correct modification to enable the code to compile is to replace: Line n1 in `B.java` with `import p1.A;` to import `class A`; Line n2 in `C.java` with `import p1.A; import p1.p2.B;` to import both `class A` from `p1` and `class B` from `p1.p2`.

Discussion
iSnover

The answer is the letter C. You don't need to explain much because the other alternatives are very wrong. But it's worth remembering that when we use * we import all the classes in the package but we don't import the classes of the sub-packages. Having this concept the others are wrong

Kolodets

good tip

ManuTov

I do not understand p1. p2.B ?? I only see p2.B or p2.*

dsms

correct answer A !!!!!! import p1.*; import p1.p2.*;

yanoolthecool

nah man, read it again, class C need 2 imports in answer A it only mentions 'import p1.p2.*;' in class C, which will give problem in detecting class A

7df49fb

C : A is needed in class B; A and B are needed in class C

DarGrin

Answer is C, agree

IbrahimAlnutayfi

The answer is C