Question 1 of 25
Hints left: 3
Q1
What does the `E` represent in generic class declarations in Java?
Q2
What one of the following is best practice to handle Null Pointer exception? i) int noOfStudents = line.listStudents().count; ii) int noOfStudents = getCountOfStudents(line); public int getCountOfStudents(List line) { if(line != null) { if(line.listOfStudents() != null) { return line.listOfStudents().size(); } } throw new NullPointerException("List is empty"); }
Q3
Which of the following is a generic class in Java?
Q4
In Java generics, what is the purpose of the `? extends T` wildcard?
Q5
Which keyword is used to define generic methods in Java?
Q6
What is the purpose of the `extends` keyword in Java generics?
Q7
In Java generics, what is the purpose of the `` syntax?
Q8
What is the result of the following Java code? List> list = new ArrayList<>(); list.add("Hello");
Q9
Which of the following is a valid use of generics in Java?
Q10
Which of the below is false about java coding?
Q11
In Java generics, what is the purpose of the `? super T` wildcard?
Q12
In a generic class, what does the wildcard `>` represent?
Q13
In Java generics, what is the purpose of the diamond operator (`<>`)?
Q14
Which symbol is used to denote a generic type parameter in Java?
Q15
What is the result of the following Java code? List extends Number> list = new ArrayList<>(); list.add(new Integer(10));
Q16
What is the purpose of the `>` wildcard in a method parameter in Java generics?
Q17
What is type erasure in Java generics?
Q18
Which of the below is true about java class structure?
Q19
What is the main purpose of generics in Java?
Q20
What is the purpose of the `? super T` wildcard in Java generics?
Q21
What does the term "type parameter" mean in Java generics?
Q22
Which of the following is a best practice to measure time taken by a process for execution?
Q23
In Java, which exception is thrown when there is a type mismatch due to generics?
Q24
What is the benefit of using generics with collections in Java?
Q25
Which is better in terms of performance for iterating an array?