Professional Documents
Culture Documents
INTERMEDIATE PROGRAMMING. Midterm Exam.
INTERMEDIATE PROGRAMMING. Midterm Exam.
Directions:
Part I: (1 point each)
1. Refer to Java Program Coding and Debugging Class discussions and
presentation. (Item 1-4).
2. Give the Program title functions and descriptions. (Item 1-4 only)
3. Place the following after each item: (Note: Source line number is located at the
end of each statement.).
3.1. Error codes with explanation
3.2. Debugging codes with explanation
boolean result;
Encoding result is the solution in this line problem to complete the
statement.
1.7. unclosed string literal (10)
This error shows because we forgot to encode a particular symbol to complete
the statement.
Debugging codes with explanation
Program output
Always insert the incremental operator (++) and decrement operator (--)
with the variable for us to successfully declare the things that we want to
do with the int. and to run it successfully.
2.2. flip operand of the binary operator (29)
There is a missing close parenthesis in this source line that is why
this kind of program error shows.
2.4. May split into a declaration and assignment, Variable a is never read (16)
This error shows because the variable a wasn’t declared as string at the line
19.
Debugging codes with explanation
Program output
var = a;
After creating a variable, it is important to assigned a data type to its
designated purpose.
Program output
4. Java Ternary Operator
4.1. Illegal start of expression (11)
In this part the error is equal sign that is why there's an error in the declaration
String result;
I removed the equal sign (=) before the semicolon (;)
4.2. package system does not exist (9)
This error arouses because the package name that we named in the folder is
different on what we declared in the program.
package javaternaryoperator;
Some programmers don’t include to indicate the package name
in the source code program but it is also important because
when we named a folder it will automatically shows in the
program when we start to encode.
Program output
Part II: (2 points each)
2. Java Input
a. Functions
The data that the user give to the program.
b. Examples
// create an object of Scanner
Scanner input = new Scanner(System.in);
// take input from the user
int number = input.nextInt();
3. Java Output
a. Functions
To send output into a standard output and be able to accept the
output data in the program.
b. Examples
4. Java print()
a. Functions
println adds new line after print text on console
b. Examples
5. Java Variables and Literals
a. Functions
Java variables is located in memory that holds data and has a unique
name as its identifier while literals are data’s that is used in
representing fixed values.
b. Examples
VARIABLES
LITERALS
int a = 8;
float b = 6.8;
char c = 'G';
9. Java println()
a. Functions
println adds new line after print text on console
b. Examples