1. Response to the following statements by
circling either T (TRUE) or F (FALSE). [10M]
I. i)Without programs, a computer is an
empty machine. ( T / F )
II. ii) Java is NOT a high-level language.
( T / F )
III. iii)Java enables users to develop and
deploy applications on the Internet for servers, desktop computers, and small
hand-held devices.( T / F )
IV. iv) Java is one of language that support
object oriented programming. ( T / F )
V. v)Reserved words or keywords are
words that have a specific meaning to the compiler and cannot be used for other
purposes in the program. ( T / F )
VI. vi) The main method looks like this: (
T / F )
|
VII. vii)An identifier is a sequence of
characters that consist of letters, digits, underscores (_), and dollar signs
($).( T / F )
VIII. viii)An identifier must start with a
letter, an underscore (_), or a dollar sign ($). It cannot start with a digit. (
T / F )
IX. ix) Logic Errors Produces incorrect
result. ( T / F )
X. x) Run Time Error is an error that occurs during the execution of a
program. ( T / F )
2. Match the following Statement
/ Name to its description. [8M]
No
|
Statements
|
Description
|
|
I.
|
x = 1;
|
Increment
|
|
II.
|
int x = 1;
|
Addition
|
|
III.
|
double radius;
|
Declaring Variables
|
|
IV.
|
final int SIZE = 3;
|
Declaring and Initializing
|
|
V.
|
+
|
Assignment Statements
|
|
VI.
|
*
|
Remainder
|
|
VII.
|
%
|
Multiplication
|
|
VIII.
|
++
|
Constants
|
3. Give a brief
explanation for the following question. [10 M]
I.
What is debugging? [2 marks]
II.
What is the difference between a constant and
a variable? [2 marks]
III.
Explain
sequence, selection and
iteration as used in programming. [6 marks]
4. Which of the following are invalid
identifiers, why? [10 marks]
I.
my
II.
my#address
III.
my_address
IV.
my address
V.
JAVA
5. Show an evaluation tree for the
following expressions: [6 marks]
I.
10 + 2 - 2
II.
3 + 3 * 3 % 2
III.
3 + 2 / 5 +2 * 4
6. (Computing the volume of a cylinder) Write an
algorithm and a Java program that reads in the radius and length of a cylinder
and computes its volume using the following formulas: [20
marks]
Area
|
= radius
* radius * p
|
volume
|
= area *
length
|
7. (Finding the largest)
Write an algorithm and a java program that two integers and find the
largest. [20 marks]
1. T,F,T,T,T,T,T,T,T,T
2.
3.
4.
5.
6.
7.
Question 7
Pseudocode
-----------
1.Input two integers (N1 and N2)
2.IF N1 bigger then N2 then
output N1
else
Output N2
Flowchart
---------
Pseudocode
-----------
1.Input two integers (N1 and N2)
2.IF N1 bigger then N2 then
output N1
else
Output N2
Flowchart
---------
No comments:
Post a Comment