I suspect that the reason your code is crashing is due to the code
if (q1 == null){
q1.add(data);
}
you test the q1 reference to be null, and having found it is, you then try to use it. I suspect there are two things you need to change, firstly you need to instantiate the Queues,currently you create reference variables ( q1 and q2 ) that are capable of referring to a Queue but you never actually create the Queues. Maybe something like
Queue<Integer> q1 = new LinkedList<Integer>();
Queue<Integer> q2= new LinkedList<Integer>();
also you are getting confused between
which says that the variable is not currently referencing a Queue and
which implies the Queue is empty - though there are edge cases where this may not be true, just don't go there yet
