Skip to main content

Discuss the various levels of access protection available for packages.

•Java provides a number of access modifiers to set access levels for classes, variables, methods and constructors. The four access levels are:

1.Visible to the package. the default. No modifiers are needed.

2.Visible to the class only (private).

3.Visible to the world (public).

4.Visible to the package and all subclasses (protected).
•Default access modifier means we do not explicitly declare an access modifier for a class, field, method, etc., A variable or method declared without any access control modifier is available to any other class in the same package.
•If you want only objects in the same class to be able to get or set the value of a field or invoke a method, declare it private.
•If you want any object at all to be able to call a method or change a field, declare it public.
•If you want access restricted to subclasses and members of the same package, declare it protected.

Comments

Post a Comment

Popular posts from this blog

Java,ES,QT practical files

All practical files: Click below to start download Uploaded on special request||||

Vidyalankar Question paper solutions

Download from their website: http://www.vidyalankar.org/index.aspx or just click here to download

Explain network classes.

43.Explain network classes. Ans. 1. TCP/IP network are 4 bytes long, called IP addresses and written in dotted-decimal notation. (ex. 192.168.166.5) 2. The decimal numbers must be within the numeric range of 0-255, each IPv4 addresses consist of 4 parts. 3. Each part should conform to the 1-byte requirement. 4. Depending on the value of the first byte of the address, IP addresses can be divided into classes. 5. Network classes are of 3 type and have some specific range • Class A 0-127 • Class B 128-191 • Class C 192-233 6. Class division enables us efficient use of the address numbers. 7. Assigned network numbers are maintained in a database managed by InterNIC to insure that each assignment is unique. 8. After obtaining a network number, the host numbers may be assigned as required, for data transfer ARP maps the IP address to the MAC address of the device. 9. Routers are used for transferring data between 2 devices, routers are default gateway ...