Beruflich Dokumente
Kultur Dokumente
Mid-term – MOCK
Total Marks: 60
Exam Instructions:
• Total Number of Question is 5 totally of 60 marks.
• ALL questions must be answered in the External Answer booklet.
• Be sure you write your name and ID on the External Answer booklet.
• Go through each and every question before you start answering it. Note that the
estimated time for each question is mentioned in the question header.
• Place your question paper in the answer booklet and give them to the invigilator.
• Student handbooks are NOT permitted in this examination.
• Electronic devices that could have a memory are NOT permitted in this
examination.
Part I - Multiple Choice Questions (10 Marks)
This part consists of 6 multiple choice questions. For each question, encircle the label A, B, C,
or D as your most appropriate answer. Each question carries 2 points.
a. 10 b. 50
c. 1 d. 1050
𝒙 − 𝒚 ∗ 𝒚 + (𝒙 − 𝟐) ∗ (𝒚 − 𝒙)
=6 1
𝒙 − 𝒚 ∗ 𝒚 + 𝟔 ∗ (𝒚 − 𝒙)
=-4 2
𝒙 − 𝒚 ∗ 𝒚 + 𝟔 ∗ (−𝟒)
= 16 3
𝒙 − 𝟏𝟔 + 𝟔 ∗ (−𝟒)
= - 24 4
𝒙 − 𝟏𝟔 − 𝟐𝟒
=-8 5
− 𝟖 − 𝟐𝟒
= - 32 6
ANSWER:
if(number = = 1) //0.5 Mark
System.out.println("AAA");
else if(number = = 2) //0.75 Mark
System.out.println("BBB");
Else if(number = = 3 || number = = 4) //1.25 Mark
System.out.println("CCC or DDD");
else //0.5 Mark
System.out.println("out of the period!");
ANSWER: 3 marks for each error, 1 mark for detecting the error,1 mark for the
error type and 1 mark for the correction
Error 1: Syntax (compilation) error; using nextDouble to read an integer value
Error 2: logic error; using + in the println statement without surrounding a+b with
parantheses beacuase this will print the value of a beside the value of b not the sum value.
int a = 10;
int b = input.nextInt();
System.out.println("a + b = " + (a + b) );
Sample Run:
Enter your weight (kilograms): 110
Enter your height (meters): 1.75
Your BMI value = 35.92
You are OBESE
ANSWER:
import java.util.Scanner; //1 Mark
public class BMI {
public static void main(String[] args) {
Scanner input = new Scanner(System.in); //1 Mark
System.out.println("Enter your weight (kilograms): "); //0.5 Mark
double w = input.nextDouble(); //1 Mark
System.out.println("Enter your height (meters): "); //0.5 Mark
double h = input.nextInt(); //1 Mark
double bmi = w / (h * h); //1.5 Mark
System.out.printf(" Your BMI value = %.2f\n", bmi); //1 Mark
if(bmi < 18.5) //1 Mark
System.out.printf("You are UNDERWEIGHT”); //1 Mark
else if(bmi <= 25) //1 Mark
System.out.printf("You are IDEAL”); //1 Mark
else if(bmi <= 30) //1 Mark
System.out.printf("You are OVERWEIGHT”); //1 Mark
else //0.5 Mark
System.out.printf("You are OBESE”); //1 Mark
}
}
– End of Exam –