Question:
(a) Describe what is meant by a ‘constructor' in Java. Use a simple example to illustrate your answer.
(b) Differentiate between a class method and an instance method. Illustrate with an example.
(c) Explain the different ways you can call a method in Java with appropriate examples.
(d) Write a program which will print the square of the numbers from 1 to 10 on a message dialog. Here you must have a method called square in your program.
(e) Write a program which will test whether the number entered by a user is either even or odd. You may use an input dialog from JOptionPane to prompt the user to enter the number.