AIJPP224 · JAVAPROGRAMMING II
MID-TERM EXAMINATION
Faculty Information and Communications Technology
Date 02 April 2019
Duration 1 Hour 30 Minutes
INFORMATION FOR CANDIDATE
1. This examination is worth 20% of the overall semester
assessment.
2. The total number of marks available for this examination is (70).
3. This practical test paper contains Four (4) pages including the
cover page.
INSTRUCTIONS TO CANDIDATE
1. Answer ALL questions in Section A and B.
2. Answer Section C practically (Using the PC).
3. If you make a mistake please put a single diagonal line through
the section you wish to be ignored by the examiner.
4. Return all examination papers and scripts upon completion of
the examination including any workings.
Section A: Answer all question(s) [10 Marks]
Student name:
______________________________No.____________________________________
1. What is the difference between Overloading and Overriding? [2]
Answer:
_________________________________________________________________
______________
_________________________________________________________________
______________
_________________________________________________________________
______________
_________________________________________________________________
______________
2. What is the output of the following code? [2]
package javaapplication13;
class A {public void name(){
System.out.println("A");}}
class B extends A{public void name(){
System.out.println("B");}}
public class JavaApplication13 {
public static void main (String[] args) {
B objB = new B();
objB.name();}}
Answer:
3. Write java code to call a base class’s default constructor. [2]
Answer:
4. Suppose if you are in class room that time you behave like a [2]
student, when you are in market at that time you behave
like a customer, when you at your home at that time you
behave like a son or daughter, here one person is presented
in different behaviours. In OOP, what term is used to refer to
this scenario?
Answer:
5. Name any two access modifiers that you know of. [2]
Answer:
Section B: Answer all question(s) [70 Marks]
Question 1 [30]
Limkokwing University of Creative Technology Page 2 of 4
Faculty of Information and Communication Technology
You have been contracted to create a Java application that is meant to set,
using two overloaded constructors, student’s data and display those set
student’s details using getter methods.
Thus, create:
1. Create a StudentData class encompassing the following: [1]
Three class variables (stuID, stuName, and stuAge). [2]
Two overloaded constructors [9]
o Default constructor to initialize class variables to 100,
New Student, and 18, respectively.
o A parameterized constructor to set class variables to new
values.
Getter methods for all class variables [6]
2. A main method to encompass the following:
Create one object of type StudentData class and call a relevant [5]
method to depict the first three (3) lines of output as shown in
figure 1 below.
Create another object of type StudentData class and call [5]
relevant methods to depict the last three (3) lines of output as
shown in figure 1 below.
Note: Please note that all data is hard coded i.e. do not use the Scanner
class to get input.
Area assessed Comment( Mark(
s) s)
a) Correct class creation /
1
b) Correct class variables’ declaration /
2
c) Correct overloaded constructors /
9
d) Correct definition of getter methods /
6
e) Main method: Correct methods called to depict 1st 3 /
lines 5
f) Main method: Correct methods called to depict the last /
3 lines 5
g) Correct syntax, indentation and commenting of code /
1
h) Correct program logic /
1
Limkokwing University of Creative Technology Page 3 of 4
Faculty of Information and Communication Technology
Question 2 [30]
You have been contracted to create another Java application named
Shapes application that encompasses abstract classes, inheritance and
the use of Interfaces.
Thus, create:
A base class (Shape) that should not be instantiated with non- [6]
implemented methods named setColour (String c) and getColour ().
An interface named AreaVol with two methods named area and volume. [6]
Both of which are to have a return type - double.
A child class (ShapeTriangle), implementing multiple inheritance by using [6]
both the base class and the interface.
A class named TestShapes with a main method to be used to create [10]
appropriate class object(s) with appropriate invoked methods to depict
information as shown in figure 2 below. Use the Scanner object to get
input from the end user.
Figure 2: Application’s processing and output
Area assessed Comment(s Mark(s)
)
i) Correct Base class definition /
6
j) Correct interface definition /
6
k) Correct ShapeTriangle definition /
6
l) Correct TestShapes definition /1
0
m) Correct program logic and indentation /
2
Limkokwing University of Creative Technology Page 4 of 4
Faculty of Information and Communication Technology
Question paper checked and verified by (PRL): _____________________________Date:
21/03/2019
Limkokwing University of Creative Technology Page 5 of 4
Faculty of Information and Communication Technology