Ask Question

Which of the following statements is correct?

A) Every statement in a program must end with a semicolon.

B) Every line in a program must end with a semicolon.

C) Every method must end with a semicolon.

D) Every comment line must end with a semicolon.

E) Every class must end with a semicolon

+5
Answers (1)
  1. 16 November, 16:36
    0
    A

    Explanation:

    In Java, C++, C# programming languages every statement (executable statements must end with a semi-colon (; ). The semi-colon indicates an 'end of thought' and it is a compiler error to omit it.

    Other languages like python and microsoft visual basic does not have this requirment.

    So in java

    System. out. println ("Hello World") / /will give a compiller error, missing semi-colon.

    Note that this is different from option (B) in the question because not every line of code ends with a semi-colon for example a line declaring a method or a comment line cannot end with a semi-colon.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Which of the following statements is correct? A) Every statement in a program must end with a semicolon. B) Every line in a program must ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers