Question: Circle the assignment statements, Line 1 through Line 10, in the following code that illegally access a field. Why are they illegal accesses? package Exam;

Circle the assignment statements, "Line 1" through "Line 10", in the following code that illegally access a field. Why are they illegal accesses?

 package Exam; 

public class Parent { protected String protectedVar = "Protected"; String packageVar = "Package";

}

 package Exam; 

public class Uncle { public void SampleAccess( Parent parameter )

{ parameter.protectedVar = "Line 1";

parameter.packageVar = "Line 2"; }

}

 package Quiz; 

public class Aunt { public void SampleAccess( Exam.Parent parameter)

{ parameter.protectedVar = "Line 3";

parameter.packageVar = "Line 4"; }

}

 package Quiz; 

public class Child extends Exam.Parent { public void SampleAccess( Exam.Parent parentType,

Child childType) { parentType.protectedVar = "Line 5";;

parentType.packageVar = "Line 6";

 protectedVar = "Line 7"; packageVar = "Line 8"; 

childType.protectedVar = "Line 9";

childType.packageVar = "Line 10"; }

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!