149k views
1 vote
Matt creates a Java class as part of his college assignment. He wants this class to be accessible within the current package only. Which access specifier should Matt use?

Matt has another Java assignment with multiple classes. In this assignment, there is a general class. A few subclasses outside the package use methods from this general class. Which access specifier should Matt use for the general class?

Matt should use the (blank) access specifier for the first class.

A. Protected
B. Default
C. Private
D. Public

He should use the (blank) access specifier for the general class.

A. Protected
B. Public
C. Default
D. Private

1 Answer

3 votes

Answer:

first use Default as

a class with the default access modifier in a package, only those classes that are in this package can access this class. No other class outside this package can access this class.

general uses protected to make itself accecible to the subclasses.

User Praveen Govind
by
5.3k points