Font size
WorksheetsInterface + java-visual
Total questions: 88
Worksheet time: 44mins
What is the color of the water bottle in the image?
Red
Blue
Green
Yellow
What is the name of the remote resource defined in the image?
PetStore
Pet
CreatePet
IdNotFound
What is the output of the program?
2000
Have a good day
Static method
None of the above
What is the purpose of the CallBackInterface interface?
To allow the WorkerClass to notify the MainActivity when it has finished its task.
To allow the MainActivity to control the WorkerClass's behavior.
To allow the WorkerClass to access the MainActivity's data.
To allow the MainActivity to access the WorkerClass's methods.
What is the output of the displayInfo() method?
Person Name: JOHN, Person Age: 32
Person Name: JOHN, Person Age: 21
Person Name: InterfaceExamples, Person Age: 32
Person Name: InterfaceExamples, Person Age: 21
What is the HTTP method used to add a new pet to the store?
GET
POST
PUT
DELETE
Which of the following classes inherits from the Movable interface?
MovablePoint
MovableCircle
Both MovablePoint and MovableCircle
Neither MovablePoint nor MovableCircle
What is the purpose of the ITable interface?
To define the methods that must be implemented by any class that wants to be a table.
To provide a way to access the data in a table.
To allow different types of tables to be used in the same program.
All of the above.
Which of the following methods is declared as a private static method in the MyInterfaceInJava9 interface?
printLines()
method1()
method2()
mymethods()
Which of the following classes inherits from the Animal class?
Cat
Dog
Bird
All of the above
Which of the following methods is implemented in the MyClass class?
method()
method(double x)
method(int x)
method(char x)
What is the output of the code?
10
20
30
40
The main purpose of an interface in Java is to __________.
Achieve abstraction.
Support multiple inheritance.
Achieve loose coupling.
Provide a way to implement abstract classes.
What is the keyword used to declare an interface in Java?
interface
class
abstract
static
Which of the following is NOT a difference between a class and an interface in Java?
A class can have concrete methods, while an interface cannot.
A class can be instantiated, while an interface cannot.
A class can extend another class, while an interface can extend multiple interfaces.
A class can implement an interface, while an interface cannot implement a class.
Which of the following methods is declared in the Bird interface in the image?
breathe()
chirp()
equals(Object obj)
getClass()
Which of the following methods is implemented by the Vehicle class in the image?
speedUp()
changeGear()
main()
toString()
What is the data type of the mark variable in the Father interface?
int
float
double
String
What is the return type of the removeIf method in the Collection interface?
boolean
int
String
void
What is the purpose of the endpoint variable in the code in the image?
It stores the URL of the web service.
It stores the name of the web service.
It stores the port number of the web service.
It stores the method name of the web service.
What is the value of the name static final String in the image?
interface
interface1
interface2
interface3
What is the name of the interface that is being implemented by the Bird class?
Flyable
Animal
Bird
CanFly
What is the name of the new method that has been added to the image?
stream()
sort()
add(E e)
remove(Object o)
What is the keyword used to declare a variable in an interface?
static
final
public
private
What is the name of the class that is being extended by the MyListWMerge class?
Mergeable
Arraylist
List
Object
Which of the following is NOT a collection interface in Java?
Collection
List
Set
Deque
What is the data type of the speed variable in the Moveable interface?
int
float
double
String
Which of the following methods is declared in the Employee interface?
getData()
setAge()
getName()
toString()
What is the return type of the show() method in the InterfaceExample2 class?
void
int
String
boolean
What is the return type of the add() method in the MyMath interface?
int
float
double
void
What is the default value of the mark variable in the Father interface?
100
0
null
No default value
What is the return type of the play() method in the MediaPlayer interface?
void
int
String
boolean
What is the data type of the name variable in the CreditCard interface?
String
int
float
double
What is the return type of the calculate() method in the SimpleInterest interface?
double
int
String
void
What is the return type of the getArea() method in the Circle interface?
int
float
double
void
What is the data type of the radius variable in the Circle class?
int
float
double
String
Which of the following is not a method in the Circle class?
getArea()
getRadius()
setRadius()
draw()
What is the data type of the x variable in the Point class?
int
float
double
String
What is the return type of the getName() method in the Person class?
String
int
float
double
What is the data type of the age variable in the Student class?
int
float
double
String
What is the return type of the getMark() method in the Student class?
int
float
double
String
What is the default value of the mark variable in the Student class?
0
100
null
No default value
What is the return type of the add() method in the Calculator class?
int
float
double
void
What is the return type of the show() method in the MyClass class?
void
int
String
double
What is the keyword used to declare an interface in Java?
class
interface
abstract
static
Which of the following keywords is used to declare a method in an interface?
public
abstract
static
final
What is the keyword used to declare a constant in an interface in Java?
public
final
static
abstract
Which of the following interfaces is a subinterface of the Collection interface?
List
Set
Queue
Map
Which of the following statements is true about constructors in Java interfaces?
Constructors are allowed in Java interfaces.
Constructors are not allowed in Java interfaces.
Constructors are allowed in Java interfaces, but they must be default constructors.
Constructors are allowed in Java interfaces, but they must be parametrized constructors.
Which of the following statements is true about the code in the image?
The code compiles and runs without errors.
The code compiles but throws an exception at runtime.
The code does not compile because the inputLocation() method is abstract.
The code does not compile because the inputLocation() method is not public.
Why does the code in the image not compile?
The interface SimpleFuncInterface is not a functional interface.
The method doWork() is not abstract.
The method isFunctional() is not abstract.
The annotation @FunctionalInterface is not used correctly.
What is the error message in the image?
The interface DemoInterface must have a default method.
The interface DemoInterface cannot have a default method.
The interface DemoInterface must have a static method.
The interface DemoInterface cannot have a static method.
What is the output of the code in the image?
Person Name: JOHN Person Age: 32 Employee Name: Michael
Person Name: JOHN Person Age: 32
Employee Name: Michael
Nothing is printed
What is the keyword used to declare a method in an interface?
public
abstract
static
final
What is the keyword used to declare a constant in an interface in Java?
public
final
static
abstract
What is the error message in the image?
The interface TestInterface must have a default method.
The interface TestInterface cannot have a default method.
The interface TestInterface must have a static method.
The interface TestInterface cannot have a static method.
What is the purpose of the code in the image?
To declare a marker interface.
To declare a class that implements the MyMarker interface.
To create an object of the MyMarker interface.
To call the checkMarker() method.
What is the keyword used to declare a default method in an interface in Java?
public
abstract
static
default
What is the diamond problem in Java?
A situation where a class inherits from two interfaces that have the same method with the same signature.
A situation where a class inherits from two interfaces that have the same method with different signatures.
A situation where a class inherits from two classes that have the same method with the same signature.
A situation where a class inherits from two classes that have the same method with different signatures.
What is the error message in the image?
The class Employee must implement the method getName().
The interface Human cannot have a default method.
The interface EmployeeInfo cannot have a default method.
The class Employee cannot inherit from two interfaces with the same method with the same signature.
What is the keyword used to declare an interface in Java?
class
interface
public
static
What is the error message in the image?
The interface MyInterface cannot have a method with the same signature as the method getName() in the class Human.
The class Human cannot have a method with the same signature as the method getName() in the interface MyInterface.
The interface MyInterface cannot extend the class Human.
The class Human cannot implement the interface MyInterface.
What is the output of the code in the image?
Hello, John!
Hello, World!
Nothing is printed.
An error is thrown.
What is the error message in the image?
The interface MyInterface must have a default method.
The interface MyInterface cannot have a default method.
The interface MyInterface must have a static method.
The interface MyInterface cannot have a static method.
What is the error message in the image?
The class MyClass must implement the method getName().
The interface MyInterface cannot have a method with the same signature as the method getName() in the class MyClass.
The class MyClass cannot have a method with the same signature as the method getName() in the interface MyInterface.
The interface MyInterface cannot extend the class MyClass.
What is the error message in the image?
The interface MyInterface must have a method with the same signature as the method getName() in the class MyClass.
The class MyClass cannot have a method with the same signature as the method getName() in the interface MyInterface.
The interface MyInterface cannot extend the class MyClass.
The class MyClass must implement the method getName().
What is the output of the code in the image?
Hello, John!
Hello, World!
Nothing is printed.
An error is thrown.
What is the error message in the image?
The class Employee cannot extend the interface Human.
The interface Human must have a method with the same signature as the method getName() in the class Employee.
The class Employee cannot have a method with the same signature as the method getName() in the interface Human.
The interface Human cannot have a default method.
What is the error message in the image?
The interface Human cannot have a default method.
The class Employee cannot have a method with the same signature as the method getName() in the interface Human.
The interface Human must have a method with the same signature as the method getName() in the class Employee.
The class Employee cannot extend the interface Human.
What is the warning message in the image?
The method show() is abstract and must be implemented by the subclass.
The method show() is not defined in the Sample interface.
The method show() is not public and cannot be accessed from other classes.
The class Employee cannot extend the interface Human.The method show() has a return type of void but does not return anything.
What is the name of the method that is being overridden in the MyClass class in the image?
display()
print()
show()
toString()
What is the name of the interface that the Activity class implements in the code snippet shown in the image?
Which of the following is a static method in the image?
public static void m1() in interface A
main() method in interface Main
main() method in abstract class B
main() method in enum C
What is the type of the variable UPPER_LIMIT in the image?
Instance variable
Static variable
Final variable
Constant variable
Which of the following is the correct way to inherit from the Animal class and implement the Flyable interface in the image?
class Bird extends Animal implements Flyable {}
class Bird implements Flyable extends Animal {}
class Bird extends Animal implements Flyable { public void fly() { } }
class Bird implements Flyable { public void fly() { } } extends Animal
What is the default value of the radius attribute in the Circle class in the image?
0
1
5
None of the above
What is the name of the class that is being created in the image?
Employee
Person
Human
Worker
What is the name of the interface that is being implemented in the image?
Runnable
Callable
Thread
Runnable and Callable
What is the value of the variable mark in the image?
1002
2007
300
None of the above
What is the name of the functional interface that takes an object of type T and returns an object of type R?
Predicate
Consumer
Supplier
Function
What is the name of the Java IDE that is being used in the image?
IntelliJ IDEA
Eclipse
NetBeans
Visual Studio Code
What is the name of the interface that the Books class implements in the image?
Periodicals
getPeriodicals
getPublisher()
getPublishDate()
What is the name of the interface that the Books class implements in the image?
Periodicals
getPeriodicals
getPublisher()
getPublishDate()
What is the type of the object that is being created in the image?
Mobile
OnePlus
AbstractMobile
Object
Which of the following is the correct way to declare a variable of type List in the image?
List<Integer> list = new ArrayList<>();
List<Integer> list = new LinkedList<>();
List<Integer> list = new Vector<>();
List<Integer> list = new Stack<>();
What is the purpose of the flowchart in the image?
To show the process of writing a sentence.
To show the different parts of a sentence.
To show the different types of sentences.
To show how to write a sentence in a specific style.
What is the name of the class that is being created in the image?
Laptop
Notebook
Computer
Device
What is the default value of the brand attribute in the Laptop class in the image?
Apple
Dell
HP
None of the above
