L3, Basics of Java Syntax, Correct the Error, and Error in Syntax package, package q10800 & q10801

In English language we normally use a Period (. also called Full Stop) to terminate a statement.

Similarly in Java, a semicolon ; is used to terminate a statement.

For example:

int x = 3;

int y = x + 4;


If we miss the semicolon at the end of a statement, it is a syntax error. And while compiling, Java compiler will flag an error.

For example, click Submit on the below code without fixing the error and notice the compilation error. And later you can fix the problem and re-submit the code.

package q10800 :-

package q10800;
public class PrintHello {
    public static void main(String[] args) {

Correct the Error in Syntax.
Identify the error and correct it.

package q10801 :-

package q10801;
public class PrintHello {
    public static void main(String[] args) {
        String text1 = "He";
        String text2 = "llo, ";
        String text3 = text1 + text2;
        String text4 = "I am learning Java";
        String text5 = text3 + text4;
        System.out.println("text5 = " + text5);

Post a Comment