Java Programming (With Name)
Java Programming (With Name)
SEMESTER 7 / 2020
CDOP3203
JAVA PROGRAMMING
MATRICULATION NO : 900307115181001
IDENTITY CARD NO. : 900307115181
PROGRAMME : DIPLOMA IN INFORMATION TECHNOLOGY
TELEPHONE NO. : 01133500911
E-MAIL : atiff_arafat@oum.edu.my
LEARNING CENTRE : TERENGGANU LEARNING CENTRE
PART A
1. Inheritance
2. A “subclass” is created when it is derived from “another class”. The class that is derived
from is also known as “superclass”. It’s a hierarchy of objects in which the “subclass inherits
from “superclass”.
3. The correct method to access a priate data from a different class is by creating and using
“getter” and “setter” methods. This is also called “accessor” and “mutator” methods.
4. 5
5. “Method overriding” is an approach that replaces a relatively similar method from the
inherited class in a subclass. Usually, the “overriding method” have the same name, number
and types of parameter values, and return value type as the inherited method.
PART B
Question 1
public class Account {
Question 2
public class Person {
public Person () {
Name = "";
Address = "";
Phone = "";
Email = "";
}
public Person (String name, String address, String phone, String email) {
Name = name;
Address = address;
Phone = phone;
Email = email;
}
public Student () {
super();
StudentNo = "";
}
public Student (String name, String address, String phone, String email, int studentno) {
super(name, address, phone, email);
StudentNo = studentno;
}
public Employee() {
super();
Salary = 0.00;
DepartmentId = 0;
}
public Employee(String name, String address, String phone, String email, double salary,
int departmentid) {
super(name, address, phone, email);
Salary = salary;
DepartmentId = departmentid;
}
public double getSalary() {
return Salary;
}