Java MCQ test - Access Modifiers | Java Quiz on Access Modifiers



Check your Java concepts on access modifiers with our free online Java test series. Evaluate access modifiers concepts in Java by giving this online test that covers questions on - public, private, protected, final, static, and abstract modifiers.


Java access modifiers MCQ test

Topic- Java - Access Modifiers

The test consists of 11 questions.

No negative marking for this test.

No Time limit

The pass percentage is 70%

The correct answer with a description will be displayed after the answer has been marked.

Submit the test to calculate your score once you are done with all the questions.

Complexity Level- Moderate




Q1: A variable with the 'public' modifier can be accessed from anywhere, wherever this class is visible:


Select whether the statement is True or False.










Q2: Private members of a class can be inherited by the sub-class:


Select whether the statement is True or False.










Q3: Protected members in Java are accessible:


Select all possible answers:



















Q4: A static method in a class can _______














Q5: If a variable of primitive datatype in Java is declared as final, then ______















Q6: Non-subclasses in other packages can also access protected members from other packages


Select whether the statement is true or false:











Q7: What will be the output of the below program:

class superDemoClass{
final int a = 20;
}

class subDemoClass extends superDemoClass{
void subFunc(){
a=40;
System.out.println("value of a = " +a);
}
}

class demo{
public static void main(String[] args){
subDemoClass subc = new subDemoClass();
subc.subFunc();
}
}














Q8: If a method is declared as final in Java, then _________













Q9:What will be the output of the below program:

class superDemoClass{
final void func(){
int a = 20;
System.out.println("value of a = " +a);
}
}

class subDemoClass extends superDemoClass{
void func(){
int b = 60;
System.out.println("value of b = " +b);
}
}

class demo{
public static void main(String[] args){
subDemoClass subc = new subDemoClass();
subc.func();
}
}














Q10: Which of the following statements is true for an abstract method in Java?

















Q11: A final method cannot be abstract and vice versa.


Select whether the statement is True or False: