Java Programming Practice Question
Assume class Calculator in package p1 and CalculatorService class in package p2 as shown below. package p1; public class Calculator { __________ static void calculate(){ //some code here } } package p2; import p1.Calculator; public class CalculatorService { public void display(){ Calculator.calculate(); } } What can be the valid access specifier for the calculate method in Calculator class so that it can be accessed from CalculatorService class?Answer options
A
public
B
protected
C
private
D
default
Correct answer: public
Detailed Solution & Conceptual Analysis
This question has been retained as-is due to its unique context.
Key Engineering Takeaway
In Java Programming, understanding the underlying mechanics of Java Programming is critical for writing performant, bug-free production code and passing rigorous technical architecture reviews.