Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

which variable/method will be called?

 
Anu satya
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
 
vivien siu
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you got it all right it has to be public
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic