InstructionsTotal Questions: 18Total Minutes: 18This ExamTray Free Online Test or Quiz or Trivia tests your Programming Skills on the basics of Java Access Modifiers. This practice test displays answers after finishing the exam for review. You can easily clear Competitive Exams and Job Interview Questions. Students can learn Java basics. Go through Java Theory Notes on Access Modifiers before attempting this test. All the Best Challenge SCORE0 / 18Take This Exam 1*2*3*4*5*6*7*8*9*10*11*12*13*14*15*16*17*18*Q Buttons 1) Which are access modifiers below in Java? A) public B) private C) protected D) All the above 2) What is an access modifier in Java? A) An access modifier controls the visibility of variables, constants and methods of a class B) An access modifier can hide or show a variable or method to outside classes. C) Access modifiers help in implementing the Encapsulation feature of Object-Oriented Programming (OOPs). D) All the above 3) Which is the keyword used to specify the DEFAULT access modifier in java? A) default B) bydefault C) normal D) There is no keyword 4) Which is the less restrictive access modifier in Java? A) public B) private C) protected D) default 5) Which is the most restrictive access modifier in Java? A) public B) private C) protected D) default 6) Is it possible to combine more than one access modifier in Java? A) No B) Yes C) - D) - 7) Choose the correct Java code snippet with access modifiers below? A) class ABC { } B) private protected class ABC { } C) protected public class ABC { } D) protected private class ABC { } Ad 8) Can you access a default member of a class from a class of outside current package in Java? A) No B) Yes C) - D) - 9) Choose the correct statement about access modifiers in Java. A) public, protected and default variables and methods can be accessed outside the package somehow. B) public and protected variables and methods can be accessed outside the package somehow. C) Only public variables and methods can be accessed outside the package somehow. D) None of the above 10) To access a protected variable or method of a Class outside the package, you need to ____ in Java. A) Create an instance and call the protected variable or method B) Create a Subclass and call the protected variable or method C) A and B D) None of the above 11) What is the output of the Java program with access modifiers? package apartment1; public class Class101 { public String colour = "BLUE"; } package apartment2; import apartment1; public class Apartment2Flat102 { public static void main(String[] args) { Class101 flat = new Class101(); System.out.println(flat.colour); } } A) BLUE B) empty C) null D) Compiler error 12) What is the output of the below Java Code Snippet with access modifiers? package package1; public class Forest { int area = 10;//sq. km } package package1; public class SmallForest { public static void main(String[] args) { Forest fr = new Forest(); System.out.println("Area = " + fr.area); } } A) Area = 0 B) Area =10 C) No ouput D) Compiler error 13) What is the output of the Java code snippet with default access modifier? package package1; public class Bug { int legs = 4; } package package2; import package1.Bug; public class BugTest extends Bug { public static void main(String[] args) { Bug bug = new Bug(); System.out.println("Bug Legs = " + bug.legs); } } A) Bug Legs = 4 B) Bug Legs = 0 C) Bug Legs = D) Compiler error 14) What is the output of the Java code snippet with PROTECTED access modifier? package package1; public class Parent { protected void showProperty() { System.out.println("10 million"); } } package package2; import package1.*; public class Children extends Parent { void show() { showProperty(); } public static void main(String[] args) { Children chil = new Children(); chil.show(); } } A) No output B) 10 million C) Compiler error D) None of the above Ad 15) What is the output of the Java code with PRIVATE access modifier? package package1; public class Factory { private void run() { System.out.println("Running factory"); } } package package1; public class FactoryTest { void callFactory() { Factory fac2 = new Factory(); fac2.run(); } public static void main(String[] args) { Factory fac1 = new Factory(); fac.run(); } } a A) Running factory Running factory B) Running factory C) Compile error D) None of the above 16) In Java, a PROTECTED variable or method of a Super class can not be accessed from a STATIC method of Subclass of different PACKAGE. State TRUE or FALSE. A) TRUE B) FALSE C) - D) - 17) What is the output of the Java program with PROTECTED access modifer? package package1; public class Milk { protected int volume = 1000; //Liters } package package2; import package1.Milk; public class RoseMilk extends Milk { public static void main(String[] args) { Milk object = new Milk(); System.out.println(object.volume); } } A) 0 B) 1000 C) null D) Compiler error 18) What is the output of the Java code with PROTECTED access modifier? package package1; public class Plant { protected void showHeight() { System.out.println("50 meters"); } } package package2; import package1.Plant; public class Tree extends Plant { public static void main(String[] args) { Tree tree = new Tree(); tree.showHeight(); } } A) No output B) 50 meters C) Compiler error D) No output FINISH EXAM 1*2*3*4*5*6*7*8*9*10*11*12*13*14*15*16*17*18*PREV Java Packages Online Test NEXT Java Exception Handling Online Test 1