*/ What's wrong with this program? /* public MyProgram { public static void main(String[] args); } int a, b, c \\ Three integers a = 3 b = 4 c = a + b System.out.println('The value of c is' + C); {

Respuesta :

ijeggs

Answer:

A lot is wrong with the program given in the question. See the corrected version below:

public class ANot {

   public static void main(String[] args) {

       int a, b, c;

   //Three integers

   a = 3; b = 4; c = a + b;

       System.out.println("The value of c is " + c);

   }

}

Explanation:

Errors:

1. The main method had a semi colon after it. This is wrong

2. An open brace was supposed to follow the main method

3. The declaration of the variables was supposed to end with a semi colon

4. the correct comment style is // and not \\

5. Initialization of variables was supposed to end with semi colons

6. The output statement had C and not c which is the declared and initialized variable..Java is strictly typed

7. Open and closing braces for the class and method wrongly placed