0% found this document useful (0 votes)
36 views

Programming 2B ASSIGNMENT 2

This document provides instructions for submitting an individual assignment through an online learning platform. It outlines 7 steps for uploading an assignment submission through the myClass page and notes important details like file size limits and draft submission status. It also includes sample multiple choice and written response questions that assess knowledge of exceptions and exception handling in Java programming.

Uploaded by

diloeoctobee2
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

Programming 2B ASSIGNMENT 2

This document provides instructions for submitting an individual assignment through an online learning platform. It outlines 7 steps for uploading an assignment submission through the myClass page and notes important details like file size limits and draft submission status. It also includes sample multiple choice and written response questions that assess knowledge of exceptions and exception handling in Java programming.

Uploaded by

diloeoctobee2
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Programme Diploma: Information Technology

Module Programming 2B

Module Code 23_HE_FT_DP_IT_PRG220_Y2

NQF Level 6

Credits

Assessment Type Assignment 2


Semester 2ND

Due Date 29/09/2023

Total marks 100

Pass mark 50%

Weighting 20%

Examiner L. ZUKA
This question paper consists of 6 pages including the cover page.

IMPORTANT: INDIVIDUAL ASSIGNMENT SUBMISSION INSTRUCTIONS

STEP 1:
Scroll down to the Individual Assignment Section of your myClass page.
STEP 2:
Click on the Submission Icon

STEP 3:

Click on the “Add Submission” button.


STEP 4:
You will be able to add your assignment here. Take note of the maximum size that can be uploaded,
and how many attachments you are allowed.
STEP 5:

Once you have added your attachment, it will appear in the File submissions block, click on ‘Save
changes'

STEP 6:

It is important to note that the assignment is NOT submitted yet – it will state “Draft (not submitted)”

At this step, you are still able to edit your submission.

Should you click on “Edit Submission”, you will be taken back to Step 4, where you will be able to
reupload the correct document.

To confirm the draft version that is already there, click on “Submit assignment”.
STEP 7:

To confirm your submission, be sure to check the box that appears there, and then click on ‘Submit’.
STEP 8:
Once you have clicked on Continue, you will see that the submission status has been changed to
“Submitted for grading”
Only once it states submitted for grading, the process of the online submission is complete.
SECTION A

Question 1 (20)

Indicate whether the statement is true or false.


You can place as many statements as you need within a try block, and you can catch as
many exceptions as you want.
a. a. True
b. False

Placing data conversion attempts in a try block allows you to handle potential data
conversion errors caused by careless user entry.
b. a. True
b. False

A catch block is a method that can be called directly and takes an argument that is some
type of exception.
c. a. True
b. False

Comma-separated values (CSV) is a file format strictly used for working with Java and
databases.
d. a. True
b. False

Since variables declared within a try or catch block are local to that block, the variable
goes out of scope when the try or catch block ends.
e. a. True
b. False

Enter the appropriate word(s) to complete the statement.


____________________ is an abstract class that contains methods for performing
f.
output.

The ____________________ class comprises less serious errors that represent unusual
g.
conditions that arise while a program is running and from which the program can recover.
In order to use a variable both with a try or catch block and afterward, you must declare
h.
the variable before the ____ block begins.

The ____ method returns the last Path element in a list of pathnames.
i.

Any of the file input or output methods in a Java program might throw an exception, so
j.
all the relevant code in the class is placed in a ____ block.

SECTION B

Question 2 (20)

Give a sample/skeleton code (or format ) of the try…catch …finally sequence.


2.1 (10)
Explain three different outcomes of the try block that would cause the code in the finally
block to execute.

public interface FindTheError


{
void firstMethod(int anIntNum)
{
2.2 System.out.println("Did you find the error?"); (4)
}
}

What is the problem with the above interface? How would you correct the interface?

public abstract class Car


{
private String model;
public abstract void color();
2.3 public String getName() (6)
{
return model;
}
public void setName(String carModel)
{
model = carModel;
}
}

Using the code above, would it be possible to create a class in which you declare a Car
object with the statement Car myCar = new Car("Honda");?
Explain why or why not.

SECTION C

Question 3 (30)
Create a Division application that accepts 2 values- a numerator and denominator and
create a try-catch block that will catch any type of Exception object and display the
message “Invalid operation”.

Question 4 (30)
Write a Java program that reads a file and throws an exception if the file is
empty.

“End of Paper!!!”

You might also like