Given the code fragment:
Which two modifications enable the code to compile? (Choose two.)
Given the code fragment:
Which two modifications enable the code to compile? (Choose two.)
To enable the code to compile, the method in the child class must have at least the same level of visibility as the method in the parent class. Since the parent class has 'protected' visibility for the method at line 2, the child class method must be either 'protected' or 'public'. Therefore, making the method at line 8 'protected' or 'public' (options A or B) will fix the visibility issue. The method at line 10 is an implementation of an abstract method from the parent class and it cannot be private, thus making it 'protected' or 'public' would work as well. However, given the options, the correct choices are A and B to change the visibility of the method at line 8 to protected or public.
in this case the only two good ones represent its A and B, the Implementation of an abstract method in the child class can be private in note case it does not prevent the compilation, instead the method revolve and declared protected so the child class this method can be declared minimum protected or lower public, thus the answer and A, B
A and B only
sorry for my answer i have tested A and C is good answer
The answer would be BC or AC.
The answer whould be BC or AC. Both A and B are correct answers unfortunately. Note that in these options what is being analyzed is an override and not an implementation of an abstracted method. The oracle documentation states that the access modifier in this case could be the same or allow for greater visibility, not less. Which makes options A and B correct. If the question is correct, it remains to be seen what is the best practice or convention in this regard. https://docs.oracle.com/javase/tutorial/java/IandI/override.html About the answer: I choose AC. Whereas, the abstract class is a pseudo-model to follow. I would keep the same access modifier already informed in it. Another no less relevant issue is having confidence in this simulated exam material that being the knowledge base for us. We wait for new comments in this forum to improve the accuracy in the answer.
The question was asked wrong, because in addition to answers A and C being correct, B is also correct. So both AC and BC are correct, because in inheritance you can put a view pattern bigger than the parent class, you just can't put it smaller. Attention to the question because she didn't talk about independent changes so it can't be AB.
If the question falls on the test I would mark BC, I don't know if they score the most correct. To be on the safe side, I would mark BC.