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

Lab - Exp - 7 (Dealing With Polymorphism and Inheritance)

This document outlines an object-oriented programming laboratory exercise on polymorphism and inheritance. The exercise involves students creating Java programs that demonstrate polymorphism through method overriding and overloading. It includes three programming activities: 1) creating an interface for comparing time objects, 2) creating classes for persons, students, and teachers using inheritance, and 3) creating an arithmetic class with overloaded and overridden methods. The document provides evaluation criteria for grading students' programs based on execution, output, logic, code quality, and timeliness.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views

Lab - Exp - 7 (Dealing With Polymorphism and Inheritance)

This document outlines an object-oriented programming laboratory exercise on polymorphism and inheritance. The exercise involves students creating Java programs that demonstrate polymorphism through method overriding and overloading. It includes three programming activities: 1) creating an interface for comparing time objects, 2) creating classes for persons, students, and teachers using inheritance, and 3) creating an arithmetic class with overloaded and overridden methods. The document provides evaluation criteria for grading students' programs based on execution, output, logic, code quality, and timeliness.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 5

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:

1. Create an interface named Comparison whose method can be used to compare two
Time objects. The methods will include isGreater, isLess, and isEqual.

2. 2.1. Create class Person with attributes name, age and gender.
2.2. Create class Student with attribute grade and,
2.3. Create class Teacher with attribute salary.
Note:
Class Student and Teacher must inherit from Person.
In main class, create and print two students and one teacher.
Apply inheritance, setter and getter.

Sample Output:
Student 2:
Name: Rachel
Age: 15
Gender: F
Grade: 2.50
3. 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)

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?
b. Which method hides a method in the superclass?
c. What do the other methods do?
______________________________________________________________________________
______________________________________________________________________________
_____________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
____________________________________________________________________________

Note: The following rubrics/metrics will be used to grade students’ output in the lab
Exercise 7.

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


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-11pts)
syntax or runtime errors (15-17pts) errors (12-14pts)
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 do significant logic incorrect (10-
designed (18- no significantly errors (3-5pts) 11pts)
20pts) affect the results
(15-17pts)
Standards Program code is Few inappropriate Several Program is poorly
(20pts) stylistically well design choices inappropriate written (10-11pts)
designed (18- (i.e. poor variable design choices
20pts) names, improper (i.e. poor variable
indentation) (15- names, improper
17pts) indentation) (12-
14pts)
Delivery The program was The program was The program was The program was
(10pts) 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 Abstraction


Lab Activity No 7a
Lab Activity Comparison
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 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 7a
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