You are on page 1of 8

COLLEGE OF COMPUTER STUDEIS


INFORMATION TECHNOLOGY DEPARTMENT

CCS0023L
(Object Oriented Programming)

EXERCISE 7
Dealing with Polymorphism and Inheritance

Student Name /
Group Name:

Name Role

Members (if Group):

Section:

Professor:

I. PROGRAM OUTCOME/S (PO) ADRESSED BY THE LABORATORY EXERCISE


b. Analyze a complex problem and identify and define the computing requirements appropriate
to its solution.
g. Analyze the local and global impact of computing information technology on individuals,
organizations and society.

II. COURSE LEARNING OUTCOME/S (CLO) ADDDRESSED BY LABORATORY


EXERCISE
1 Understand the fundamental principle of object-oriented programming.
3 Apply appropriate modern computing tools and resources to solve computing activities with an
understanding of limitations.

III. INTENDED LEARNING OUTOME/S (ILO) ADDRESSES BY THE LABORATORY


EXERCISE
Create Java programs with Polymorphism and Inheritance

IV. BACKGROUND INFORMATION

Polymorphism is the ability of different objects to respond to the same message in different
ways. This means that different objects can have very different method implementations for the
same message.

Method Overloading is the process of declaring methods with the same name but different
parameter types.

Method Overriding allows a subclass to redefine methods of the same name from a superclass

V. EXPERIMENTAL PROCEDURE:

2. Give a definition of a class named Arithmetic whose methods are three add() and multiply()
and one subtract() and divide().

• Parameter for add() and multiply() should be two, three and four int respectively.
• Parameter for subtract() and divide() should be two int.
• Applying method calling in the main(), test your program by calling the following
methods:

add(1,3) add(1,3,4,5)
multiply(2,3,4)
multiply(1,1)
subtract(3,1)
divide(5,2)
• Main
VI. QUESTION AND ANSWER:

1. Consider the following two classes:


public class ClassA {
public void methodOne(int i) {
}
public void methodTwo(int i) {
}
public static void methodThree(int i) {
}
public static void methodFour(int i) {
}
} public class ClassB extends ClassA {
public static void methodOne(int i) {
}
public void methodTwo(int i) {
}
public void methodThree(int i) {
}
public static void methodFour(int i) {
}
}

a. Which method overrides a method in the superclass?


Based on the code above, the method that overrides a method in the supercalss is the
methodTwo.
b. Which method hides a method in the superclass?
When you look and analyze the codes above, you'll find that the method that hides a
method in the superclass is methodFour.
c. What do the other methods do?
The other methods causes compile-time errors.
Note: The following rubrics/metrics will be used to grade students’ output in the lab
Exercise 7.

Program (100 (Excellent) (Good) (Fair) (Poor)


pts.)
Program Program executes Program executes Program executes Program does not
execution (20pts) correctly with no with less than 3 with more than 3 execute (10-
syntax or runtime errors (15-17pts) errors (12-14pts) 11pts)
errors (18-20pts)
Correct output Program displays Output has minor Output has Output is incorrect
(20pts) correct output errors (15-17pts) multiple errors (10-11pts)
with no errors (12-14pts)
(18-20pts)
Design of output Program displays Program displays Program does not Output is poorly
(10pts) more than minimally display the designed (5pts)
expected (10pts) expected output required output (6-
(8-9pts) 7pts)
Design of logic Program is Program has slight Program has Program is
(20pts) logically well logic errors that significant logic incorrect (1011pts)
designed do no significantly errors (3-5pts)
(1820pts) affect the results
(15-17pts)

Standards (20pts) Program code is Few inappropriate Several Program is poorly


stylistically well design choices (i.e. inappropriate written (10-11pts)
designed poor variable design choices (i.e.
(1820pts) names, improper poor variable
indentation) names, improper
(1517pts) indentation)
(1214pts)
Delivery (10pts) The program was The program was The program was The program was
delivered on time. delivered a day delivered two days delivered more
(10pts) after the deadline. after the deadline. than two days after
(8-9pts) (6-7pts) the deadline.
(5pts)

Topic Polymorphism and Inheritance


Lab Activity No 7a
Lab Activity Person
CLO 1,3
Program execution (20)
Correct output (20)
Design of output (10)
Design of logic (20)
Standards (20)
Delivery (10)
TOTAL

Topic Polymorphism and Abstraction


Lab Activity No 7b
Lab Activity Arithmetic Operations
CLO 1,3
Program execution (20)
Correct output (20)
Design of output (10)
Design of logic (20)
Standards (20)
Delivery (10)
TOTAL

You might also like