Uploaded by Romeo Arthur

DISCUSSION ASSIGNMENT 1 FOR UNIT 1 PROG 1

advertisement
DISCUSSION ASSIGNMENT 1 FOR UNIT 1
Similar to all normal spoken languages, there are rules that pertains the use of diction and distribution
of our spoken words. Just like in a normal setting, programming languages also have same. Syntax refers
to the rules that controls what is permitted and accepted and defines how a program is organized.
These rules specify the fundamental building blocks or vocabularies of the language and how programs
could be constructed with materials like loops, branches and methods. To say a program is syntactically
correct, the program should be able to be compiled or interpreted. As a programmer, it is not enough to
just write programs but also be able to know into details the syntax in which you are writing your
program.
Everyone can write a program for it to run but that is not all that is takes to be a programmer. A
successful programmer should be able to understand the meaning of the program. A program that
produces what you want it to is a semantically correct program.
Programs run on rules and meaning or understanding of the set of rules of the program therefore it is
important for a programmer to know the rules(syntax) and understand the meaning of the set of
rules(semantics) of the program he is writing.
A syntax error in java is the use of incorrect rule or omission in the language used in creating a program.
For example;
int a = 13 //
OUTPUT
Test.java:10: ‘;’ expected
int a = 13
This error is as a result of mission semicolon which is supposed to be used in ending a code.
A semantic error refers to when the syntax of a code is correct but the usage in style is inappropriate.
For example;
int a = “Vibex”; //
This error is as a result of the combination of string and integer which is not compatible.
Eck, D. J. (2019). Introduction to programming using Java, version 8.1.
http://math.hws.edu/javanotes
Download