InterviewSolution
Saved Bookmarks
| 1. |
Rewrite the following Java code using switch case statement:Int option=Integer.parseInt(JTextField1.getText ());if (option==1)JTextField2.setText ("Regular Employee");else if (option==2)JTextField2.setText ("On Probation");else if (option==3)JTextField2.setText("Visiting Faculty");else if (option== 4)JTextField2.setText("On Contract");elseJTextField2.setText("Invalid option"); |
|
Answer» int option = Integer.parseInt(JTextField1.getText ()); switch (option) { case 1 : JTextField2.setText("Regular Employee"); break; case 2: JTextField2.setText("On Probation"); break; case 3: JTextField2.setText("Visiting Faculty"); break; case 4: JTextField2.setText ("On Contract"); break; default: JTextField2.setText ("Invalid option"); } |
|