1/25
Looks like no tags are added yet.
What does extends mean in Java?
A class inherits properties and methods from another class.
What does implements mean in Java?
A class agrees to implement the methods required by an interface.
Can a Java class extend multiple classes?
No. A class can extend only one class.
Can a Java class implement multiple interfaces?
Yes.
Which keyword is used with a parent class?
extends
Which keyword is used with an interface?
implements.
What happens if a class implements an interface but does not implement all its required abstract methods?
The class must be declared abstract.
abstract method
A method declared without a body.
A class can implement…
A class can implement multiple interfaces.
How many classes can be extended by another class
A class can extend only one class.
What is polymorphism in Java?
The ability of one thing to take many forms.
What does polymorphism allow?
Different objects to respond to the same method call in different ways.
What are the two main types of polymorphism?
Compile-time and runtime polymorphism.
What is a superclass?
The parent class being inherited from.
What is a subclass?
A child class that inherits from another class
What are generics in Java?
A feature that allows classes and methods to work with different data types.
Why do programmers use generics?
To improve type safety and reduce casting
What symbol is used to represent a generic type parameter?
Angle brackets < >.
What does T commonly represent in generics?
Type. It is a placeholder for a data type.
What does E commonly represent in generics?
Element, often used when working with collections.
What is a generic class?
A class that can work with different data types.
How do you declare a generic class?
class Box<T> { }
What does Box<Integer> mean?
A Box object that stores Integer values.
What is type safety?
Making sure the correct data types are used.
What happens if you try to add the wrong type to a generic collection?
Java produces a compile-time error.
What does <T> mean in a generic method?
The method can accept a value of a specified type.