-
What is the output of this program?
class access_Example
{
public int p;
private int q;
void calc(int n1, int n2)
{
p = n1 + 1;
q = n2;
}
}
public class access_specifier
{
public static void main(String args[])
{
access_Example obj = new access_Example();
obj.cal(5, 7);
System.out.println(obj.p + " " + obj.q);
}
}
-
- 5 7
- 7 7
- Compiletime error
- Runtime error
- None of these
Correct Option: C
access_specifier.java:16: error: cannot find symbol
obj.cal(5, 7);
^
symbol: method cal(int,int)
location: variable obj of type access_Example
access_specifier.java:17: error: q has private access in access_Example
System.out.println(obj.p + " " + obj.q);
^
2 errors