Modifier Types
- What is the output of this program?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
output: 25 1
- What is the output of this program?
class static_Access
{
static int p;
static int q;
void add(int n1, int n2)
{
p = n1 + n2;
q = p + n2;
}
}
public class static_output
{
public static void main(String args[])
{
static_Access obj1 = new static_Access();
static_Access obj2 = new static_Access();
int n1 = 5;
obj1.add(n1, n1 + 2);
obj2.add(6, n1);
System.out.println(obj1.p + " " + obj2.q);
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
Output: 11 16
- Which of these access specifier must be used for class so that it can be inherited by another subclass?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
public
- 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;
}
void print()
{
System.out.println(+ q);
}
}
public class access_specifier_result
{
public static void main(String args[])
{
access_Example obj = new access_Example();
obj.calc(5, 7);
System.out.println(obj.p);
obj.print();
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
Output:
6
7
- Which one of the following is not an access modifier?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
Public, private, protected and default are the access modifiers.