File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes which variable/method will be called? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "which variable/method will be called?" Watch "which variable/method will be called?" New topic
Author

which variable/method will be called?

Anu satya
Ranch Hand

Joined: Mar 17, 2005
Posts: 146
Hello everybody,
I had been to one written test. There was two questions. Which I am not sure of correct answer.
1. which of the following variable is accessible from any class/any method at any point of time?
a)public int i;
b)protected int i;
c)private int i;
d)static int i;
e)static final int i;

I feel it must be a-public int i, Because it is public. Private can be accessed only through a object handle. And protected is only for extending class.

2. Which of the following methods can be accessed from any class at any point of time?
a)public int execute();
b)protected execute();
c)private execute();
d)static execute();
e)static final execute();

I feel it must be a-public int execute, Because it is public. Private can be accessed only through a object handle. And protected is only for extending class.

please help me
Regards,


With Regards,
Anu
vivien siu
Ranch Hand

Joined: Nov 10, 2005
Posts: 143
I think you got it all right it has to be public


I'm not available, my BF's name is WORK.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: which variable/method will be called?
 
Similar Threads
Access Control and Inheritance
Java Quiz
Nested Class
Traps to be aware of in any SCJP test !!!!! :)
Public Variables