Data Access Modifiers and Packages Flashcards

1
Q

Member Access Modifiers

A

Control access to class members through the keywords.

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

Public

A

members declared as public are accessible from anywhere in the program when the object is referenced.

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

Protected

A

Subclasses can access protected methods/data of the parent class.

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

Default

A

such a class, method or field can be accessed by a class inside the same package only.

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

Private

A

members declared as private are accessible ONLY to methods of the class in which they are defined.

All private data are always accessible through the methods of their own class.

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

Java Package

A

A java package is a group of similar types of classes, interfaces and sub-packages.

Package in java can be categorized in two form, built-in package and user-defined package.

There are many built-in packages such as java, lang, awt, javax, swing, net, io, util, sql etc.

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

Advantage of Java Package

A

1) Java package is used to categorize the classes and interfaces so that they can be easily maintained.
2) Java package provides access protection.
3) Java package removes naming collision.

For example, a package allows you to create a class named List, which you can store in your own package without concern that it will collide with some other named List stored elsewhere.

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

java. lang
java. io
java. util
java. applet
java. awt
java. net

A

java. lang - contains language support classes(primitive data types, math operations). This package is automatically imported.
java. io - contains classes for supporting input/output operations.
java. util - contained utility classes that implement data structures like LinkedList, Hash Table, Dictionary, etc and support for Date/Time operations.
java. applet - contains classes for creating applets.
java. awt - contains classes for implementing the components of graphical user interface (like buttons, menus, etc.)
java. net - contains classes for supporting networking operations.

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