0

Will line 1 give me an error ? If yes, why?

Here's the code //code from pckg abc package abc; class Sup { protected int x;} //code in pckg xyz package xyz; import package abc; class Sub extends Sup { psvm (...){ Sup obj=new Sup () //line 1 obj.x=5;} }

8th Jul 2017, 3:35 PM
Learner
Learner - avatar
1 Odpowiedź
0
yes, it will give error. Sub classes can access protected members but not through objects
8th Jul 2017, 5:04 PM
Bhavani Prasad B V N S
Bhavani Prasad B V N S - avatar