I have two classes in different packages as follows This is the base class in package library.
package library;
public class Book{
public int varPublic;
protected int varProtected;
private int varPrivate;
int varDefault;
}
and this is the subclass in the package building.
package building;
import library.Book;
public class StoryBook extends Book {
public static void main(String[] args) {
// TODO Auto-generated method stub
Book book = new Book();
book.varPublic = 10;
book.varProtected = 11;
}
}
my understanding is that the variable "var.Protected" should be visible in the class StoryBook but i am getting an error. I have tried to execute this code from eclipse and command-prompt.
could anyone please look into this