SlideShare a Scribd company logo
15
Most read
16
Most read
17
Most read
CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING
Page 2 of 18
SECTION A
OBJECTIVE QUESTIONS (50 marks)
INSTRUCTION:
This section consists of FORTY (40) objective questions. Answer ALL questions in the
answer booklet.
1. Identify how the program developed is more secure when using object oriented
programming. [CLO 1]
A. The data developed are hidden.
B. A program that has been developed can be easily upgraded from small
programs to large systems.
C. Eliminate redundant code and optimize usage of existing classes.
D. Complexity of a program can be easily managed.
2. The following is part of java program to create an object for class Car. Identify
the correct UML class diagram notation based on the program. [CLO1]
Car Car
myCar myCar
Car
Car1 : CarCar1 : Car
Car
new Car ( )
new Car ( ) new Car ( )
new Car ( )
A.
B.
C.
D.
Car myCar = new Car ( );
CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING
Page 3 of 18
3.  Identify problem domain.
 Identify object.
 Identify Object's Attributes.
 Identify Object's Operations
Based on the list of procedures above, it refers to [CLO 1]
A. State a problem.
B. Design a problem.
C. Declare a problem.
D. Analyze a problem.
4. What is the suitable answer to fill in the Figure 1? [CLO 1]
Figure 1
A.
B.
C.
D.
I II II
Class Method Behavior
Class Attributes Method
Operation Method Class
Attributes Operation Behavior
5. “Process to delete all unnecessary attributes and remain the necessary attribute to
describe object.” This statement refers to basic terminology of
[CLO 1]
A. data abstraction
B. polymorphism
C. object
D. class
I
III
II
CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING
Page 4 of 18
6. State the method from the given problem statements.
“A bank account consists of a name of depositor, account number, type of
account and balance amount in the account. Depositor can deposit an amount
into their account and withdraw their amount.” [CLO 3]
A. Name of depositor, account number, type of account
B. Depositor amount, withdraw amount, bank account
C. Name of depositor, account number, bank account
D. Depositor amount, withdraw amount
7. What is the function of Java compiler? [CLO 1]
A. converts source code into byte code
B. converts source code into unicode
C. converts byte code into source code
D. converts byte code into psuedocode
8. What is the tool use to produces header files for use with native methods?
[CLO 1]
A. jar
B. java
C. javap
D. javah
9. Which one of the following are reserved word in Java? [CLO 1]
A. package, return, double, class, pi
B. return, continue, static, protected, boolean
C. public, static, private, boolean, chase
D. protected, int, void, class, trouble
10. What is the first name of Java? [CLO 1]
A. Sun
B. Bean
CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING
Page 5 of 18
C. Oak
D. Coffee
Question 11-12 are based on the following scenarios:
SportsCar, Inc. sells sports car from their catalog. Business is growing 30%
per year, and they need a new order entry system. You have been contracted
by SportsCar to design the new system.
SportsCar produces a catalog of car every six months and mails it to
subscribers. Each car in the catalog has an item identifier (ID) and price.
11. Analyze the scenario using OOAD and identify the possible objects.
I. Order
II. Car
III. Customer
IV. Mail
[CLO 3]
A. I, II
B. I, II, III
C. I, II, IV
D. I, II, III, IV
CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING
Page 6 of 18
12. Analyze the scenario using OOAD and identify the possible data member and
member function for Car. [CLO 3]
Car
ID: char
Price:double
calculatePrice(): double
display()
Car
ID: char
calculatePrice(): float
display()
13. Which of the following is the exactly naming convention of object method?
[CLO 1]
A. method Compute_AREA
B. method ComputeArea
C. method computeArea
D. method Computearea
14. Which of the following is the type of errors? [CLO 1]
A. Compile error, runtime error and read error
B. Compile-time error, class error and logic error
C. Compute error, runtime error and logic error
D. Compile-time error, runtime error and logic error
Car
ID: char
Price:double
Color:char
calculatePrice(): float
display()
Car
ID: char
Price:double
Color:char
calculatePrice(): double
display()
C.
D.
A.
B.
CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING
Page 7 of 18
Question 15-16 are based on the following source code:
15. Define the correct meaning of statement in line 3, “int x”. [CLO 1]
A. Declare x to be a float variable
B. Declare x to be a double variable
C. Declare x to be an integer variable
D. Declare x to be a character variable
16. Identify output from the program segment. [CLO 2]
A. The number is 20
B. The number is 21
C. The number is : 20
D. The number is : 21
1. public class number{
2. public static void main(String [] args){
3. int x;
4. x = 20;
5. System.out.println(“The number is : ”+ x);
6. }
7. }
CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING
Page 8 of 18
Question 17-18 are based on the following java program:
17. Explain code in line 5. [CLO 2]
A. Object reference variable to invoke data member
B. Declaration of object for class and assign it to class.
C. Declaration of class with reference type. Create a new object for class
and assign it to object reference variable.
D. Object reference variable to invoke member function
18. Explain code in line 8. [CLO 2]
A. Object reference variable to invoke data member
B. Declaration of object for class and assign it to class.
C. Declaration of class with reference type. Create a new object for class
and assign it to object reference variable.
D. Object reference variable to invoke member function
1 public class YellowRec
2 {
3 public static void main (String[] args)
4 {
5 Rectangle myRec = new Rectangle();
6 System.out.println("The area rectangle for
width " +
7 myRec.width + " is " +
8 myRec.calculateArea());
9 }
10 }
11 class Rectangle
12 {
13 double width = 12.3;
14 double length = 2.6;
15 double calculateArea()
16 {
17 return width * length;
18
19 }
20 }
CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING
Page 9 of 18
19. The Java IO package that we will be using is called [CLO 1]
A. java.inout
B. java.input
C. java.file
D. java.io
20. java.io does input from an input _________ of characters and does output to
an _____________ of characters. [CLO 1]
A. stream and output stream
B. output stream and stream
C. stream and input stream
D. input stream and stream
21. “Returns the number of bytes that can be read from input stream” This
statement refers to the abstract of input output stream for method
[CLO 2]
A. +read( ): int
B. +reset ( ) : void
C. +close ( ) : void
D. +available ( ) : int
22. All methods in BufferedInputStream/BufferedOutputStream are inherited
from __________________ class. [CLO 1]
A. InputStream/OutputStream
B. FileInputStream/FileOutputStream
C. DataInputStream/DataOutputStream
D. ObjectInputStream/ObjectOutputStream
CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING
Page 10 of 18
23. Select the valid declare and create an array from the following.
[CLO 2]
A. int arr[ ] = new char[5];
B. double car[ ] = new double[10];
C. char car[ ] = new char[5];
D. char car = new char[ ];
24. What is the output of the following code fragment:
int[] ar = {2, 4, 6, 8 };
System.out.println( ar[0] + " " + ar[1] );
[CLO 3]
A. 2, 4
B. 2, 6
C. 4, 6
D. 4, 2
25. What type of exception is thrown by parseInt() if it gets illegal data?
[CLO 1]
A. NumberError
B. RunTimeException
C. ArithmeticException
D. NumberFormatException
26. Say that methodA calls methodB, and methodB calls methodC. MethodC
might throw a NumberFormatException. Can the program be written so that
methodA handles the exception? [CLO 3]
A. No, methodC must handle the exception.
B. Yes, if the header for methodC says …throws
NumberFormatException
CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING
Page 11 of 18
C. No, the exception must be handled by methodC or its caller, methodB.
D. Yes, if the headers for methodC and methodB say …throws
NumberFormatException
27. Which statement is true? [CLO 1]
A. A try statement must have at least one corresponding catch block.
B. Multiple catch statements can catch the same class of exception more
than once.
C. An Error that might be thrown in a method must be declared as
thrown by that method, or be handled within that method.
D. Except in case of VM shutdown, if a try block starts to execute, a
corresponding finally block will always start to execute.
28. What will be the output of the program? [CLO 3]
A. AC
B. BC
C. ACD
D. ABCD
public class X
{
public static void main(String [] args)
{
try
{
badMethod();
System.out.print("A");
}
catch (Exception ex)
{
System.out.print("B");
}
finally
{
System.out.print("C");
}
System.out.print("D");
}
public static void badMethod() {}
}
CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING
Page 12 of 18
29. Consider the following piece of code:
Give the values of the expressions E1.equals (E2) and E1 == E2.
[CLO 3]
A. The value of E1.equals (E2) is false, whereas the value of E1 == E2 is
true.
B. The value of E1.equals (E2) is true, whereas the value of E1 == E2 is
false.
C. The value of E1.equals(E2) is true, whereas the value of E1 == E2 is
true
D. The value of E1.equals (E2) is false, whereas the value of E1 == E2 is
false.
30. Which statement, if placed in a class other than MyOuter or MyInner,
instantiates an instance of the nested class?
[CLO 2]
A. MyOuter.MyInner m = new MyOuter.MyInner();
B. MyOuter.MyInner mi = new MyInner();
C. MyOuter m=new MyOuter
D. MyInner mi = new MyOuter.MyInner();
Employee E1 = new Employee("Karim", 5001);
Employee E2 = new Employee(E1);
public class MyOuter
{
public static class MyInner
{ public static void foo() { }
}
}
CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING
Page 13 of 18
31. Which code declares class A to belong to the mypackage.financial package?
[CLO 2]
A. package mypackage;
package financial;
B. import mypackage.*;
C. package mypackage.financial.A;
D. package mypackage.financial;
32. One of the important Java package is java.lang package. Which of the
following statement describe java.lang package? [CLO 1]
A. The java.lang package is automatically exported.
B. It contains classes and interfaces that are fundamental to virtually all
java programming.
C. It contains many mathematical methods.
D. Inherits the variables and class of object.
33. Package “java.lang.math” indicates that [CLO 1]
A. Math is a class in the package java.
B. Lang is a class in the package java.
C. Math is a class in the package lang and that lang is a package in the
package java.
D. Lang is a class in the package math and that math is a package in the
package java.
34. Identify the correct statement to put a class to “com.prenhall.mypackage”
package. [CLO 2]
A. package com.prenhall.mypackage;
B. package com.prenhall.mypackage
C. com.prenhall.mypackage Package
D. com.prenhall.mypackage Package;
CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING
Page 14 of 18
Question 35-36 based on the following program segment:
35. Define the correct explanation for statement in (i). [CLO 2]
A. Method p( ) in class A overrides the method in B.
B. Method p( ) in class A overloads the method in B.
C. Method p( ) in class B overrides the method in A.
D. Method p( ) in class B overloads the method in A.
36. Identify the output for program segment. [CLO 3]
A. The Number 10
B. The Number : 10
C. The Number 100
D. The Number : 100
37. If you do not implement all the method of an interface while implementing,
what specifier should you use for the class? [CLO 3]
A. Abstract
B. Inheritance
C. Encapsulation
D. Constructor
public class Exam{
public static void main(String[] args){
A a = new A();
a.p(10);
}
}
class B {
public void p(int i) { }
}
class A extends B{
public void p(int i) {
System.out.println(“The Number : ” +i );
}
}
(i)
CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING
Page 15 of 18
38. When a class implements an interface, what must it do? [CLO 1]
A. It must redefine each constant from the interface.
B. It must include a private method for each method in the interface.
C. It must declare a variable for each constant in the interface.
D. It must declare and provide a method body for each method in the
interface.
39. Which of the following is a correct statement to declare and initialize a string
in the segment program? [CLO 2]
A. StringBuffer strBuffer2 = new StringBuffer("Aliah");
B. StringBuffer strBuffer1 = new StringBuffer("Aliah");
C. StringBuffer Buffer1 = new StringBuffer("Aliah");
D. StringBuffer strBuffer1 = StringBuffer("Aliah");
40. What is the output of the following program segment? [CLO 2]
A. 12
B. 11
C. 10
D. 13
public class StringBufferExample{
public static void main(String[] args) {
______________________________
System.out.println("strBuffer1 : " +strBuffer1);
}
}
public class Main1 {
public static void main(String[] args) {
String str = new String("10");
int i = Integer.parseInt(str);
System.out.println(i);
}
}
CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING
Page 16 of 18
SECTION B
STRUCTURED QUESTIONS (50 marks)
INSTRUCTION:
This section consists of TWO (2) structured questions. Answer ALL questions.
QUESTION 1
a) Define polymorphism and inheritance. [CLO 1]
(4 marks)
b) Explain TWO (2) anatomy of Java program. [CLO 1]
(4 marks)
c) c) Answer the question below by using the given situation.
With the abstraction process you have to identify the object, attributes and
methods in the situation above. Please fill in the object, attributes and methods
you have identified in format as below. [CLO 2]
i) Object name
ii) Attribute
iii) Methods
(1 marks)
(5 marks)
(3 marks)
Klinik Fatihah Dungun is one of the new clinics
launch on January 2011. Once the patient registered, their
information will be recorded such as ic number, name of
patient, address, date, and disease. The treatment will be
done by the doctor in charge on the current day. The
appropriate medicine will be given to the patient depend
on the disease and the staff will print the patient detail for
documenting.
CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING
Page 17 of 18
d) Based on the abstraction process that student have done in (c)
question, write the encapsulation process by using the class
diagram.
[CLO 2]
(5 marks)
e) e) Describe the differences between exception handling and
assertions.
[CLO 1]
(3 marks)
QUESTION 2
(a) i) Identify the importance of Object-Oriented Analysis
(OOAD) pattern.
ii) List THREE (3) types of diagrams in UML.
[CLO 1]
(3 marks)
[CLO 1]
(3 marks)
(b) In Java, modifier is used to control access data, method and
class. State the function of each modifier for method below.
i) abstract
ii) final
iii) static
[CLO 1]
(6 marks)
(c) Answer the question based on the program segment below.
public class Mother{
public String name;
public int age;
Mother(){
name="Aminah";
age=45;
}
public void display(){
System.out.println("Name: "+name);
System.out.println("Age: "+age);
}
}
CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING
Page 18 of 18
i) Create a class named Child that inherits the Mother class.
Declare an instance name location (String) for class Child.
ii) Define a constructor in class Child and give an appropriate
initial values for the instances (name, age and location).
iii) Define a method display() in class Child, execute the
display() method in superclass using the keyword super.
Method display() in class child should print the information
of name, age and location.
[CLO 2]
(2 marks)
[CLO 2]
(3 marks)
[CLO 2]
(3 marks)
iv) Create other class named Main for the main method and
create 2 objects for the 2 classes (Mother and Child). Then
execute the display() method for Mother and Child.
Example of the output:
[CLO 3]
(5 marks)
Mother's info:
Name: Aminah
Age: 45
Child's info:
Name: Sarah
Age: 20
Location: Dungun

More Related Content

PDF
FP 301 OOP FINAL PAPER
PPT
chapter3 - Basic Processing Unit.ppt
PPTX
Asymptotic Notation
PPTX
OOP Unit 2 - Classes and Object
PDF
FP305 data structure PAPER FINAL SEM 3
PPT
Abstract data types (adt) intro to data structure part 2
PPTX
PPTX
Comparable/ Comparator
FP 301 OOP FINAL PAPER
chapter3 - Basic Processing Unit.ppt
Asymptotic Notation
OOP Unit 2 - Classes and Object
FP305 data structure PAPER FINAL SEM 3
Abstract data types (adt) intro to data structure part 2
Comparable/ Comparator

What's hot (20)

PPTX
Object Oriented Programming ppt presentation
PPTX
Object Oriented Programming Concepts for beginners
PPTX
Principles of programming
PPTX
Linked List
PPTX
Merge sort and quick sort
PPTX
Python-DataAbstarction.pptx
PPTX
C++ ppt
PPT
Abstract data types
PPTX
Computer organization
PPTX
An Introduction to OMNeT++ 6.0
PDF
Optimal binary search tree
PPTX
Oop c++class(final).ppt
PPTX
Data structures and algorithms
PDF
sparse matrix in data structure
PPT
1. over view and history of c
PPT
Instruction format
PDF
Parallel Algorithms
PDF
Python functions
PDF
Singly linked list
PPT
Arrays
Object Oriented Programming ppt presentation
Object Oriented Programming Concepts for beginners
Principles of programming
Linked List
Merge sort and quick sort
Python-DataAbstarction.pptx
C++ ppt
Abstract data types
Computer organization
An Introduction to OMNeT++ 6.0
Optimal binary search tree
Oop c++class(final).ppt
Data structures and algorithms
sparse matrix in data structure
1. over view and history of c
Instruction format
Parallel Algorithms
Python functions
Singly linked list
Arrays
Ad

Viewers also liked (9)

DOC
Jawapan 1
PDF
Pengaturcaraan C
PPTX
Pembinaan Jsu 2010
PPT
Jadual Penentu Ujian dan Jadual Spesifikasi Ujian
PPTX
Classes And Objects
PPTX
Jadual spesifikasi ujian
DOC
Sample Jsu Pendidikan
PPT
Jadual Spesifikasi Ujian (Jsu)
PPTX
class and objects
Jawapan 1
Pengaturcaraan C
Pembinaan Jsu 2010
Jadual Penentu Ujian dan Jadual Spesifikasi Ujian
Classes And Objects
Jadual spesifikasi ujian
Sample Jsu Pendidikan
Jadual Spesifikasi Ujian (Jsu)
class and objects
Ad

Similar to FINAL PAPER FP301 OBJECT ORIENTED PROGRAMMING (20)

PDF
FP 301 OOP FINAL PAPER JUNE 2013
DOCX
CS 192 test questions 1-441. Global variables are known to the e.docx
TXT
CORE JAVA
DOC
BISH CS Modle Exit Exam.doc
PDF
Multiple Choice Questions on JAVA (object oriented programming) bank 2 -- bas...
PDF
OOM MCQ 2018
PDF
Java Programming.pdf
DOCX
Faculty of ScienceDepartment of ComputingFinal Examinati.docx
DOCX
CIS 407 STUDY Inspiring Innovation--cis407study.com
PDF
Multiple Choice Questions on JAVA (object oriented programming) bank 1 -- int...
PDF
Java MCQ Important Questions and Answers
PDF
ITI COPA Java MCQ important Questions and Answers
PDF
Tcs sample technical placement paper level i
TXT
CORE JAVA
PDF
Devry CIS 355A Full Course Latest
PDF
Core java
PDF
EEE 3rd year oops cat 3 ans
DOCX
Mcs 024 assignment solution (2020-21)
PDF
Oop suplemnertary september 2019
PDF
QUESTION 1A business system is a(n)A.collection of operations .pdf
FP 301 OOP FINAL PAPER JUNE 2013
CS 192 test questions 1-441. Global variables are known to the e.docx
CORE JAVA
BISH CS Modle Exit Exam.doc
Multiple Choice Questions on JAVA (object oriented programming) bank 2 -- bas...
OOM MCQ 2018
Java Programming.pdf
Faculty of ScienceDepartment of ComputingFinal Examinati.docx
CIS 407 STUDY Inspiring Innovation--cis407study.com
Multiple Choice Questions on JAVA (object oriented programming) bank 1 -- int...
Java MCQ Important Questions and Answers
ITI COPA Java MCQ important Questions and Answers
Tcs sample technical placement paper level i
CORE JAVA
Devry CIS 355A Full Course Latest
Core java
EEE 3rd year oops cat 3 ans
Mcs 024 assignment solution (2020-21)
Oop suplemnertary september 2019
QUESTION 1A business system is a(n)A.collection of operations .pdf

More from Amira Dolce Farhana (7)

DOCX
Final paper FN512 server management
DOCX
Final paper FN511 Switching & Routing
PDF
FINAL PAPER FP304 DATABASE SYSTEM
PDF
FINAL PAPER FN311 INTERNET SERVICES
DOCX
Osha ERGONOMICS
DOCX
Kertas kerja lawatan ke rumah anak yatim
PDF
FINAL PAPER FP501 OPEN SOURCE OPERATING SYSTEM
Final paper FN512 server management
Final paper FN511 Switching & Routing
FINAL PAPER FP304 DATABASE SYSTEM
FINAL PAPER FN311 INTERNET SERVICES
Osha ERGONOMICS
Kertas kerja lawatan ke rumah anak yatim
FINAL PAPER FP501 OPEN SOURCE OPERATING SYSTEM

Recently uploaded (20)

PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
Computing-Curriculum for Schools in Ghana
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
Classroom Observation Tools for Teachers
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Sports Quiz easy sports quiz sports quiz
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Complications of Minimal Access Surgery at WLH
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
Cell Structure & Organelles in detailed.
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
Cell Types and Its function , kingdom of life
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPH.pptx obstetrics and gynecology in nursing
Computing-Curriculum for Schools in Ghana
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
VCE English Exam - Section C Student Revision Booklet
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
STATICS OF THE RIGID BODIES Hibbelers.pdf
Renaissance Architecture: A Journey from Faith to Humanism
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Classroom Observation Tools for Teachers
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Sports Quiz easy sports quiz sports quiz
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Complications of Minimal Access Surgery at WLH
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Cell Structure & Organelles in detailed.
TR - Agricultural Crops Production NC III.pdf
Cell Types and Its function , kingdom of life
2.FourierTransform-ShortQuestionswithAnswers.pdf

FINAL PAPER FP301 OBJECT ORIENTED PROGRAMMING

  • 1. CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING Page 2 of 18 SECTION A OBJECTIVE QUESTIONS (50 marks) INSTRUCTION: This section consists of FORTY (40) objective questions. Answer ALL questions in the answer booklet. 1. Identify how the program developed is more secure when using object oriented programming. [CLO 1] A. The data developed are hidden. B. A program that has been developed can be easily upgraded from small programs to large systems. C. Eliminate redundant code and optimize usage of existing classes. D. Complexity of a program can be easily managed. 2. The following is part of java program to create an object for class Car. Identify the correct UML class diagram notation based on the program. [CLO1] Car Car myCar myCar Car Car1 : CarCar1 : Car Car new Car ( ) new Car ( ) new Car ( ) new Car ( ) A. B. C. D. Car myCar = new Car ( );
  • 2. CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING Page 3 of 18 3.  Identify problem domain.  Identify object.  Identify Object's Attributes.  Identify Object's Operations Based on the list of procedures above, it refers to [CLO 1] A. State a problem. B. Design a problem. C. Declare a problem. D. Analyze a problem. 4. What is the suitable answer to fill in the Figure 1? [CLO 1] Figure 1 A. B. C. D. I II II Class Method Behavior Class Attributes Method Operation Method Class Attributes Operation Behavior 5. “Process to delete all unnecessary attributes and remain the necessary attribute to describe object.” This statement refers to basic terminology of [CLO 1] A. data abstraction B. polymorphism C. object D. class I III II
  • 3. CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING Page 4 of 18 6. State the method from the given problem statements. “A bank account consists of a name of depositor, account number, type of account and balance amount in the account. Depositor can deposit an amount into their account and withdraw their amount.” [CLO 3] A. Name of depositor, account number, type of account B. Depositor amount, withdraw amount, bank account C. Name of depositor, account number, bank account D. Depositor amount, withdraw amount 7. What is the function of Java compiler? [CLO 1] A. converts source code into byte code B. converts source code into unicode C. converts byte code into source code D. converts byte code into psuedocode 8. What is the tool use to produces header files for use with native methods? [CLO 1] A. jar B. java C. javap D. javah 9. Which one of the following are reserved word in Java? [CLO 1] A. package, return, double, class, pi B. return, continue, static, protected, boolean C. public, static, private, boolean, chase D. protected, int, void, class, trouble 10. What is the first name of Java? [CLO 1] A. Sun B. Bean
  • 4. CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING Page 5 of 18 C. Oak D. Coffee Question 11-12 are based on the following scenarios: SportsCar, Inc. sells sports car from their catalog. Business is growing 30% per year, and they need a new order entry system. You have been contracted by SportsCar to design the new system. SportsCar produces a catalog of car every six months and mails it to subscribers. Each car in the catalog has an item identifier (ID) and price. 11. Analyze the scenario using OOAD and identify the possible objects. I. Order II. Car III. Customer IV. Mail [CLO 3] A. I, II B. I, II, III C. I, II, IV D. I, II, III, IV
  • 5. CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING Page 6 of 18 12. Analyze the scenario using OOAD and identify the possible data member and member function for Car. [CLO 3] Car ID: char Price:double calculatePrice(): double display() Car ID: char calculatePrice(): float display() 13. Which of the following is the exactly naming convention of object method? [CLO 1] A. method Compute_AREA B. method ComputeArea C. method computeArea D. method Computearea 14. Which of the following is the type of errors? [CLO 1] A. Compile error, runtime error and read error B. Compile-time error, class error and logic error C. Compute error, runtime error and logic error D. Compile-time error, runtime error and logic error Car ID: char Price:double Color:char calculatePrice(): float display() Car ID: char Price:double Color:char calculatePrice(): double display() C. D. A. B.
  • 6. CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING Page 7 of 18 Question 15-16 are based on the following source code: 15. Define the correct meaning of statement in line 3, “int x”. [CLO 1] A. Declare x to be a float variable B. Declare x to be a double variable C. Declare x to be an integer variable D. Declare x to be a character variable 16. Identify output from the program segment. [CLO 2] A. The number is 20 B. The number is 21 C. The number is : 20 D. The number is : 21 1. public class number{ 2. public static void main(String [] args){ 3. int x; 4. x = 20; 5. System.out.println(“The number is : ”+ x); 6. } 7. }
  • 7. CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING Page 8 of 18 Question 17-18 are based on the following java program: 17. Explain code in line 5. [CLO 2] A. Object reference variable to invoke data member B. Declaration of object for class and assign it to class. C. Declaration of class with reference type. Create a new object for class and assign it to object reference variable. D. Object reference variable to invoke member function 18. Explain code in line 8. [CLO 2] A. Object reference variable to invoke data member B. Declaration of object for class and assign it to class. C. Declaration of class with reference type. Create a new object for class and assign it to object reference variable. D. Object reference variable to invoke member function 1 public class YellowRec 2 { 3 public static void main (String[] args) 4 { 5 Rectangle myRec = new Rectangle(); 6 System.out.println("The area rectangle for width " + 7 myRec.width + " is " + 8 myRec.calculateArea()); 9 } 10 } 11 class Rectangle 12 { 13 double width = 12.3; 14 double length = 2.6; 15 double calculateArea() 16 { 17 return width * length; 18 19 } 20 }
  • 8. CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING Page 9 of 18 19. The Java IO package that we will be using is called [CLO 1] A. java.inout B. java.input C. java.file D. java.io 20. java.io does input from an input _________ of characters and does output to an _____________ of characters. [CLO 1] A. stream and output stream B. output stream and stream C. stream and input stream D. input stream and stream 21. “Returns the number of bytes that can be read from input stream” This statement refers to the abstract of input output stream for method [CLO 2] A. +read( ): int B. +reset ( ) : void C. +close ( ) : void D. +available ( ) : int 22. All methods in BufferedInputStream/BufferedOutputStream are inherited from __________________ class. [CLO 1] A. InputStream/OutputStream B. FileInputStream/FileOutputStream C. DataInputStream/DataOutputStream D. ObjectInputStream/ObjectOutputStream
  • 9. CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING Page 10 of 18 23. Select the valid declare and create an array from the following. [CLO 2] A. int arr[ ] = new char[5]; B. double car[ ] = new double[10]; C. char car[ ] = new char[5]; D. char car = new char[ ]; 24. What is the output of the following code fragment: int[] ar = {2, 4, 6, 8 }; System.out.println( ar[0] + " " + ar[1] ); [CLO 3] A. 2, 4 B. 2, 6 C. 4, 6 D. 4, 2 25. What type of exception is thrown by parseInt() if it gets illegal data? [CLO 1] A. NumberError B. RunTimeException C. ArithmeticException D. NumberFormatException 26. Say that methodA calls methodB, and methodB calls methodC. MethodC might throw a NumberFormatException. Can the program be written so that methodA handles the exception? [CLO 3] A. No, methodC must handle the exception. B. Yes, if the header for methodC says …throws NumberFormatException
  • 10. CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING Page 11 of 18 C. No, the exception must be handled by methodC or its caller, methodB. D. Yes, if the headers for methodC and methodB say …throws NumberFormatException 27. Which statement is true? [CLO 1] A. A try statement must have at least one corresponding catch block. B. Multiple catch statements can catch the same class of exception more than once. C. An Error that might be thrown in a method must be declared as thrown by that method, or be handled within that method. D. Except in case of VM shutdown, if a try block starts to execute, a corresponding finally block will always start to execute. 28. What will be the output of the program? [CLO 3] A. AC B. BC C. ACD D. ABCD public class X { public static void main(String [] args) { try { badMethod(); System.out.print("A"); } catch (Exception ex) { System.out.print("B"); } finally { System.out.print("C"); } System.out.print("D"); } public static void badMethod() {} }
  • 11. CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING Page 12 of 18 29. Consider the following piece of code: Give the values of the expressions E1.equals (E2) and E1 == E2. [CLO 3] A. The value of E1.equals (E2) is false, whereas the value of E1 == E2 is true. B. The value of E1.equals (E2) is true, whereas the value of E1 == E2 is false. C. The value of E1.equals(E2) is true, whereas the value of E1 == E2 is true D. The value of E1.equals (E2) is false, whereas the value of E1 == E2 is false. 30. Which statement, if placed in a class other than MyOuter or MyInner, instantiates an instance of the nested class? [CLO 2] A. MyOuter.MyInner m = new MyOuter.MyInner(); B. MyOuter.MyInner mi = new MyInner(); C. MyOuter m=new MyOuter D. MyInner mi = new MyOuter.MyInner(); Employee E1 = new Employee("Karim", 5001); Employee E2 = new Employee(E1); public class MyOuter { public static class MyInner { public static void foo() { } } }
  • 12. CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING Page 13 of 18 31. Which code declares class A to belong to the mypackage.financial package? [CLO 2] A. package mypackage; package financial; B. import mypackage.*; C. package mypackage.financial.A; D. package mypackage.financial; 32. One of the important Java package is java.lang package. Which of the following statement describe java.lang package? [CLO 1] A. The java.lang package is automatically exported. B. It contains classes and interfaces that are fundamental to virtually all java programming. C. It contains many mathematical methods. D. Inherits the variables and class of object. 33. Package “java.lang.math” indicates that [CLO 1] A. Math is a class in the package java. B. Lang is a class in the package java. C. Math is a class in the package lang and that lang is a package in the package java. D. Lang is a class in the package math and that math is a package in the package java. 34. Identify the correct statement to put a class to “com.prenhall.mypackage” package. [CLO 2] A. package com.prenhall.mypackage; B. package com.prenhall.mypackage C. com.prenhall.mypackage Package D. com.prenhall.mypackage Package;
  • 13. CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING Page 14 of 18 Question 35-36 based on the following program segment: 35. Define the correct explanation for statement in (i). [CLO 2] A. Method p( ) in class A overrides the method in B. B. Method p( ) in class A overloads the method in B. C. Method p( ) in class B overrides the method in A. D. Method p( ) in class B overloads the method in A. 36. Identify the output for program segment. [CLO 3] A. The Number 10 B. The Number : 10 C. The Number 100 D. The Number : 100 37. If you do not implement all the method of an interface while implementing, what specifier should you use for the class? [CLO 3] A. Abstract B. Inheritance C. Encapsulation D. Constructor public class Exam{ public static void main(String[] args){ A a = new A(); a.p(10); } } class B { public void p(int i) { } } class A extends B{ public void p(int i) { System.out.println(“The Number : ” +i ); } } (i)
  • 14. CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING Page 15 of 18 38. When a class implements an interface, what must it do? [CLO 1] A. It must redefine each constant from the interface. B. It must include a private method for each method in the interface. C. It must declare a variable for each constant in the interface. D. It must declare and provide a method body for each method in the interface. 39. Which of the following is a correct statement to declare and initialize a string in the segment program? [CLO 2] A. StringBuffer strBuffer2 = new StringBuffer("Aliah"); B. StringBuffer strBuffer1 = new StringBuffer("Aliah"); C. StringBuffer Buffer1 = new StringBuffer("Aliah"); D. StringBuffer strBuffer1 = StringBuffer("Aliah"); 40. What is the output of the following program segment? [CLO 2] A. 12 B. 11 C. 10 D. 13 public class StringBufferExample{ public static void main(String[] args) { ______________________________ System.out.println("strBuffer1 : " +strBuffer1); } } public class Main1 { public static void main(String[] args) { String str = new String("10"); int i = Integer.parseInt(str); System.out.println(i); } }
  • 15. CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING Page 16 of 18 SECTION B STRUCTURED QUESTIONS (50 marks) INSTRUCTION: This section consists of TWO (2) structured questions. Answer ALL questions. QUESTION 1 a) Define polymorphism and inheritance. [CLO 1] (4 marks) b) Explain TWO (2) anatomy of Java program. [CLO 1] (4 marks) c) c) Answer the question below by using the given situation. With the abstraction process you have to identify the object, attributes and methods in the situation above. Please fill in the object, attributes and methods you have identified in format as below. [CLO 2] i) Object name ii) Attribute iii) Methods (1 marks) (5 marks) (3 marks) Klinik Fatihah Dungun is one of the new clinics launch on January 2011. Once the patient registered, their information will be recorded such as ic number, name of patient, address, date, and disease. The treatment will be done by the doctor in charge on the current day. The appropriate medicine will be given to the patient depend on the disease and the staff will print the patient detail for documenting.
  • 16. CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING Page 17 of 18 d) Based on the abstraction process that student have done in (c) question, write the encapsulation process by using the class diagram. [CLO 2] (5 marks) e) e) Describe the differences between exception handling and assertions. [CLO 1] (3 marks) QUESTION 2 (a) i) Identify the importance of Object-Oriented Analysis (OOAD) pattern. ii) List THREE (3) types of diagrams in UML. [CLO 1] (3 marks) [CLO 1] (3 marks) (b) In Java, modifier is used to control access data, method and class. State the function of each modifier for method below. i) abstract ii) final iii) static [CLO 1] (6 marks) (c) Answer the question based on the program segment below. public class Mother{ public String name; public int age; Mother(){ name="Aminah"; age=45; } public void display(){ System.out.println("Name: "+name); System.out.println("Age: "+age); } }
  • 17. CONFIDENTIAL FP301 OBJECT ORIENTED PROGRAMMING Page 18 of 18 i) Create a class named Child that inherits the Mother class. Declare an instance name location (String) for class Child. ii) Define a constructor in class Child and give an appropriate initial values for the instances (name, age and location). iii) Define a method display() in class Child, execute the display() method in superclass using the keyword super. Method display() in class child should print the information of name, age and location. [CLO 2] (2 marks) [CLO 2] (3 marks) [CLO 2] (3 marks) iv) Create other class named Main for the main method and create 2 objects for the 2 classes (Mother and Child). Then execute the display() method for Mother and Child. Example of the output: [CLO 3] (5 marks) Mother's info: Name: Aminah Age: 45 Child's info: Name: Sarah Age: 20 Location: Dungun