Computer Science S5 Marking Scheme
Computer Science S5 Marking Scheme
Date: 22/06/2022
Period: 8H30'-11H30'
DURATION: 3 hours
Marks
INSTRUCTIONS
Page 1 of 5
SECTION A: ATTEMPT ALL QUESTIONS. (55 marks)
6) Transmission media are broadly classified into two groups: Guided and
Unguided media. Explain each group. (5 Marks)
7) A database contains a table with eight fields. The table currently has 100
records and each has data in each field. Answer the following question:
(3 Marks)
a. How many entities are contained in the database?
b. How many attributes are contained in database?
c. How many individual pieces of data are in the database?
Page 2 of 5
8) Suggest an output of the following program (2 Marks)
#include<iostream>
using namespace std;
int main (){
int num, *ptr1, *ptr2;
ptr1=#
ptr2=ptr1+8;
cout<<”the difference is:”<<ptr2-ptr1<<endl;
return 0;
}
9) List any three advantages of inheritance (3 Marks)
10) Answer TRUE or FALSE, the following sentences related to vb: (2 Marks)
a) A project is an anything that is found on the computer specifically on
the desktop.
b) A class is collection of object with similar type
11) Write a class definition that creates a class called leverage with one
private data member,crowbar, of type int and one public function whose
declaration is void pry(). (4 Marks)
12) Write a Java program to print 'Hello' on screen and then print your
name on a separate line. Using input from the user (6 Marks)
13) You are browsing a website on the internet while the speed is okay and
suddenly you find that the page is loading slowly. Investigate the reason
behind slowness? (3 Marks)
Page 3 of 5
SECTION B: ATTEMPT THREE QUESTIONS. (30 Marks)
14) write a Java program to sort a numeric array and a string array.(10 Marks)
15) Compare computerized vs non-computerized database with at least 5 for
each. (10 Marks)
16) Using a pointer write a C++ program which will ask the user to enter data
and compute the area of a rectangle. Area = width*length. (10 Marks)
Page 4 of 5
SECTION C: ATTEMPT ANY ONE QUESTION. (15 marks)
20) Create a class student with the following specification (15 Marks)
Private members of class student:
admno integer
sname 20 character
eng. math, science float
total
float total() a function to calculate eng + math + science with float return type.
Public member function of class student
Takedata() Function to accept values for admno, sname, eng, science and
invoke ctotal() to calculate total.
Showdata() Function to display all the data members on the screen.
End !!!!
Page 5 of 5
Computer Science
MARKING GUIDE
DURATION: 3 Marks
INSTRUCTIONS
Page 1 of 12
SECTION A: ATTEMPT ALL QUESTIONS. (55 marks)
i. Standard Input: This is used to feed the data to user’s program and
usually a keyboard is used as standard input stream and represented
as System.in.
ii. Standard Output: This is used to output the data produced by the
user's program and usually a computer screen is used to standard
output stream and represented as System.out.
iii. Standard Error: This is used to output the error data produced by
the user's program and usually a computer screen is used to standard
error stream and represented as System.err.
Page 2 of 12
this() is used to access one constructor from another with in the same
class while super() is used to access superclass constructor. Either this()
or super() exists it must be the first statement in the constructor.
Output:
4
12
24
24
0
5) Determine the order in which the elements would be accessed during
Pre-Order, In Order and Post-Order traversals. (6 Marks)
Answer
Answer
Pre-order: A B D F C E H
In-order: D B F E C H A
Post-order: D F B E H C A
6) Transmission media are broadly classified into two groups: Guided and
Unguided media. Explain each group. (5 Marks)
Page 3 of 12
Answer
Wired or Guided Media: are the cables that are tangible or have physical
existence and are
limited by the physical geography. Example guided media are: Twisted
pair cable, co-axial
cable and fiber optical cable.
• Wireless or Unguided Media are the ways of transmitting data without
using any cables.
These media are not bounded by physical geography. Example of
unguided media are:
Radio wave, Infrared, Bluetooth.
7) A database contains a table with eight fields. The table currently has 100
records and each has data in each field. Answer the following question:
(3 Marks)
a. How many entities are contained in the database?
b. How many attributes are contained in database?
c. How many individual pieces of data are in the database?
Answer
a) one entity
b) 8 attributes
c) 800 piece of data Order, and make a relationship between those
tables.
8) Suggest an output of the following program (2 Marks)
#include<iostream>
using namespace std;
int main (){
int num, *ptr1, *ptr2;
ptr1=#
ptr2=ptr1+8;
cout<<”the difference is:”<<ptr2-ptr1<<endl;
return 0;
}
Answer
The difference is 8
9) List any three advantages of inheritance (3 Marks)
Answer
1. Inheritance helps the code to be reused in many situations.(reusability)
2. It increases program structure which result in greater reliability.
Page 4 of 12
3. Saves Time and Effort
10) Answer TRUE or FALSE, the following sentences related to vb: (2 Marks)
a) A project is an anything that is found on the computer specifically on
the desktop.
b) A class is collection of object with similar type
Answer
a) False
b) True
11) Write a class definition that creates a class called leverage with one
private data member,crowbar, of type int and one public function whose
declaration is void pry(). (4 Marks)
Answer
class leverage
{
private:
int crowbar;
public:
void pry();
};
12) Write a Java program to print 'Hello' on screen and then print your
name on a separate line. Using input from the user (6 Marks)
Answer
import java.util.Scanner;
public class Main {
public static void main(String[] args)
{
Scanner input = new Scanner (System.in);
13) You are browsing a website on the internet while the speed is okay and
suddenly you find that the page is loading slowly. Investigate the reason
behind slowness? (3 Marks)
Answer
Page 5 of 12
Causes: bad made cables, malfunctioning of network devices, wireless
interference and weather.
14) write a Java program to sort a numeric array and a string array.(10 Marks)
Answer
package arrayexercice;
import java.util.Arrays;
public class Exercise1 {
public static void main(String[] args){
int[] my_array1 = { 17, 20, 18, 14, 13,14, 24, 54, 72, 23, 56, 21, 57, 56};
String[] my_array2 = { "Java", "Python", "PHP", "C#", "C Programming", "C++" };
System.out.println("Original numeric array : "+Arrays.toString(my_array1));
Arrays.sort(my_array1);
Page 6 of 12
System.out.println("Sorted numeric array : "+Arrays.toString(my_array1));
System.out.println("Original string array : "+Arrays.toString(my_array2));
Arrays.sort(my_array2);
System.out.println("Sorted string array : "+Arrays.toString(my_array2)); }}
#include <iostream>
using namespace std;
int main()
{
int width,length,area,*p;
cout <<"\nenter the width";
Page 7 of 12
cin>>width;
cout <<"\nenter the length";
cin>>length;
p = &width;
area = (*p) * length;
cout<<"The area of Rectangle is "<<area;
return 0;
}
17) Build an application by using vb6.0 or vb.net to calculate the volume of
the cylinder(V = πr2h) (10 Marks)
Answer
Vb6.0 Vb14
Private Sub Command1_Click() Public Class Form1
Label1.Caption = 3.14 *
Val(Text1.Text ^ 2) * Private Sub
Val(Text2.Text) Button1_Click(sender As
End Sub Object, e As EventArgs)
Handles Button1.Click
Private Sub Form_Load() Label3.Text = 3.14 *
Text1.Text = "" Val(TextBox1.Text ^ 2) *
Text2.Text = "" Val(TextBox2.Text)
Label1.Caption = "" End Sub
End Sub
Private Sub
Form1_Load(sender As Object,
e As EventArgs) Handles
MyBase.Load
TextBox1.Clear()
TextBox2.Clear()
Label3.Text = ""
End Sub
End Class
Page 8 of 12
Answer
Page 9 of 12
SECTION C: ATTEMPT ANY ONE QUESTION. (15 marks)
f- Project Explorer Window: it is a list of the forms and modules for the
current projects. lt is a hierarchical tree- branch structure, where the
project at top of tree and other parts like forms ,modules) descend from
this tree.
Page 10 of 12
h- Code Editor Window: Code Editor Window is used to write a VB code for
an application. For each form there is a separate code editor window. It is
displayed when user clicks on form or object in form.
20) Create a class student with the following specification (15 Marks)
Private members of class student:
admno integer
sname 20 character
eng. math, science float
total
float total() a function to calculate eng + math + science with float return type.
Public member function of class student
Takedata() Function to accept values for admno, sname, eng, science and
invoke ctotal() to calculate total.
Showdata() Function to display all the data members on the screen.
Answer
#include<iostream>
using namespace std;
class student
{
private:
int admno;
char sname[20];
float eng,math,science;
float total;
float ctotal()
{
return eng+math+science;
}
public:
void Takedata()
{
cout<<"Enter admission number ";
cin>>admno;
cout<<"Enter student name " ;
cin>>sname;
cout<< "Enter marks in english, math, science ";
cin>>eng>>math>>science;
total=ctotal();
Page 11 of 12
}
void Showdata()
{
cout<<"Admission number "<<admno<<"\nStudent name
"<<sname<<"\nEnglish " <<eng<<"\nMath "<<math<<"\nScience
"<<science<<"\nTotal "<<total;
} };
int main ()
{
student obj ;
obj.Takedata();
obj.Showdata();
return 0;
}
End !!!!
Page 12 of 12