Package - Day 7 Flashcards

1
Q

Package

A

A group of related classes, interfaces to help organisation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Package benefits

A

Modularisation

Reusable

Name conflicts

Controlled access

Data encapsulation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Two types of packages

A

Built in packages: predetermined packages that are a part of JDK.

User-Defined packages: developed by users in order to group related classes, interfaces and sub-packages

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Keyword for package

A

package mypackage;

Can be used once and will package all interfaces and classes in the file.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Protected declaration

A

Protected Variables, methods & constructors can be accessed only by sub classes in other packages or any class within the package.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

import keyword

A

Import built in or user defined packages

Import packagename.*;
^importe all classes

Import packagename.classname;
^imports only the class you want 

Packagename.classname;
^ using it

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Accessibility of access modifier

A

Public can be access anywhere

Private can be accessed only within that class

If not mentioned, element is accessible to all the classes in the same package

protected can be accessed to all classes inside the same package and to sub classes present in different package

How well did you know this?
1
Not at all
2
3
4
5
Perfectly