Q1medium
You want to write a function that can accept any List, but you want to ensure the items in the list are at least a type of Animal (e.g., Dog or Cat). Which concept should you use?
Topic-wise practice questions for Programming (C++ / Java / Python). Test your knowledge, check solutions on demand, and pace your preparation.
list = [1, 2, 3, 4]
result = list.filter(x -> x > 2).map(x -> x * 2)
print(result)
template <typename T>
T add(T a, T b) { return a + b; }
print(add(5, 10));
print(add(2.5, 1.5));
What is the output?