1/22
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
What is multiple inheritance?
A feature where a class can inherit from more than one superclass.
Why does Java not allow multiple inheritance?
To avoid ambiguity in method and field resolution when two superclasses have the same method or field.
What is an abstract method?
A method that is declared without an implementation and must be overridden in a subclass.
What keyword is used to implement interfaces in Java?
Implements
Can a class in Java implement multiple interfaces?
Yes, a class can implement any number of interfaces.
What is the default access modifier for interfaces in Java?
Public
What is the purpose of an interface in Java?
To define a contract that classes can fulfill, consisting of abstract methods.
How are interfaces defined in Java?
Using the keyword 'interface' followed by the interface name.
What is a default method in an interface?
A method that has an implementation within the interface itself.
What is the Collection interface in Java?
An interface representing any group of objects, with subinterfaces for lists, queues, etc.
What is an ArrayList in Java?
A resizable array implementation of the List interface, providing flexible array operations.
What is the Map interface in Java?
An interface that represents a collection of key-value pairs, similar to a Python dictionary.
What is polymorphism in the context of interfaces?
The ability to use an interface type as a variable type, allowing for different implementations.
What happens if two interfaces have the same variable name?
It causes a compilation error due to duplicated variable names.
What is the significance of the Stack interface?
It defines a contract for stack operations, allowing for various implementations without exposing details.
What is the difference between a class and an interface?
A class represents a type of thing, while an interface represents a notion or trait.
Can interfaces extend other interfaces?
Yes, interfaces can extend other interfaces and can extend more than one interface.
What is the role of static final fields in interfaces?
They can be defined in interfaces, but any duplication across interfaces leads to compilation errors.
What is an example of an interface that represents a trait?
HasLegs, which can be implemented by any class that has legs.
What is a key characteristic of Java Collections?
They can only contain objects, not primitive types.
What does the <> symbol signify in Java's ArrayList?
It specifies the type of elements contained in the list.
What is the relationship between interfaces and method implementation?
Interfaces define methods that must be implemented in the classes that use them.
How does Java ensure backward compatibility with collections?
Existing classes like Stack cannot be removed even after introducing interfaces.