InstructionsTotal Questions: 27Total Minutes: 27This ExamTray Free Online Test or Quiz or Trivia tests your Programming Skills on the basics of Java Interface. 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 Interface and Java 8 Default and Static Methods in Interfaces before attempting this test. All the Best Challenge SCORE0 / 27Take This Exam 1*2*3*4*5*6*7*8*9*10*11*12*13*14*15*16*17*18*19*20*21*22*23*24*25*26*27*Q Buttons 1) An interface in Java is like a 100% ____. A) abstract class B) public class C) inner class D) anonymous class 2) A Java Interface is not considered a class. State TRUE or FALSE. A) TRUE B) FALSE C) - D) - 3) Choose the correct syntax below for defining an Interface in Java. A) interface NAME { //abstract methods } B) abstract interface NAME { //abstract methods } C) public interface NAME { //abstract methods } D) All the above 4) Choose a correct statement about Java Interfaces? A) Interface contains only abstract methods by default. B) A Java class can implement multiple interfaces C) An Interface can extend or inherit another Interface. D) All the above 5) A Java Class inherits Constants and Methods of an Interface using ____ keyword. A) INTERFACE B) IMPLEMENTS C) EXTENDS D) All the above 6) What is the output of the below Java program with an Interface? interface Bus { void move(); } class ElectricBus implements Bus { public void move() { System.out.println("Implemented move() method."); } } public class InterfaceTest1 { public static void main(String[] args) { new ElectricBus().move(); } } A) No output B) Implemented move() method. C) Compiler error D) None of the above 7) What is the output of the below Java program with an Interface? interface Car { int basePrice=1000; } public class InterfaceTest2 implements Car { void changePrice() { basePrice = 2000; System.out.print(basePrice); } public static void main(String[] args) { new InterfaceTest2().changePrice(); } } A) 1000 B) 2000 C) Compiler error D) None of the above Ad 8) What is the output of the below Java program with an Interface? interface Book { char type='C'; } public class InterfaceTest3 { public static void main(String[] args) { System.out.println(new Book().type); } } A) C B) No output C) Compiler error D) None of the above 9) All Interface variables are ___ by default in Java. A) public B) final C) public and final D) None 10) All Interface methods in Java are ____ by default. A) public B) abstract C) public and abstract D) None of the above 11) A Class implementing an Interface can use ____ access modifier before the implemented methods. A) private B) protected C) public D) All the above 12) A Java Class implementing an Interface can define a variable with the same name as that of the Interface constant. State TRUE or FALSE. A) TRUE B) FALSE C) - D) - 13) What is the output of the below Java program with an Interface? interface Worm { int teeth=2; } class BookWorm implements Worm { int teeth=4; void show() { teeth= 5; System.out.println("Teeth: " + teeth); } } public class InterfaceTest4 { public static void main(String[] args) { new BookWorm().show(); } } A) Teeth: 4 B) Teeth: 5 C) Compiler error as teeth is a constant in Worm interface. D) None of the above 14) A Java Interface can not declare constructors. State TRUE or FALSE. A) TRUE B) FALSE C) - D) - Ad 15) What is the output of the below Java program with an Interface? interface Floor { Floor(){ } } public class InterfaceTest5 { public static void main(String[] args) { System.out.print("Floor"); } } A) Floor B) No output C) Compiler error D) None 16) Java 8 (Java 1.8) introduced the ___ feature. A) Default methods B) Static methods C) Default and Static methods D) None of the above 17) Java Interface static methods have ___ compatibility with the existing project code. A) Forward B) Backward C) Both Forward and Backward D) - 18) Java Interface DEFAULT methods have ___ compatibility with the existing project code. A) Forward B) Backward C) Backward and Forward D) - 19) The DEFAULT methods of an Interface are suitable mostly for ___ type of projects. A) Open Source (Public Repositories) B) Closed Source (Private Repositories) C) - D) - 20) Is it possible to remove the keyword DEFAULT and make the method abstract again in an Interface, if the Interface belongs to a Closed-Source project? A) Yes B) No C) - D) - 21) The annotation used in Java to override the method of a super-class or interface by the subclass or implementing class is ___. A) @override B) @Override C) @super D) @subclass Ad 22) It is ___ to override the static method of an Interface in Java. A) possible B) not possible C) - D) - 23) A Java static method can not be ___. A) private or protected B) final C) abstract D) All the above 24) Which is the missing java code in the class implementing an Interface below? interface Linein { void addInput(); } interface Lineout { void addOutput(); } class Speaker implements Linein, Lineout { //MISSING CODE } A) class Speaker implements Linein, Lineout { @Override public void addOutput() { } @Override public void addInput() { } } B) class Speaker implements Linein, Lineout { @Override public void addOutput() { } } C) class Speaker implements Linein, Lineout { @Override public void addInput() { } } D) All the above 25) Which is the missing code to successfully compile the below Java program with abstract classes and Interfaces? interface A { void a(); } abstract class B implements A { abstract void b(); } class C extends B { //Missing methods } A) @Override public void a() { } @Override void b() {} B) @Override public void a() { } C) @Override void b() {} D) All the above 26) A Superinterface is comparable to a Superclass. State TRUE or FALSE. A) TRUE B) FALSE C) - D) - 27) A Static method of an Interface should be accessed with _____ and a DOT operator. A) Class Name B) Interface Name C) An object of a concrete class D) None of the above FINISH EXAM 1*2*3*4*5*6*7*8*9*10*11*12*13*14*15*16*17*18*19*20*21*22*23*24*25*26*27*PREV Java Interface Online Test NEXT Java Package Online Test