Final Exam Comp Prog 1 2020 PDF
Final Exam Comp Prog 1 2020 PDF
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
8. Which one of the following will be used for multiple lines of comment?
A. //
B. /* */
C. A and B
D. None
Part3: Answer only three (3) questions. Question six (6) is compulsory with 10 marks [20Marks]
___________________________________________________________________________________
___________________________________________________________________________________
___________________________________________________________________________________
int count = 1;
while(count <= 10 ){
System.out.println(count)
count++
}
___________________________________________________________________________________
___________________________________________________________________________________
___________________________________________________________________________________
6. Write down the output of the following expressions. The first one has been done