Answer:
The code after rearrange the question segment:
public class Q// Class declaration of Q name.
{// Open the class body.
public static void main(String[] a) // Main function declaration.
{ //Open the main-function body.
System.out.println("Q"); // Print statement which print Q.
} //close the main-function body.
}//close the class body.
Output:
Q
Explanation:
The correct form of the question segment is written in the answer part. Now, this program can print Q. The syntax used above is described below--
- Firstly the user needs to define the class so the class declaration statement is defined above.
- Then the user needs to open the braces to tell the compiler about the body of the class
- Then the user needs to define the main function which tells the compiler that the execution starts from there.
- Then the user needs to open the braces to tell the compiler about the body of the main function.
- Then the user needs to define the print statement which helps to print 'Q'.
- Then the user needs to close the braces to tell the compiler that the main function body id closed.
- Then the user needs to close the braces to tell the compiler that the class body id closed.