logo

Crowdly

Browser

Add to Chrome

PROGRAMMING 731(2025S1PRO731D)

Looking for PROGRAMMING 731(2025S1PRO731D) test answers and solutions? Browse our comprehensive collection of verified answers for PROGRAMMING 731(2025S1PRO731D) at learning.richfield.ac.za.

Get instant access to accurate answers and detailed explanations for your course questions. Our community-driven platform helps students succeed!

1.3 What is the final keyword used for in Java? Describe its three main uses. [10 Marks]

View this question

1.2 Explain why Integer a = 100; Integer b = 100; returns true for a == b but Integer c = 200; Integer d = 200; returns false for c == d and suggest the correct way of comparing Integers.[5 Marks]

View this question

1.1 The concept of ‘Autoboxing’ is of paramount importance in Java Language. Explain what Autoboxing is and provide a scenario where it occurs[5 Marks]

View this question

2.5 For the below Java Code Snippets contain bugs or issues that you need to identify the problem in the code and state the exact problem.

Code Snippet 5

(10 MARKS)

View this question

2.4 For the below Java Code Snippets contain bugs or issues that you need to identify the problem in the code and state the exact problem.

Code Snippet 4

(5 MARKS)

View this question

2.3 For the below Java Code Snippets contain bugs or issues that you need to identify the problem in the code and state the exact problem.

Code Snippet 3

(5 MARKS)

View this question

2.2 For the below Java Code Snippets contain bugs or issues that you need to identify the problem in the code and state the exact problem.

Code Snippet 2

(5 MARKS)

View this question

2.1 For the below Java Code Snippets contain bugs or issues that you need to identify the problem in the code and state the exact problem.

Code Snippet 1

(5 MARKS)

View this question

3.2 The following Java program attempts to create two threads that print numbers from 1 to 5. However, the output is sometimes incorrect or inconsistent.

Possible Output

a. Explain why does the output sometimes show numbers printed in a mixed order (e.g., Thread-B: 3 before Thread-A: 3)

b. Write Java Code on how can we ensure that each thread prints numbers 1 to 5 sequentially (without mixing between threads)?

c. Write Java Code on how can we make Thread-A complete its execution before Thread-B starts? (25 Marks)

View this question

3.1 Design a class hierarchy to model different types of trade tariffs. Your implementation should demonstrate understanding of inheritance and polymorphism.

Class Design

·         Create an abstract base class Tariff with these properties:

name (String)

·         rate (double - represents percentage rate)

·         effectiveDate (String)

·         and one abstract method: double calculateDuty(double productValue)

Create three concrete subclasses that extend Tariff:

·         SteelTariff (adds property: steelType String)

·         AluminumTariff (adds property: countryOfOrigin String)

·         ChinaTariff (adds property: productCategory String)

Method Implementation

·         Implement the calculateDuty() method differently for each subclass:

For SteelTariff:

·         Base calculation is productValue * rate

·         Add 5% surcharge if steelType is "stainless"

·         For AluminumTariff:

·         Base calculation is productValue * rate

·         Add 10% surcharge if countryOfOrigin is "Canada"

For ChinaTariff:

·         Flat $500 fee if productCategory is "electronics"

·         Otherwise productValue * rate

Demonstration

Create a main method that:

·         Creates an array of Tariff objects containing one instance of each subclass

·         Initializes each with appropriate values.

·         Iterates through the array, calling calculateDuty() for a sample product value of $10,000

·         Prints the calculated duty for each tariff

(25 MARKS)

View this question

Want instant access to all verified answers on learning.richfield.ac.za?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!

Browser

Add to Chrome