Answer:
Following error are present in the given code:
1. I in Import javax.swing.JOptionPane; is capital.
2. Spaces are there in class name Welcome to JAVA
3. Return type not mentioned for Main function.
4. Second argument (Welcome To Java) in function showMessageDialog() not enclosed within double quotes.
5. Main method and Class not enclosed within curly braces.
Step-by-step explanation:
Following are fixes and explanation for above errors.
Error 1:
Since Java is case sensitive therefore I in import should be small. Correct statement is as follows:
import javax.swing.JOptionPane;
Error 2:
In Java identifiers cannot have spaces. Since Welcome to JAVA is an identifier thus it should not contain any spaces. Correct statement is as follows:
public class welcomeToJava{
Error 3:
In Java every method should have a return type. Main() method has return type of void. Thus void keyword should be present after static. Correct statement is as follows:
public static void main(String[] args)
Error 4:
Second and third argument in method showDialog() should be of string type. Thus they should be enclosed within double quotes. Correct statement is as follows:
JOptionPane.showMessageDialog(null,"Welcome To Java","Display this Message",JOptionPane.INFORMATION_MESSAGE);
Error 5:
All methods and class should be enclosed within an opening and closing curly braces.
Thus complete correct code will be as follows:
import javax.swing.JOptionPane;
public class welcomeToJava{
public static void main(String[] args) {
// Display welcome to java in a dialogue box
JOptionPane.showMessageDialog(null,"Welcome To Java","Display this Message",JOptionPane.INFORMATION_MESSAGE);
}
}