Java Interface Interview MCQ Questions and Answers

Study and learn Interview MCQ Questions and Answers on Java Interface. Attend job interviews easily with these Multiple Choice Questions. You can print these Questions in default mode to conduct exams directly. You can download these MCQs in PDF format by Choosing Print Option first and Save as PDF option next using any Web Browser.

Go through Java Theory Notes on Interface and Java 8 Default and Static Methods in Interfaces before reading these objective questions.



1) An interface in Java is like a 100% ____.
A) abstract class
B) public class
C) inner class
D) anonymous class
Answer [=]
Answer[=]
2) A Java Interface is not considered a class. State TRUE or FALSE.
A) TRUE
B) FALSE
C) -
D) -
Answer [=]
Answer[=]
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
Answer [=]
Answer[=]
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
Answer [=]
Answer[=]
5) A Java Class inherits Constants and Methods of an Interface using ____ keyword.
A) INTERFACE
B) IMPLEMENTS
C) EXTENDS
D) All the above
Answer [=]
Answer[=]
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
Answer [=]
Answer[=]
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
Answer [=]
Answer[=]


 

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
Answer [=]
Answer[=]
9) All Interface variables are ___ by default in Java.
A) public
B) final
C) public and final
D) None
Answer [=]
Answer[=]
10) All Interface methods in Java are ____ by default.
A) public
B) abstract
C) public and abstract
D) None of the above
Answer [=]
Answer[=]
11) A Class implementing an Interface can use ____ access modifier before the implemented methods.
A) private
B) protected
C) public
D) All the above
Answer [=]
Answer[=]
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) -
Answer [=]
Answer[=]
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
Answer [=]
Answer[=]
14) A Java Interface can not declare constructors. State TRUE or FALSE.
A) TRUE
B) FALSE
C) -
D) -
Answer [=]
Answer[=]


 

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
Answer [=]
Answer[=]
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
Answer [=]
Answer[=]
17) Java Interface static methods have ___ compatibility with the existing project code.
A) Forward
B) Backward
C) Both Forward and Backward
D) -
Answer [=]
Answer[=]
18) Java Interface DEFAULT methods have ___ compatibility with the existing project code.
A) Forward
B) Backward
C) Backward and Forward
D) -
Answer [=]
Answer[=]
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) -
Answer [=]
Answer[=]
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) -
Answer [=]
Answer[=]
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
Answer [=]
Answer[=]


 

22) It is ___ to override the static method of an Interface in Java.
A) possible
B) not possible
C) -
D) -
Answer [=]
Answer[=]
23) A Java static method can not be ___.
A) private or protected
B) final
C) abstract
D) All the above
Answer [=]
Answer[=]
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
Answer [=]
Answer[=]
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
Answer [=]
Answer[=]
26) A Superinterface is comparable to a Superclass. State TRUE or FALSE.
A) TRUE
B) FALSE
C) -
D) -
Answer [=]
Answer[=]
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
Answer [=]
Answer[=]


Like or Share

Show some care. Like or Subscribe. [FB]...[Youtube]

C MCQ App by ExamTray 

Android APP

Java MCQ App by ExamTray 

Android APP
ALL MCQ App by ExamTray Android APP

Ad

 

Try Some Java Books

Book Price
1. Java - The Complete Reference  Check Price
2. Core Java: An Integrated Approach, Black Book Check Price
3. Java All-in-One for Dummies Check Price
4. OCP Java SE 8: Programmer II Check Price
5. Programming with Java Check Price
6. Head First Java Check Price

We may get some affiliate commission for the above purchases.