logo

Crowdly

Browser

Додати до Chrome

PROGRAMMING 731(2025S1PRO731D)

Шукаєте відповіді та рішення тестів для PROGRAMMING 731(2025S1PRO731D)? Перегляньте нашу велику колекцію перевірених відповідей для PROGRAMMING 731(2025S1PRO731D) в learning.richfield.ac.za.

Отримайте миттєвий доступ до точних відповідей та детальних пояснень для питань вашого курсу. Наша платформа, створена спільнотою, допомагає студентам досягати успіху!

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

Переглянути це питання

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]

Переглянути це питання

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]

Переглянути це питання

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)

Переглянути це питання

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)

Переглянути це питання

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)

Переглянути це питання

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)

Переглянути це питання

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)

Переглянути це питання

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)

Переглянути це питання

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)

Переглянути це питання

Хочете миттєвий доступ до всіх перевірених відповідей на learning.richfield.ac.za?

Отримайте необмежений доступ до відповідей на екзаменаційні питання - встановіть розширення Crowdly зараз!

Browser

Додати до Chrome