Answer: access modifier : Questions « Statements « SCJP






B. D 

protected modifier allows access by derived classes as well as classes in the same package. 
private prevents any access from another class. 
default access allows only access within the same package.








5.15.Questions
5.15.1.What is the correct statement for line 3 to sum all elements in an array?
5.15.2.Answer: for loop definition
5.15.3.Which of the following statements about this method are true?
5.15.4.Answer: if ladder
5.15.5.Which are input and output?
5.15.6.Answer: switch statement and default
5.15.7.Which declarations of x will not cause a compiler error?
5.15.8.Answer: switch controlling variable
5.15.9.What will the printed output be?
5.15.10.Answer: break statement with label
5.15.11.What is the output from the following code(number format exception)?
5.15.12.Answer: number format exception
5.15.13.What is the output from the following code(Compare strings)?
5.15.14.Answer: Compare strings
5.15.15.What is the output from the following code(switch statement)?
5.15.16.Answer: switch statement and calculation
5.15.17.What is the output from the following code(variable inheritance)?
5.15.18.Answer: variable inheritance
5.15.19.Which modifiers used in XXXXXX would allow the BigWidget class to access the Widget.setWidth method?
5.15.20.Answer: access modifier
5.15.21.What is the output of the following code(nested for loop with continue label)?
5.15.22.Answer: nested for loop with continue label
5.15.23.Which method will be acceptable when aMethod may throw a AException or a BException?
5.15.24.Answer: exception throwing
5.15.25.Choose all of the declarations of x that will not cause a compiler error.
5.15.26.Answer: switch statement controller variable
5.15.27.type char may appear in a switch statement(True/False)
5.15.28.Answer: char type and switch statement
5.15.29.type byte may appear in a switch statement(True/False)
5.15.30.Answer: byte type and switch statement
5.15.31.type long may appear in a switch statement(True/False)
5.15.32.Answer: long type and switch statement
5.15.33.type boolean may appear in a switch statement(True/False)
5.15.34.Answer: boolean variable and switch statement
5.15.35.What is the output when compiling and running the following code(while statement)?
5.15.36.Answer: while statement and condition
5.15.37.What is the output when compiling and running the following code(while statement(2))?
5.15.38.Answer: while statement(2)
5.15.39.What is the output when compiling and running the following code(do... while)?
5.15.40.Answer: do... while