Discussion Unit One for CS1102 Programming
An evaluation of what is permitted and prohibited in the program is done by the
syntax rule, which is a rule of the programming language. A program that has a
syntax error cannot be compiled and cannot run when we attempt to run it. When
using the Java program, the syntax error causes commands to be confusing or
unclear to the computer. If we were to enter a line of code into the program without
including the last semicolon, it would be a nice illustration of a syntax error. The
error can be found and debugged by us as programmers.
The semantics of a computer language refers to its meaning. This means that if the
statement is indeed legitimate, it is read, validated, and then executed. It carries out
your requests. A program with a semantic error can be read and run, but it will
provide the wrong results. Sometimes the evaluation of the semantic error must
occur at runtime since it cannot be performed at compile time. These semantic
mistakes can occur in a variety of ways, such as by using the incorrect variable,
performing operations in the wrong order, or even by using the incorrect operator.
Even if our syntax is correct, if one of our operators is incorrect, the program will
produce an error.
Syntax example:
public class hello{
public static void main(String [] args) {
[Link]("Hello World!
String literal is not properly closed by a double-quote
Semantic example:
int a = "hello";
Type mismatch: cannot convert from String to int