You are on page 1of 16

Code, Subject, Grade CSC616–Procedural

Learner Name
Programming – Grade 11
NQA Registration #
ATHS ID

Related NQC Unit and Performance Criteria:

Qualification: Certificate 4 in Computing and Machine Learning

Unit : Write codes for advanced procedural programming


PC# GC/PC Description Mark (tick as
appropriate)

1 2 3 4 5*
PC4.1 Identify the class as the formal implementation, or blueprint of different
objects (instances of a class) with defined attributes and behaviors ▢ ▢ ▢ ▢ x

1 2 3 4 5*
PC4.2 Describe the behaviour of a given code segment in a program based on
concepts of classes and objects and the relationship between them ▢ ▢ ▢ ▢ x

Identify the correct constructor of an object to be called using its 1 2 3 4 5*


PC4.3 signature that consists of the constructor’s name and the formal
parameter list including the types of the values that are passed and their ▢ ▢ ▢ ▢ x
variable names
Pass actual parameter values (call by value) into a constructor that are 1 2 3 4 5*
PC4.4 compatible with the types identified in the formal parameter list based
on a given problem description to establish the initial state of the object ▢ ▢ ▢ ▢ x
and then evaluate the output of a certain code segment accordingly
1 2 3 4 5*
PC4.5 Identify overloaded constructors as multiple constructors with the same
name but a different signature within the program code ▢ ▢ ▢ ▢ x

1 2 3 4 5*
PC4.6 Create objects by calling one of the class’s constructors with or without
parameters using the keyword new ▢ ▢ ▢ ▢ x

1 2 3 4 5*
PC4.7 Identify all constructors created within a class by having the same name
of the class and invoke them to create different objects ▢ ▢ ▢ ▢ x

1 2 3 4 5*
PC4.8 Utilize existing classes and class libraries as appropriate to create
objects within a program ▢ ▢ ▢ ▢ x

1 2 3 4 5*
PC4.9 Define the variables of the correct types to represent reference data of a
given problem ▢ ▢ ▢ ▢ x

1 2 3 4 5*
PC4.10 Identify the keyword null as a special value used to indicate that a
reference is not associated with any object ▢ ▢ ▢ ▢ x

PC4.11 Identify that the memory associated with a variable of a reference type 1 2 3 4 5*
holds an object reference value while the memory associated with a null
▢ ▢ ▢ ▢ x
object holds its address in the memory
PC5.1 Call non-static void methods without parameters correctly within a 1 2 3 4 5*
program
▢ ▢ ▢ ▢ ▢

1 2 3 4 5*
Identify procedural abstraction as a procedure that allows a
PC5.2
programmer to use a method by knowing what the method does even if
▢ ▢ ▢ ▢ ▢
they do not know how the method was written.
1 2 3 4 5*
PC5.3 Identify and write non-parameterized method with signature that
consists of the method name and an empty parameter list ▢ ▢ ▢ ▢ ▢

1 2 3 4 5*
PC5.4 Use the dot operator along with the object name to call non-static
methods through objects of the class ▢ ▢ ▢ ▢ ▢

1 2 3 4 5*
PC5.5 Demonstrate understanding of the fact that void methods do not have
return values and are therefore not called as part of an expression ▢ ▢ ▢ ▢ ▢

1 2 3 4 5*
PC5.6 Identify the causes of the NullPointerException error as using a null
reference to call a method or access an instance variable ▢ ▢ ▢ ▢ ▢

1 2 3 4 5*
PC5.7 Identify the parameterized method by its signature that consists of the
method name and a list of parameter types ▢ ▢ ▢ ▢ ▢

PC5.8 Identify and write non-static void methods with parameters correctly 1 2 3 4 5*
within a program considering the fact that the parameter list need to
correspond to the order and type in the method signature ▢ ▢ ▢ ▢ ▢

1 2 3 4 5*
PC5.9 Identify overloaded methods as the multiple methods with the same
name but a different signature ▢ ▢ ▢ ▢ ▢

PC5.10 Call non-static non-void methods with or without parameters correctly 1 2 3 4 5*


within a program to return a value of the same type as the return type in ▢ ▢ ▢ ▢ ▢
the signature that is saved as a variable or as part of an expression
 Only for First Submission

Rubric
Performance
Score Description
Criteria
Student’s work is meeting the requirements of evidence quality against the
5
criteria identified in the unit of competency, by no less than 90%.
Student’s work is meeting the requirements of evidence quality against the
Achieved 4
criteria identified in the unit of competency, by no less than 80%.
Student’s work is meeting the requirements of evidence quality against the
3
criteria identified in the unit of competency, by no less than 70%.
NOT 2 Student’s work is approaching towards meeting the minimum requirements
Achieved of the evidence quality to demonstrate competency. Work quality must be
improved to be acceptable.
Student submits evidence that lacks quality towards demonstrating
1
competency against the criteria identified in the unit of competency.
0 No evidence of completion submitted.
Assessment writer

Name: Rebhi Alomari Signature: Date: 10/09/22

Assessment verifier’s approval

Verifier’s Name: Ahmed Eid Signature: Ahmed Eid Date:08-09-2022

Learner’s declaration

I certify that the work submitted for this assignment is my own. I have clearly referenced any sources used in
the work. I understand that false declaration is a form of malpractice.

Learner’s signature: Date:

Assessor’s Feedback to the learner

Assessor’s feedback should cover the following:


● Link to relevant PCs
● Justify each PC awarded
● Provide appropriate guidance to the learner without giving specific actions for improvement

Learner’s Feedback about assessment decision

Assessor’s approval

Assessor’s (Teacher) Name: Signature: Date: 00/00/2022

Notes:

 The instructor has the right to change or modify the assessment questions as long as he/she is
fulfilling the specification of the listed Performance Criteria.
 If the instructor changes the questions, they have to be verified by an assessor.
  When uploading the assessments to your ePortfolio, please follow the evidence naming

convention
Question1- Practical Assignment

Answer the following questions:

1- Which of following is correct about class?

A. A class should not have private instance variables.


B. Private instance variables are the interface to the class.
C. Private instance variables hide the implementation of a class from the class user.
D. Private instance variables should rarely be used in classes.

[This provides evidence for PC 4.1]

2- Analyze the following java code and check which of the below statements will give syntax error

Write down the required correction.

3- If you do not supply any constructors, the compiler will make a default constructor automatically.
Which of following is the correct characteristics of the default constructor?
A. It takes one parameter
It initializes all instance variables to their default values

B. It takes no parameters
It initializes all instance variables to their default values

C. It takes no parameters
It initializes all instance variables to "Zero"

D. It takes no parameters
It initializes all instance variables to "NULL"

[This provides evidence for PC4.2]

4- What is overloaded constructor?

[This provides evidence for PC4.5]

5- Refer to the code segment below, how many constructers the programmer has used?
6- Create the Java class that is described below:

Add screenshot(s) showing your code

 Create a Student class with data fields for a student number and a grade point average and 4
constructors as follows:
 A constructor that accepts an int and a double and assigns them the student number and grade
point average, respectively
 A constructor that accepts a double and assigns it to the grade point average, but initializes
every student number to 999
 A constructor that accepts an int and assigns it to the student number, but initializes every
grade point average to 0.0
 A default constructor that assigns 999 to every student number and 0.0 to every grade point
average
[This provides evidence for PC4.4, 4.6]
7- Create a Java program containing the following class:

public class Student { Object StuNum gpa


private int stuNum;
private double gpa; S1 123 3.5
public Student(int stuNum, double gpa)
{ S2 143 3.24

stuNum = stuNum; S3 242 3.9


gpa = gpa;
S4 432 3.0
}
S5 214 3.29
public Student()
{ S6 512 3.98

stuNum = 0; S7 323 3.8


gpa = 0.0;
} S8 0 0.0
}
S9 0 0.0

S10 0 0.0

Create 10 Student objects by calling the proper constructor as described in the table shown above

Add screenshot(s) showing your code

[This provides evidence for PC 4.7]


8- Create a class named Sandwich that contains the following:
1. Data fields include the following:
• a String for the main ingredient

• a String for bread type

• and a double for price

2. A constructor that has no parameters that sets the instance variable as follows:
• mainIngredient="Chicken";

• bread="wheat";

• price=10.0;

3. A constructor that receives three values to set the instance variables


4. Include methods to get and set values for each of these fields.
5. Save the class as Sandwich.java.

[This provides evidence for PC 4.9]


Part 4:

Create an application named TestSandwich that instantiates four Sandwich objects as follows:

• Obj1 to be instantiated by calling the constructor that has no parameters

• Obj2 to be instantiated by passing “Tuna”, “Baguette” and 20.0 to the constructor

• Obj3 to be instantiated by passing “Chocolate”, “Croissant” and 15.0 to the constructor

• Obj4 to be instantiated by passing “Cheese”, “Baguette” and 8.5 to the constructor

• Change the obj1 price to 4.99

• Display the instance variable values for the three objects

[This provides evidence for PC 4.4, 4.8]


Part 5:

Refer to the following class:

public class Circle {

private double radius;


public Circle() { // No-argument constructor

radius =0.0;

public Circle(double r) { // Parameterized constructor

radius =r;

a. Create a reference variable named C1 of Circle class and assign it null.

b. What does null reference mean?

c. Instantiate a Circle object and assign its address to a Circle reference variable C2.

d. What is the difference between C1 and C2?

[This provides evidence for PC 4.10, 4.11]

Question 1- Practical Assignment

1- Label the statement that calls a non-parameters method with NP and the statement that calls method with
parameters with P.
Statement NP/P

s1.getName();

s1.setName(“Hamda”);

s1.printName();

s1.setID(“232”);

s1.getID();

[This provides evidence for PC 5.1]

2- Select the correct answer:


The ability of the program to use a method by knowing what the method does even if they do not know how the
method was written is known as:
A. procedural programming
B. Object oriented programming
C. Procedural abstraction
D. Inheritance

E. Polymorphism
[This provides evidence for PC 5.2]

3- Which of the following method signatures is/are non-parameterized(NP) and which are parameterized (P)?
Method Signature NP/P

public void setName(String name)

public void getName()

public void printName()

public void calculateBMI(double h,double w)

public void calculateBMI()

[This provides evidence for PC 5.3]


4- Write the correct name of the parts in the dot notation used in the statement.

car1.calculateAcceleration(120,150);

_______________parameter list
_______________method name
_______________object name
[This provides evidence for PC 5.4]

5- Explain why the call statement written below by the object student1 to the method printInfo() is not correct.

Method signature: public void printInfo(){…..}


Method call:
String info = student1.printInfo();

[This provides evidence for PC 5.5]

6- When running the code segment below a NullPointerException error occurs. Explain why.

1 String name;
2 System.out.println(name.length());

[This provides evidence for PC 5.6]

7- Knowing that the method calculateBMI needs the height and weight to calculate the bmi value correctly.
Which is the correct method signature for the method calculateBMI?
A. public void calculateBMI()
B. public void calculateBMI(double height, double weight)
C. public void calculateBMI(double height)
D. public void calculateBMI(double weight)

[This provides evidence for PC 5.7]

8- Which of the following method call statements is/are correct when calling the method max by the object
number and which is NOT correct?

Method max signature: public void max(double n1,double n2, double n3)

Method call Correct/Incorrect


number.max(3,4,5)
number.max(3.6,3.3)
number.max(6,7,4.5)
number.max(6 ,4.5)
number.max(1.0,7.0,4.0)

[This provides evidence for PC 5.8]

9- Which of following should be the output after running the following program?

class MethodOverloading{

    public static void main(String s[]){
        print();
        print(8);
        int j = print(9);
    }
    
public static void print(){
        System.out.println("Called print with no parameters");
    }

    public static void print(int i){
        System.out.println("Called print with int parameter with return type
void");
    }
    
public static int print(int i){
        System.out.println("Called print with int parameter with return type
int");
    }
}

A.
Called print with no parameters
Called print with int parameter with return type void
Called print with int parameter with return type int

B. Compilation Error - since there are two methods with int parameter but return type is different.

C. Compilation Error - since there are three methods with the same name print.

D. Runtime Error - It fails with a runtime error, since it does not know which print method to call.

[This provides evidence for PC 5.9]

10- Given the following code segment for Lease class:

class Lease{
private String name;
private int aptNumber;
private double rent;
private int term;
private static final int FEE = 10;
public Lease(){
name = "XXX";
aptNumber = 0;
rent = 1000;
term = 12;
}
public void setName(String tenant) {
name = tenant;
}
public void setAptNumber(int apt){
aptNumber = apt;
}
public void setRent(double monthRent) {
rent = monthRent;
}
public void setTerm(int t){
term = t;
}
public String getName(){
return name;
}
public int getAptNumber(){
return aptNumber;
}
public double getRent(){
return rent;
}
public int getTerm(){
return term;

}
public void addPetFee(){
rent = rent + FEE;
}
}

Create a class named TestLease as instructed below:

a. Instantiate four Lease objects in the main()method.


b. Change the aptNumber value for the first object to 20
c. Change the rent value for the second object to 5000
d. Change the term value for the forth object to 6
e. Display the instance values for each of the instantiated objects

[This provides evidence for PC 5.10]

You might also like