File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Doubt in accessing a method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Doubt in accessing a method" Watch "Doubt in accessing a method" New topic
Author

Doubt in accessing a method

Prashanth Patha
Ranch Hand

Joined: May 06, 2011
Posts: 62

Suppose we have a class as follows:

package prash;
public class A // public class
{

void print() { // default access
System.out.print("Hi");
}

}

Consider another class:

package ravi;
import prash.A;
class B
{
// Doubt:
// Can B access the method print() (having default access ) of a public class A which is in different package?
}









Thanks & Regards
Prashanth

Evelina Vrabie
Greenhorn

Joined: Oct 10, 2008
Posts: 19
No, default access means package-private (only visible inside the package). Take a look here: http://download.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html


Evelina Vrabie
SCJP 6, SCJD (in progress)
Ikpefua Jacob-Obinyan
Ranch Hand

Joined: Aug 31, 2010
Posts: 394

Hello Prashanth, please use code tags to make code reading easier



As you can observe, it is easier to read now.


OCPJP 6.
In Your Pursuit Towards Certification, NEVER Give Up.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt in accessing a method
 
Similar Threads
Doubt
Doubt
doubt in access modifier
Inheritance Doubt?
A small doubt