Question: In the following code, the classes Box, Pen, and Main are in the same package. Can the Main class be compiled? class Box {
In the following code, the classes Box, Pen, and Main are in the same package. Can the Main class be compiled? class Box { protected void math() { } } class Pen extends Box { } class Main { public void p() { Pen p = new Pen(); p.math(); }
Step by Step Solution
3.42 Rating (146 Votes )
There are 3 Steps involved in it
No the Main class cannot be compiled The issue lies in the visibility of the method ... View full answer
Get step-by-step solutions from verified subject matter experts
