c.
d.
113.
114.
a.
sub–classes that are outside the package.
Public: A member having the
public access specifier is
accessible to all classes outside the package.
Default: The default access occurs when none of the above
access specifiers are specified. In such a case,
the member
is accessible within the package but not outside the package.
Explain with a code sample how to create a package.
Answer:
You can create a package by using the package keyword. It
should be followed by the name that you want to give to the
package. The package name should be a valid Java identifier.
The package statement should be the first statement in the java
file. The following code demonstrates this:
package demo;
public class MyClass {
//instance fields and methods
}
This code declares a class called MyClass.
It is in a package
called demo. Note that the package statement is the first
statement in the code.
Do'stlaringiz bilan baham: