Assignment 1
Assignment 1
Instructions
Assignment document must contain a title page showing Assignment-1, your name and
registration number.
Assignment document must also contain JAVA source code (For JAVA Programming Questions)
along with output.
You must follow proper JAVA naming convention for identifiers and properly document your
source code
Plagiarism: Plagiarism is not allowed. If found plagiarized, zero marks will be awarded in the
assignment.
COMSATS University Islamabad
Department of Computer Science
Programming Fundamentals (CSC103)
Class Assignment – 1 (CLO-1)
a. Write JAVA statements that can produce Syntax Errors. Give three different examples
and write the names of errors
b. Write JAVA statements that can produce Logical Errors. Give three different examples
and briefly explain the reason (1-2 lines)
c. Write JAVA statements that can produce Run Time Errors. Give three different examples
and briefly explain the reason (1-2 lines)
d. The following program has syntax errors. Write clearly type of error and its correction
(in tabular form). After you have corrected the syntax errors, show the output of this
program.
Question – 2: This question focuses on the basic elements of JAVA language (comments,
Special Symbols, Reserve Words and Identifiers)
You are required to identify following (Show your answer as tabular form)
- comments (Single Line, Multiline),
- Special symbols (three)
- Reserve words (three)
- Identifier (predefined and defined by user) (three each)
- Standard Input Stream Object
- Standard Output Stream Object
COMSATS University Islamabad
Department of Computer Science
Programming Fundamentals (CSC103)
Class Assignment – 1 (CLO-1)
Question – 3: This question focuses on the basic elements of JAVA language (Primitive Data
Types, Expressions and Assignments, Arithmetic Operators, Order of Precedence, Augmented
Assignment Operators, Type Conversion)
c. Suppose a, b, and sum are int variables and c is a double variable. What value is
assigned to each variable after each statement executes?
NOTE: Consider a = 3 , b = 5 , and c = 14.1 for all of the following
statements.
Statements a b c sum
sum = a + b + ( int) c;
c /= a;
b += (int) c - a;
a *= 2 * b + (int) c;
COMSATS University Islamabad
Department of Computer Science
Programming Fundamentals (CSC103)
Class Assignment – 1 (CLO-1)
Question – 4:
COMSATS University Islamabad
Department of Computer Science
Programming Fundamentals (CSC103)
Class Assignment – 1 (CLO-1)
Question – 5:
Question – 6:
Question – 7:
Question – 9:
Question – 10: