SlideShare una empresa de Scribd logo
1 de 17
Descargar para leer sin conexión
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

Más contenido relacionado

La actualidad más candente

Applet life cycle
Applet life cycleApplet life cycle
Applet life cycle
myrajendra
 
Time and space complexity
Time and space complexityTime and space complexity
Time and space complexity
Ankit Katiyar
 
Travelling salesman dynamic programming
Travelling salesman dynamic programmingTravelling salesman dynamic programming
Travelling salesman dynamic programming
maharajdey
 
FINAL PAPER FP304 DATABASE SYSTEM
FINAL PAPER FP304 DATABASE SYSTEMFINAL PAPER FP304 DATABASE SYSTEM
FINAL PAPER FP304 DATABASE SYSTEM
Amira Dolce Farhana
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
Tech_MX
 

La actualidad más candente (20)

Applet life cycle
Applet life cycleApplet life cycle
Applet life cycle
 
C++ Arrays
C++ ArraysC++ Arrays
C++ Arrays
 
Time and space complexity
Time and space complexityTime and space complexity
Time and space complexity
 
Data structures
Data structuresData structures
Data structures
 
Python Programming Essentials - M9 - String Formatting
Python Programming Essentials - M9 - String FormattingPython Programming Essentials - M9 - String Formatting
Python Programming Essentials - M9 - String Formatting
 
Travelling salesman dynamic programming
Travelling salesman dynamic programmingTravelling salesman dynamic programming
Travelling salesman dynamic programming
 
FINAL PAPER FP304 DATABASE SYSTEM
FINAL PAPER FP304 DATABASE SYSTEMFINAL PAPER FP304 DATABASE SYSTEM
FINAL PAPER FP304 DATABASE SYSTEM
 
Arrays in Java | Edureka
Arrays in Java | EdurekaArrays in Java | Edureka
Arrays in Java | Edureka
 
UNIT I LINEAR DATA STRUCTURES – LIST
UNIT I 	LINEAR DATA STRUCTURES – LIST 	UNIT I 	LINEAR DATA STRUCTURES – LIST
UNIT I LINEAR DATA STRUCTURES – LIST
 
Arrays in python
Arrays in pythonArrays in python
Arrays in python
 
Arrays searching-sorting
Arrays searching-sortingArrays searching-sorting
Arrays searching-sorting
 
[Question Paper] ASP.NET With C# (75:25 Pattern) [April / 2016]
[Question Paper] ASP.NET With C# (75:25 Pattern) [April / 2016][Question Paper] ASP.NET With C# (75:25 Pattern) [April / 2016]
[Question Paper] ASP.NET With C# (75:25 Pattern) [April / 2016]
 
java-thread
java-threadjava-thread
java-thread
 
Merge Sort
Merge SortMerge Sort
Merge Sort
 
Solution of Erds
Solution of ErdsSolution of Erds
Solution of Erds
 
Programming in c Arrays
Programming in c ArraysProgramming in c Arrays
Programming in c Arrays
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
Manipulators
ManipulatorsManipulators
Manipulators
 
SEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMSSEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMS
 
Programming in C++ and Data Strucutres
Programming in C++ and Data StrucutresProgramming in C++ and Data Strucutres
Programming in C++ and Data Strucutres
 

Destacado (10)

Jawapan 1
Jawapan 1Jawapan 1
Jawapan 1
 
Pengaturcaraan C
Pengaturcaraan CPengaturcaraan C
Pengaturcaraan C
 
Pembinaan Jsu 2010
Pembinaan Jsu 2010Pembinaan Jsu 2010
Pembinaan Jsu 2010
 
Jadual Penentu Ujian dan Jadual Spesifikasi Ujian
Jadual Penentu Ujian dan Jadual Spesifikasi UjianJadual Penentu Ujian dan Jadual Spesifikasi Ujian
Jadual Penentu Ujian dan Jadual Spesifikasi Ujian
 
Classes And Objects
Classes And ObjectsClasses And Objects
Classes And Objects
 
Jadual spesifikasi ujian
Jadual spesifikasi ujianJadual spesifikasi ujian
Jadual spesifikasi ujian
 
Sample Jsu Pendidikan
Sample Jsu Pendidikan Sample Jsu Pendidikan
Sample Jsu Pendidikan
 
Jadual Spesifikasi Ujian (Jsu)
Jadual Spesifikasi Ujian (Jsu)Jadual Spesifikasi Ujian (Jsu)
Jadual Spesifikasi Ujian (Jsu)
 
Oop c++class(final).ppt
Oop c++class(final).pptOop c++class(final).ppt
Oop c++class(final).ppt
 
class and objects
class and objectsclass and objects
class and objects
 

Similar a FINAL PAPER FP301 OBJECT ORIENTED PROGRAMMING

Module wise format oops questions
Module wise format oops questionsModule wise format oops questions
Module wise format oops questions
SANTOSH RATH
 
classes object fgfhdfgfdgfgfgfgfdoop.pptx
classes object  fgfhdfgfdgfgfgfgfdoop.pptxclasses object  fgfhdfgfdgfgfgfgfdoop.pptx
classes object fgfhdfgfdgfgfgfgfdoop.pptx
arjun431527
 
C programming session 01
C programming session 01C programming session 01
C programming session 01
Vivek Singh
 
Mid term sem 2 1415 sol
Mid term sem 2 1415 solMid term sem 2 1415 sol
Mid term sem 2 1415 sol
IIUM
 

Similar a FINAL PAPER FP301 OBJECT ORIENTED PROGRAMMING (20)

FP 301 OOP FINAL PAPER JUNE 2013
FP 301 OOP FINAL PAPER JUNE 2013FP 301 OOP FINAL PAPER JUNE 2013
FP 301 OOP FINAL PAPER JUNE 2013
 
Computer Science Sample Paper 2015
Computer Science Sample Paper 2015Computer Science Sample Paper 2015
Computer Science Sample Paper 2015
 
CBSE Grade12, Computer Science, Sample Question Paper
CBSE Grade12, Computer Science, Sample Question PaperCBSE Grade12, Computer Science, Sample Question Paper
CBSE Grade12, Computer Science, Sample Question Paper
 
Module wise format oops questions
Module wise format oops questionsModule wise format oops questions
Module wise format oops questions
 
Cs practical file
Cs practical fileCs practical file
Cs practical file
 
Comp 328 final guide
Comp 328 final guideComp 328 final guide
Comp 328 final guide
 
classes object fgfhdfgfdgfgfgfgfdoop.pptx
classes object  fgfhdfgfdgfgfgfgfdoop.pptxclasses object  fgfhdfgfdgfgfgfgfdoop.pptx
classes object fgfhdfgfdgfgfgfgfdoop.pptx
 
Oops Quiz
Oops QuizOops Quiz
Oops Quiz
 
UGC-NET, GATE and all IT Companies Interview C++ Solved Questions PART - 2
UGC-NET, GATE and all IT Companies Interview C++ Solved Questions PART - 2UGC-NET, GATE and all IT Companies Interview C++ Solved Questions PART - 2
UGC-NET, GATE and all IT Companies Interview C++ Solved Questions PART - 2
 
C test
C testC test
C test
 
C __paper.docx_final
C __paper.docx_finalC __paper.docx_final
C __paper.docx_final
 
Technical aptitude Test 1 CSE
Technical aptitude Test 1 CSETechnical aptitude Test 1 CSE
Technical aptitude Test 1 CSE
 
Express 070 536
Express 070 536Express 070 536
Express 070 536
 
C programming session 01
C programming session 01C programming session 01
C programming session 01
 
CS Sample Paper 1
CS Sample Paper 1CS Sample Paper 1
CS Sample Paper 1
 
Part - 2 Cpp programming Solved MCQ
Part - 2  Cpp programming Solved MCQ Part - 2  Cpp programming Solved MCQ
Part - 2 Cpp programming Solved MCQ
 
BISH CS Modle Exit Exam.doc
BISH CS Modle Exit Exam.docBISH CS Modle Exit Exam.doc
BISH CS Modle Exit Exam.doc
 
Technical questions
Technical questionsTechnical questions
Technical questions
 
Mid term sem 2 1415 sol
Mid term sem 2 1415 solMid term sem 2 1415 sol
Mid term sem 2 1415 sol
 
Computer science ms
Computer science msComputer science ms
Computer science ms
 

Más de Amira Dolce Farhana (6)

Final paper FN512 server management
Final paper FN512 server managementFinal paper FN512 server management
Final paper FN512 server management
 
Final paper FN511 Switching & Routing
Final paper FN511 Switching & RoutingFinal paper FN511 Switching & Routing
Final paper FN511 Switching & Routing
 
FINAL PAPER FN311 INTERNET SERVICES
FINAL PAPER FN311 INTERNET SERVICES FINAL PAPER FN311 INTERNET SERVICES
FINAL PAPER FN311 INTERNET SERVICES
 
Osha ERGONOMICS
Osha ERGONOMICSOsha ERGONOMICS
Osha ERGONOMICS
 
Kertas kerja lawatan ke rumah anak yatim
Kertas kerja lawatan ke rumah anak yatimKertas kerja lawatan ke rumah anak yatim
Kertas kerja lawatan ke rumah anak yatim
 
FINAL PAPER FP501 OPEN SOURCE OPERATING SYSTEM
FINAL PAPER FP501 OPEN SOURCE OPERATING SYSTEMFINAL PAPER FP501 OPEN SOURCE OPERATING SYSTEM
FINAL PAPER FP501 OPEN SOURCE OPERATING SYSTEM
 

Último

Último (20)

On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 

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