Question 1 [12 marks]
1.1 Explain the role of program statements in the context of programming languages and discuss the difference between a compiler and an interpreter in translating and executing these statements. (4 marks)
1.2 Describe the differences between procedural and object-oriented programming. (4 marks)
1.3 Explain how objects are created from classes within Object-Oriented Programming and differentiate between the two. (4 marks)
Question 2 [13 marks] You are a programming instructor conducting a workshop for beginners. During the workshop, you encounter a situation where one of the participants, Alex, is struggling with debugging their code. Alex has encountered several compile-time errors in their program and is having difficulty understanding the error messages and fixing the issues.
2.1 Explain why it is essential for programmers to understand and interpret error messages generated by compilers. (4 marks)
2.2 Define the difference between syntax and logic errors in programming using examples, emphasising their effects on compilation and execution phases. (6 marks)
2.3 How do syntax errors and logic errors affect the compilation and execution phases of a program? (3 marks)
Question 3:
Code Snippet:
public class StorageUnit {
public static final int MAX_CAPACITY = 100;
public static void main(String[] args) {
int currentCapacity = 50;
int newAddition = 30;
int updatedCapacity = currentCapacity + newAddition; System.out.println(“Current Capacity: ” + currentCapacity); System.out.println(“New Addition: ” + newAddition);
System.out.println(“Updated Capacity: ” + updatedCapacity);
}
}
3.1 Explain the concept of named constants in Java programming. (2 marks)
3.2 List and explain four advantages of incorporating named constants into programming. Use the provided code snippet to enhance your answer.(12 marks)
3.3 Refer to the provided code snippet and explain how the constant MAX_CAPACITY exemplifies a named constant. (2 marks)
Questuion 4:
Code snippet:
public class NumberClass {
// Method with access specifier, static modifier, return type, identifier, and empty parentheses
public static int numberMethod() {
// Method body return 42;
}
public static void main(String[] args) {
// Calling the numberMethod int result = numberMethod();
System.out.println(“Result: ” + result);
}
}
4.1 Identify the components of the method header in the provided Java code snippet and explain how each component contributes to defining the methods’s behaviour and usage. (14 marks)
4.2 Define the functions of the components mentioned in question 4.1. (5 marks)
Question 5:
You, a newly hired employee at a local store, are tasked with developing a salary calculator. You must create a Java program to calculate employee salaries based on hours worked and hourly rates, ensuring accurate tax deductions. The program should adhere to the following requirements:
1. Declare and use constants and variables for storing salary-related information.
2. Utilize appropriate integer and boolean data types.
3. Implement the Scanner class to receive keyboard inputs for relevant data.
4. Create methods with return values, add parameters to methods, and demonstrate method overloading.
5. The program should calculate the salary based on given inputs and display the result.
Answers to Above Questions on Systems Development
Answer 1: When it comes to the role of program statements in programming language, the role is quite crucial as the program statements are known as the building blocks in case of any type of computer program. Program statements are generally defined as a type of statement that is written in a programming language and it is easier for the computer to understand and perform the action as written in the language.
Content Removal Request
If you believe that the content above belongs to you, and you don’t want it to be published anymore, then request for its removal by filling the details below. It will only be removed if you can provide sufficient evidence of its ownership.