0% found this document useful (0 votes)
5 views21 pages

(16 May) Computer Science (CS) Mock Exam: Question Paper 101 Marks

The document is a mock exam for a Computer Science course, consisting of various programming and object-oriented programming questions. It covers topics such as class design, data types, sorting algorithms, and relationships between classes. The exam includes coding tasks, explanations of concepts, and the construction of methods and diagrams.

Uploaded by

Aye Myatt Naing
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views21 pages

(16 May) Computer Science (CS) Mock Exam: Question Paper 101 Marks

The document is a mock exam for a Computer Science course, consisting of various programming and object-oriented programming questions. It covers topics such as class design, data types, sorting algorithms, and relationships between classes. The exam includes coding tasks, explanations of concepts, and the construction of methods and diagrams.

Uploaded by

Aye Myatt Naing
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

[16 May] Computer Science

Mock Exam (CS)


Question Paper
101 marks

Printed with revisiondojo.com

m
co
o.
oj
o nd
si
vi
re
Question 1
A restaurant uses an object-oriented program to manage the cost of the food and drink consumed by
customers. Everytime a table is occupied a `Payment`object is instantiated which will contain details of
the items ordered. As each item is ordered, a `FoodItem`or a `DrinkItem`object is added to the
`Payment`object as appropriate.

public class Payment


{
private FoodItem fi = **new** FoodItem$100$; **private int** fiCount; **private static double** foodTax
= 0.2; // 20 % sales tax added to // all food prices **private** DrinkItem di = new DrinkItem100;
private int diCount;
private static double drinkTax = 0.1; // 10 % sales tax added to
// all drink prices
public Payment()
{

m
fiCount = 0;
diCount = 0;
} co
o.
public DrinkItem getDi(int x)
oj

{
nd

return dix;
}
o

// all other accessor and mutator methods are included


si

// addFoodItem() – this method adds a new FoodItem object


vi

// addDrinkItem() – this method adds a new DrinkItem object


re

public static double findPrice(Item$$ pl, String c)


{ //code missing }
// calculateBill() – This method returns the bill (the total value of
// the items consumed for a particular table)
}
public class FoodItem
{
private String itemCode;
private int quantity;
public FoodItem(String x, int y)
{
itemCode = x;
quantity = y;
}
// all accessor and mutator methods are included
}
The DrinkItemclass is defined in a similar way.
Whenever a Payment object is instantiated, the variables fiCount and diCount are initialized to 0 through
the code in the constructor.
1. Outline an alternative method of initializing these variables that would not require the use [2]
of the code in the constructor.

m
co
o.
oj
o nd

2. State the implication of the use of the term `static`in the `Payment`class. [2]
si
vi
re
3. With reference to two examples from the classes in the resource, explain the benefits [4]
gained by the use of different data types.

m
4. Describe the purpose of the following statement:
co [3]
o.
`**private** FoodItem[] fi = **new** FoodItem[100]`
oj
o nd
si
vi
re
5. The `Payment`class method `addFoodItem()`is passed a `FoodItem`object as a [3]
parameter.
Construct the method `addFoodItem()`.

m
co
o.
oj
o nd
si
vi
re
Question 2
1. The `Arrival`object has two methods named `compareWith`. [2]

Outline why calling the `compareWith`method does not cause a conflict.

2. Outline the use of data-hiding as a security feature in OOP. [2]

m
co
o.
oj
o nd

State the name of this OOP property.


si

3. [1]
vi
re
Question 3
A sorting algorithm needs to be implemented using selection statements.
1. Construct code that finds the minimum value in an array numbers of integers. [4]

m
co
o.
Explain how the if statement is used in your code to compare values.
oj

2. [2]
o nd
si
vi
re

3. Define the term 'local variable' and explain its scope in the context of your code. [2]
Question 4
An online education platform tracks students and their courses. The platform has a Student class and a
Course class.
private String courseName;
private int courseCode;
private Student[] enrolledStudents;

public Course(String courseName, int courseCode, int capacity) {


this.courseName = courseName;
this.courseCode = courseCode;
this.enrolledStudents = new Student[capacity];
}

m
public void enrollStudent(Student student) {
// code to add a student to the enrolledStudents array

co
}
}
o.
oj
public class Student {
private String studentID;
nd

private String name;


private boolean activeStatus;
o
si

public Student(String studentID, String name) {


this.studentID = studentID;
vi

this.name = name;
re

this.activeStatus = true;
}

public String getStudentID() {


return studentID;
}

public void setActiveStatus(boolean status) {


this.activeStatus = status;
}
}
1. Construct code to create an instance of the Student class with a student ID of "S12345" [2]
and name "John Doe".

2. Explain the purpose of the `setActiveStatus` method in the Student class. [2]

m
co
o.
oj

Describe the relationship between the Course and Student classes.


nd

3. [3]
o
si
vi
re
4. Outline one benefit of setting Student attributes as private. [2]

m
co
o.
oj
o nd
si
vi
re
Question 5
A task scheduler needs to manage tasks with varying priorities.
1. Describe how a priority queue differs from a regular queue. [2]

2. Outline how a priority queue can be implemented using a linked list. [2]

m
co
o.
oj
o nd
si
vi
re
3. Construct the method insertTask to add tasks into the linked list in order of priority. [6]

m
co
o.
oj
o nd
si
vi
re
Question 6
A company is developing a suite of financial software tools, utilizing programming teams in different
countries.
1. Discuss the use of programming teams in software development projects. [4]

m
co
o.
oj

Outline two reasons why using programming teams in different locations may be [4]
nd

2.
problematic.
o
si
vi
re
3. Describe one advantage and one disadvantage of object-oriented programming for the [4]
development of financial software tools.

m
co
o.
oj
o nd
si
vi
re
Question 7
A simulation game includes classes such as Vehicle, Car, and Bicycle. Both Car and Bicycle inherit from
Vehicle.
1. Explain the term encapsulation. [2]

Explain one advantage of encapsulation in the context of the simulation game.

m
2. [3]

co
o.
oj
o nd
si
vi
re
3. Explain two advantages of modularity in program development for this game. [4]

m
co
o.
oj
o nd
si
vi
re
Question 8
In a university system, a Course object is related to multiple Student objects. Each student is enrolled in
one or more courses.
1. Describe the relationship between the Course and Student objects in this scenario. [2]

Construct a UML class diagram showing Course and Student with an appropriate

m
2. [3]
relationship.
co
o.
oj
o nd
si
vi
re

3. Explain one benefit of defining clear relationships between objects in a program. [2]
Question 9
The Treatment object needs to be developed further. There are three possible types of treatment and
this is to now be recorded.
1. Construct diagrams to show how inheritance can be used to re-design the Treatment [6]
class.

m
co
o.
oj
o nd
si
vi
re
2. Describe three advantages of modularity in program development. [6]

m
co
o.
oj
o nd
si
vi
re
Question 10
Computer-aided design incorporates 2D and 3D visualization. A car manufacturer decides to adapt a
current design to include extra features. The designer starts by loading a wire frame version of the
current design.
1. Outline the way in which the wire frame graphic represents the car design. [2]

m
2. Identify one change to the design of the car that could be made using the wire frame. [1]

co
o.
oj
nd

3. Outline how the wire frame could be manipulated to make this change. [2]
o
si
vi
re

4. Outline how the designer could interact with the computer in order to achieve this. [2]
5. Identify two changes to the interior and exterior that the designer may want to make. [2]

6. Describe the visualization techniques that would be applied to convert the wire frame to a [6]
3D view of the car, as it would appear when manufactured.

m
co
o.
oj
o nd
si
vi
re

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy