Java Interface Quiz

Java Interface Quiz

University

9 Qs

quiz-placeholder

Similar activities

java quiz based on interface

java quiz based on interface

University

10 Qs

Object Oriented Programming Quizz

Object Oriented Programming Quizz

University

10 Qs

Advanced Java Lab_4CSN

Advanced Java Lab_4CSN

University

10 Qs

Java Inheritance

Java Inheritance

University

6 Qs

Java Quiz 1

Java Quiz 1

University

10 Qs

Unit 24 - Java Basics

Unit 24 - Java Basics

University

10 Qs

Nested Classes + java

Nested Classes + java

University

10 Qs

Java Classes

Java Classes

12th Grade - University

10 Qs

Java Interface Quiz

Java Interface Quiz

Assessment

Quiz

Computers

University

Hard

Created by

Kundan Kumar

Used 2+ times

FREE Resource

9 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which keyword is used to implement an interface in Java?

uses
implements
inherits
extends

2.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Media Image

What will be the output of this code?

Compilation error

Method A

Runtime error

No output

3.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

What happens if a class implements an interface but does not provide implementations for all of its methods?

The class can be instantiated without any restrictions.
The class must be declared abstract.
The class will automatically implement the missing methods.
The class will compile without errors.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the default access modifier for methods declared in an interface?

private

protected
package-private

public

5.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

Which of the following is true about interfaces in Java?

Interfaces can contain method signatures and static final variables, but cannot contain method implementations.

Interfaces can contain method implementations without restrictions.
Interfaces can only contain private methods.
Interfaces cannot contain any variables.

6.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

What keyword is used to inherit from a class and to implement an interface in Java?

inherit, derive

extends, extends

extends, implements

implements, extends

7.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

Which of the following is true regarding multiple inheritance in Java?

Java does not allow any form of inheritance.
Java supports multiple inheritance only through classes.
Java allows multiple inheritance with classes and interfaces.
Java does not support multiple inheritance with classes, but it allows multiple inheritance through interfaces.

8.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

Which of the following correctly distinguishes a class from an interface in Java?

Both classes and interfaces can have constructors

Only interfaces can have constructors

Only classes can have constructors



Neither classes nor interfaces can have constructors

9.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

Why can’t interfaces have constructors in Java?

Interfaces can have constructors if they extend a class.
Interfaces cannot have constructors because they cannot be instantiated.
Constructors in interfaces are used for initialization.
Interfaces can be instantiated like classes.