here is my rewrite but I think Tamil's did the same thing:
PHP Code:
select student_id from (
  
select student_id,
   
max(decode(course'java'student_id)) java,
   
max(decode(course'c'student_id)) c,
   
max(case when course not in ('java''c'then 'x' endx
  from my_table
  group by student_id
)
where java is not null and c is not null and x is null