Explain the notion of package access in Java Explain the neg

Explain the notion of package access in Java. Explain the negative aspects of package access. What happens when a return type, even void, is specified for a constructor?

Solution

Answer 8.2

Package access doesn\'t support object oriented programing when applied to a instance variable as it eliminates the notion of information hiding, If no access modifier is specified for a method or variable when it is declared in a class, then the method or variable is considered to have PACKAGE ACCESS. if a program uses multiple classes from the same package, then the classes can access each other\'s package-access member directly through reference to object of the appropiate class.

Answeer 8.3

If a return type or void is specified for a constructor ,It will compile because the return type or void is specified it will be considered as normal method. if not it will be a constructor.Example given below

public class example

{

    public example () / This is constructor

    {

    }

    public void example () // This is method

    {

    }

}

 Explain the notion of package access in Java. Explain the negative aspects of package access. What happens when a return type, even void, is specified for a co

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site