In Java define a class quizQuestion In this class define a m
In Java define a class quiz.Question. In this class define a method named answer. Define this method so that it returns a count of all the elements of its argument, an ArrayList, that have length 3. If the argument is null, return 0.
Solution
//save the below code as quiz.java
import java.util.ArrayList;
 public class quiz {
 public static void main(String args[])
 {
 ArrayList a=new ArrayList();
 //passing the arraylist with no elements to the method answer
 System.out.println(answer(a));
 //adding elements to arraylist
 a.add(\'a\');
 a.add(\'b\');
 a.add(\'c\');
 //passing the arraylist with 3 elements to the method answer
 System.out.println(answer(a));
 }
 static int answer(ArrayList a)
 {
 //size method returns 0 if ArayList is null(no elements) otherwise returns numberof elements
 return a.size();   
 }
 }
 /*Example output.
 0
 3
 */
 //Comment if any clarification or if you want answer in any other method...
 //thanks

