Most probably because you are declaring an array but never initialize it.
Here:
Student sd[]=new Student[2];
sd[0].setName("name");
should read:
Student sd[]=new Student[2];
sd[0] = new Student();
sd[0].setName("name");
Debugging is definitely the way to spot this kind of problems very quickly.