0% found this document useful (0 votes)
183 views4 pages

Final Exam Comp Prog 1 2020 PDF

This document contains a final exam for a Computer Programming I course at the University of Hargeisa College of Computing and IT. The exam has three parts: 1. Part 1 has 10 true/false questions about Java variables, literals, data types, and the JDK. 2. Part 2 has 10 multiple choice questions about Java compilers, data types, operators, and control flow. 3. Part 3 has short answer and coding questions about loops, output, and operators in Java. It includes a compulsory question to write the output of several relational expressions.

Uploaded by

Mustafe Elabe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
183 views4 pages

Final Exam Comp Prog 1 2020 PDF

This document contains a final exam for a Computer Programming I course at the University of Hargeisa College of Computing and IT. The exam has three parts: 1. Part 1 has 10 true/false questions about Java variables, literals, data types, and the JDK. 2. Part 2 has 10 multiple choice questions about Java compilers, data types, operators, and control flow. 3. Part 3 has short answer and coding questions about loops, output, and operators in Java. It includes a compulsory question to write the output of several relational expressions.

Uploaded by

Mustafe Elabe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

UNIVERSITY OF HARGEISA

COLLEGE OF COMPUTING AND IT


COURSE: COMPUTER PROGRAMING I FINAL EXAM (60 marks)

Name :____________________________________________________________ Class


:_____________

Part 1: Write true or false in the spaces provided [20Marks]


1. ___________Java variable names can contain digits and letters only.
2. ___________Java variables names can start with numbers.
3. _________Java is case sensitive, which means, capital letters are different from small letters.
4. __________The value that we assigned a variable is called literal.
5. __________JDK Stands for Java Development Kit
6. __________Java programs can only run on Windows Operating Systems environment
7. __________Switch is a repetition structure
8. __________Java byte code is saved in a .class file
9. __________To create a variable, you must specify the type and give it a name
10. __________String is one of the eight java primitive data types

Part 2: Circle the most correct answer [20 Marks]


1. The primary java compiler included in the JDK is called
A. JAVNA
B. JAVAC
C. JAVA_C
D. None

2. Java compiler converts the source code that you wrote into a
A. Bit-code
B. Byte-code
C. Barcode
D. All

3. What does Java do if you give it a number where it wants a true or false value?
A. It refuses to compile.
B. It crashes during execution.
C. It stupidly takes any nonzero value to be “true”, and zero to be “false”
D. All
4. What is the difference in results from the left and right program parts:

int x = 2; int x = 2;
if(x == 2) if (x == 2) {
System.out.print(“Strange”); System.out.print(“Strange”);
System.out.print(“Mathematics”); System.out.print(“Mathematics”);
}
Left output Right output
A. Strange Mathematics / Strange Mathematics.
B. Mathematics / No output.
C. No output / No output
D. No output / Strange Mathematics

5. Which one of the following data types is not a primitive data type
A. int
B. double
C. float
D. String

6. ____________can hold one number, one letter or one symbol


A. bool
B. char
C. string
D. double

7. int x = 2+3-1*4/2; The value of x in the above expression will be:


A. 8
B. 3
C. 10
D. None

8. Which one of the following will be used for multiple lines of comment?
A. //
B. /* */
C. A and B
D. None

9. In _____________ repetition structure, all actions are executed at least once.


A. for repetition
B. while repetition
C. do/while repetition
D. All
10. What is the correct syntax of for statement?
A. for(initialization;condition;increment/decrement)
B. for(initialization,condition,increment/decrement)
C. for(condition;initialization;increment/decrement)
D. for(initialization;condition;)

Part3: Answer only three (3) questions. Question six (6) is compulsory with 10 marks [20Marks]

1. List the three repletion/loop structures in JAVA

___________________________________________________________________________________
___________________________________________________________________________________
___________________________________________________________________________________

2. Write a JAVA program to display natural numbers from 1 to 100?


___________________________________________________________________________________
___________________________________________________________________________________
___________________________________________________________________________________
___________________________________________________________________________________
___________________________________________________________________________________

3. Write down the output of the following code snippet?

int count = 1;
while(count <= 10 ){
System.out.println(count)
count++
}
___________________________________________________________________________________
___________________________________________________________________________________
___________________________________________________________________________________

4. Convert the above while loop in question 3 to for loop.


___________________________________________________________________________________
___________________________________________________________________________________
___________________________________________________________________________________
5. List at least five different types of java Operators you know?
___________________________________________________________________________________
___________________________________________________________________________________
___________________________________________________________________________________

6. Write down the output of the following expressions. The first one has been done

int x=5; int y=30;


a. x > y ---------------- FALSE
b. y < x ----------------
c. x == y ---------------
d. x != y ---------------
e. x <= y ---------------
f. x >= y ---------------
g. y > x ----------------
h. x < y ----------------
i. y <= x ---------------
j. y >= x ---------------

You might also like