Let's think about what your code does.
We have two cars between us: my car (a black Mercedes) and your car (a green BMW).
They have a lot of attributes in common: they both have four wheels, the both have a drivers seat, they both have a glovebox.
Suppose you put your mobile in the glovebox of your car, and we go for a ride in mine. Can you access your mobile by opening my glovebox?
Of course you can't - you know that each car is a separate entity and the glovebox isn't "shared" by all cars!
So you also know that if you want to access your mobile, you need to open your car, open that glovebox, and retrieve it.
Classes act the same way.When you declare a variable in a class, it is part of that class, and isn't accessible outside it unless you reference the specific instance of the class.
But what you have done is worse: you have created the Scanner variables inside the class constructor method - and all variables created in a method are local to that method: they are destroyed as soon as the method exits. It's as if the glovebox in a car was emptied automatically when you exit the vehicle! Your mobile that you put in your car's glovebox has been discarded, and you can't access it ever again!
So look at your code:
case 1: teacher a = new teacher();
You create an instance of a teacher, but you never try to use it: instead, you assume that one of the (now destroyed) variables will exist in the ether because you have created it: that a mobile phone will magically appear on the table beside you when you buy a car!
Try using the instance of a teacher you created instead - and go back to your course notes and read them again!