Generics Flashcards
1
Q
Advantage of generics?
A
No casting. Avoid runtime errors by encouraging compile time errors.
2
Q
Write basic generic class.
A
public class Box{}
3
Q
What are types in Java?
A
Classes and interfaces.
4
Q
What is generics?
A
Generics enables classes and interfaces to be parameters when defining classes, interfaces and methods. Called Type Parameters.
5
Q
Give example of generics:
A
public interface List {}
static void arrayToList(T[] a, List c) { …}