0% found this document useful (0 votes)
21 views

Questions and Answers of Computer Science

Uploaded by

tuyishimiret498
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Questions and Answers of Computer Science

Uploaded by

tuyishimiret498
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 246

RWANDA BASIC EDUCATION BOARD

MINISTRY OF EDUCATION

PREPARED BY COMPUTER SCIENCE DEPARTMENT


PART I: FREQUENTLY ASKED QUESTIONS OF SECTION A.

1) Define the following terms:


(a) Compiler

ANSWER:
Compiler is a program that converts instructions into a machine-code or lower-level form so that
they can be read and executed by a computer.

(b) Debugger

ANSWER:
a computer program that assists in the detection and correction of errors in other computer
programs.

(c)Computer
ANSWER:

A computer is an electronic device capable of receiving raw facts (data) and performing a
sequence of operations on the data based on special computer instructions (processing) to
produce desired output (information).

(d)Computer Science
ANSWER:
Computer science-The study of the principles and use of computers.

Computer science is a branch of science that deals with theory of computation, or design and
operation of computer hardware and software, and of the application of computers in all sectors.

2) What is the role of ALTER statement in SQL?


ANSWER:
 The ALTER TABLE statement is used to add, delete, or modify columns in an existing
table.
 The ALTER TABLE statement is also used to add and drop various constraints on an
existing table.

3) Is Laptop hardware maintenance difficult comparing to a desktop computer maintenance?


Explain

ANSWER:
Yes, Laptop hardware maintenance is difficult comparing to a desktop computer maintenance
because Laptop components are proprietary, so you may not be able to use components made by
one laptop manufacturer to repair a laptop made by another manufacturer which makes that
technicians may have to obtain certification for each laptop manufacturer they support. Desktop
components are standardized.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 1


4) What is meant by case sensitive? Is c++ case sensitive?

ANSWER:
Yes, C++ is case sensitive
✓ C++ is case sensitive it means uppercase and lowercase letters are considered to be different.
✓ A variable named age is different from Age, which is different from AGE.
✓ int age, Age, AGE; // those 3 variables are different.

5) Briefly differentiate bandwidth and Latency

ANSWER:
Bandwidth is the amount of data that can be transmitted in a fixed amount of time. OR
Bandwidth is measured in the number of bits that can be sent every second.
Latency is the time between requesting data and receiving data.

6) Give any five ports found on a personal computer.

ANSWER:

 VGA Port
 USB Port
 RJ-45 Port (Ethernet)
 HDMI Port
 Line-In port
 Line-Out port

7) Write the abbreviations in full as used in computer science


a) ESD
b) CMOS
c) OS
d) MSB

ANSWER:
a) ESD - Electro Static Discharge
b) CMOS - Complementary Metal-Oxide Semi-conductor
c) OS - Operating System
d) MSB - Most Significant Bit

8) Which of the following is an Internet services provider in Rwanda?


a. MTN
b. Techno Brain
c. Airtel
d. RDB

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 2


e. Both a and c
f. None of the above.

ANSWER:
e. Both a and c

9) a) Illustrate four (4) output devices of a computer .


b) Differentiate computer hardware to computer software.
ANSWER:
a) Examples of output devices are as follow: Screen, projector, speakers, printers, Headphones,
sound cards, video cards.

b) Computer hardware is any part of the computer which you can physically touch while
computer software is a set of instructions called computer programs that make the different parts
of a computer work.

10) Differentiate between the compilers and interpreters.


ANSWER:
A compiler translates the entire source program into machine readable form while an interpreter
translates the source program to machine language line-by-line.

11) One the component of computer is its CPU. What is CPU and what is role does it play in a
computer.

ANSWER:

CPU: Central Processing Unit.

 It is responsible for fetching, decoding, and executing program instructions.


 it performs mathematical and logical calculations.
 CPU performs all types of data processing operations.
 It stores data, intermediate results, and instructions (program).
 It controls the operation of all parts of the computer.
 It takes all decisions.

12) What is the importance of primary key of relation?

ANSWER:

The importance of primary key of relation is to identify uniquely each record of relation (table).

13) Based on cardinality explain the different types of relationship between entities and give an
example for each.
ANSWER:

One to one (1:1)


An instance (row) of an entity can relate to only one instance of another entity
Ex: president – country

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 3


Person – passport
One to many (1:M)
An instance of an entity can relate to multiple instances of another entity
Ex: country can have many states
Many to one (M:1)
Many instances of an entity can relate to only one instance of another entity
Ex many employees can work in one department
Many to many (M:M)
Multiple instances of an entity can relate to multiple instances of another entity
Ex: many teachers can teach many students

14) Define the following Visual Basic terms:

a)Procedure

b)Event procedures

ANSWER:

a)Procedure: a procedure is the block of visual basic statement enclosed by declaration statement
(sub, function, operator, get, and set) and a matching end declaration.

Eg. Private sub command1_click


Statement
End sub

b)Event procedures: are the code related to some object, this is code that is executed when a
certain event occurs.
15) a)What are three primary steps involved in building a Visual Basic application?
ANSWER:

 Draw the user interface


 Assign properties to controls
 Attach code to control
b) What are three mode used in vb 6.0.
ANSWER:

 Design mode: used to build application


 Run mode: used to run application
 Break mode: application halted (stop) and debugger is available.
16) Define the following
(a)Portable device

(b)Smartphone

(c)Data structure

(d)Define a logic gate.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 4


ANSWER:
a) A portable device: is a device that can easily be carried. It is a small form of a computing
device that is designed to be held and used in the hands.

b) Smartphone: is a handheld personal computer with a mobile operating system and an


integrated mobile broadband network connection for voice, SMS, and Internet data
communication.

c) Data structure: is a way of collecting and organizing data in such a way that we
can perform operations on these data in an effective way.
d) A logic gate is an electronic circuit that has some idealized or physical device implementing a
Boolean function; that is, it performs a logical operation on one or more logical inputs, and
produces a single logical output.

17) a) What is computer threat?


ANSWER:
Threats refer to anything that has the potential to cause serious harm to a computer system
(hardware and software).
b) List any 4 computer attack.
ANSWER:

 Viruses.
 Worms.
 Trojans.
 Spyware.
 adware,
 SQL injection etc.

18) A program in ‘C+ +’ language contains the following initialization:


int tab[8] = {1,2,3,4,5,6,7,8};
a) What is the meaning of tab?
b) Write the statement to display the value 5 in the above initialization?
ANSWER:
a) tab is an array name.
b)cout<<tab[4];

19) a) Determine the order in which the elements would be accessed during an in-order, pre-
order and post-order traversal.

b) Determine the path between 50 and 86.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 5


ANSWER:

a) In order (12 ,30,40,50,86,90,100)


Pre order (50,30,12,40,90,86,100)
Post order (12,40,30,86,100,90,50)
b) The path between 50 and 86 is 50,90 and 86.

20) What is the difference between UNION and UNION ALL.

ANSWER:

UNION and UNION ALL are SQL operators used to concatenate 2 or more result sets. This
allows us to write multiple SELECT statements, retrieve the desired results, then combine them
together into a final, unified set.
The main difference between UNION and UNION ALL is that:
 UNION: only keeps unique records
 UNION ALL: keeps all records, including duplicates

21) a)Define what IP address is.


b) Explain the difference between static and dynamic IP addresses?

ANSWER:

a)It is the unique number which identifies any electronic device on a network.
An IP address is the numeric identity of a node in the network.

b) A Static IP address is assigned manually. Once assigned it does not change unless it is
changed manually again.

While

A Dynamic IP address is assigned by a service usually DHCP. It can change at any time.

Static IP addresses Dynamic IP addresses

They don’t change They change

They are more flexible They are not flexible


They are usually assigned to servers They are usually assigned to clients
They are manually assigned by network They are dynamically assigned by DHCP
administrator server.

They are expensive than dynamic IP They are Cheaper than static IP addresses
addresses

22) Explain the importance of reading the user manual before installing new software.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 6


ANSWER:

 The help manual is important in identifying the hardware specifications required in order
to install the new software.
 It helps you to know the procedures to follow in order to install the new software.
23) Outline the procedure you would follow to put out fire in computer lab that may have been
caused by electrical fault.
ANSWER:

 Switch off power from main switch or circuit breaker.


 Use non- water, non- powder based fire extinguisher to put out the fire.
24) Pointer is different from array. Explain

ANSWER:

A pointer is a variable which contains the address in memory of another variable. While
Array is a collection of data elements having the same name and same data type.

25) What is the difference between database Administrator and Database End users?

ANSWER

 Database administrator (DBA): responsible for authorizing access to the database,


monitoring its use and managing all the resources to support the use of the entire database system
 End user: people whose jobs require access to a database for querying, updating and
generating reports

26) Give by explaining the types of common network cables.

ANSWER:

Types of common network cables:


 Coaxial cable which has a single copper conductor at its center, a plastic layer which
provides insulation between the center conductors and a braided metal shield. The coaxial is
divided into thick coaxial cable and thin coaxial cable.
 Fiber optic consists of a center glass core surrounded layers of protective materials. The
fiber optic has the ability to carry signals over much longer distances and at vastly speeds than
coaxial and twisted pair.
 Twisted pair cable which is divided into two: shielded and unshielded twisted pair.
Unshielded twisted pair (UTP) is the most popular and is generally the best option for school
networks.

27) Explain the importance of reading the user manual before installing new software.
ANSWER:

i. The help manual is important in identifying the hardware specifications required in order to
install the new software.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 7


ii. It helps you to know the procedures to follow in order to install the new software

28) Define:
a) Algorithm
b) Variable
c) Expression
d) Data type
e) Pseudocode

ANSWER:

a) Algorithm: is a set of steps used to solve a problem


b) Variable: is a space in memory to store a particular value.
c) Expression: is a set of operands joined by operators’ equivalent to a single variable.
d) Data type: is the kind of data a variable can store. It shows the size occupied by a variable in
computer memory
e)Pseudocode: is an outline of a program , written in form that can easily be converted into real
programming statements.

29) Highlight some of achievements of the fifth computer generation.


ANSWER:

 Artificial intelligence
 Graphical user interface
 Small physical size but large processing power
 Easy programming

30) a)Define a flowchart.


ANSWER:

Flowchart is a diagrammatic representation that illustrates the sequences of operations to be


performed to get the solution of a program or is a graphical representation of an algorithm.
b) State three advantages of using flowcharts over pseudocode in formulating an algorithm.
ANSWER:

The following are advantages of using flowcharts over pseudocode:


 Flowcharts are better way of communicating the system logic
 With a flowchart, problem can be analyzed in a more effective way.
 Graphical representation of design serves as good program documentation
 Flowchart makes it easier to debug and maintain a program
31) Who is considered as the father of the computer?

ANSWER:
Charles Babbage

32) State three factors you would consider before purchasing application software.
ANSWER:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 8


 The use needs
 The operating system environment
 The hardware requirements needed to run the software.

33) State any six functions of database management system


ANSWER:

 Data Dictionary Management,


 Data Storage Management,
 Data Transformation and Presentation,
 Security Management,
 Multi-User Access Control,
 Backup and Recovery Management,
 Data Integrity Management,
 Database Access Languages and Application Interface,
 Database Communication Interface

34) Why using an infrared TV remote control in our home will not interfere with the use of our
neighbor’s infrared TV remote control.
ANSWER:

The infrared TV remote control in our home will not interfere with the use of our neighbor’s
infrared TV remote control because of its frequencies (between 300 GHZ to 400 THZ) which
cannot penetrate walls.

35) Explain some of the characteristics that make a computer suitable for processing repetitive
tasks.

ANSWER:

It does not get tired - It can be programmed to perform a task repetitively - It does not have the
human body weaknesses - Once programmed it follows instructions exactly without fail.

36) Differentiate between the following terms:

(a) Mainframe and minicomputers.

ANSWER:

Mainframe: is smaller than supercomputer with slightly less processing power. Used as central
computer or server on large networks that require centralized data processing. Minicomputer is
smaller than mainframe. Used by smaller organizations as central server/ also used for
specialized applications e.g. the autopilot on airplanes.

(b) Analog and digital data.

ANSWER:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 9


Analog computer processes continuous data (analog data); Digital computer processes discrete
data.

(c) Servers and workstations.

ANSWER:
Server provides services to other computers on the network; Workstation used by the user, has
limited processing power and requests services from the server.

(d) Pseudocode and flowchart.


ANSWER:

A flowchart is a graphical representation of an algorithm while a pseudocode is a set of


structured statements.
(e) Selection and iteration control structures.
ANSWER:

Selection branches to an alternative action if while iteration repeats existing statement for a finite
number of times

37) a) What was the characteristics of first generation computers?

ANSWER:
First generation computers were large in size, consumed a lot of power, and produced a lot of
heat.

b) Highlight some of the achievements of the fifth generation computers.

ANSWER:
 Artificial intelligence
 Graphical User Interfaces
 Small physical size but large processing power
 Easy programming.

38) a) State two advantages of USB port over the parallel port.

ANSWER:
Smaller size, longer distance connectivity; less cumbersome; cheaper.

b) State four factors you would consider before installing computer software whether an
operating system or application software.
ANSWER:

 Memory (RAM) capacity.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 10


 Free hard disk space.
 Processor type and speed.
 Graphics display.
c) Why the truth table of an AND gate has four possible combinations?

ANSWER:
 It is because it has two entries making 22 = 4 possible combinations

d) Give a clear difference between VGA and HDMI connectors.


ANSWER:
HDMI (High-Definition Multimedia Interface) connector transports both sound and video data
while VGA (Video Graphic Array) connector carries video data only.
Note that both connectors transport any other type of data.

39) a) Explain why it is important to use the right tool for the right purpose when repairing,
upgrading or assembling a desktop PC.

ANSWER:
For quick working with minimum effort; to avoid spoiling the place or component you are trying
to repair.

b) You have just installed a new power supply, but the computer doesn’t seem to be getting any
power. What might be the problem?

ANSWER:
Check the fuse. Also check whether the power cable running from the power supply is plugged
onto the motherboard port or slot.

40) A customer is complaining that the power in the office sometimes surges, sometimes causes
blackouts and has EMI. What single device should you recommend to help the most in this
situation?

ANSWER:
A UPS to protect his/ her electronics.

41) a) Explain why it is important to regularly blow out dust from a computer.

ANSWER:
To reduce wear and tear due to friction; to reduce crashing of sensitive devices like the hard disk.

b) State the cleaning solution to keyboard and monitor

ANSWER:
Keyboard: use blower, special brushes and vacuum cleaner; Monitor: use blower, smooth
absorbent cloth.

42) i) Write the following abbreviations in full as used in computer systems:

(a) USB (b) SCSI

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 11


ANSWER:
USB: Universal Serial Bus; SCSI: Small Computer System Interface

ii) List 6 devices that use USB port connector.

ANSWER:
Computers, Scanners, Printers, Cameras, Storage devices, Hub, Phones.

iii) What is a logic circuits truth table?

ANSWER:
A truth table is a mathematical table used in Boolean algebra or propositional logic to compute
the outcome of all possible combinations of input values i.e. it can be used to tell whether an
expression is valid for all legitimate input values.

iv) Binary number system is fundamental to understanding how a computer works. Explain why
it is important to understand the concept of number systems.

ANSWER:
Digital electronic devices that utilize binary system such as digital cameras, TVs and media
players are dominating the electronic market.

v) Explain the importance of the following selection statements:

(a) IF..THEN
(b) Nested IF
(c) SWITCH
ANSWER:
 If.. is used to execute statements under true block if the Boolean return true
 Nested if - used to test multiple options e.g. in assigning grades
 Switch case - used when this an alternative to nested if used to test multiple conditions
under case.
43) a) Explain the importance of preventive maintenance, highlighting some routine maintenance
practices that need to be carried out in a computer laboratory.

ANSWER:

It keeps the computer working at optimum level and prevents unnecessary breakdowns caused
by dirt and water. You can do the following preventive maintenance:
(i) Use blower to blow out dust
(ii) Wipe the computer clean with a soft absorbent piece of cloth and non-water based cleaner
liquid.

b) Identify two alternative sources of backup power in case of blackout or brownout of main
electricity.

ANSWER:
UPS, Backup generator

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 12


c) Outline the procedure you would follow to put out fire in a computer lab that may have been
caused by electrical fault.

ANSWER:
Switch off power from main switch or circuit breaker; Use non-water non-powder based
extinguisher to put out the fire.

d) Assuming that a NOT gate has an input 0, what will be its output?

ANSWER:
1
e) Assuming that an OR gate has one input at 1 and the other one at 0. What will be its output?
ANSWER:
1
f) Draw the truth table of AND Gates

ANSWER:

44) i) Work out the following the binary difference:


(a) 10011 – 1100
(b) 10110 – 1011
(c) 101 – 100

(d) 10111 – 1111

ANSWER:
(a) 10011 – 1100 =111
(b) 10110 – 1011 = 1011
(c) 101 – 100 = 1
(d) 10111 – 1111 = 1000

ii) Perform the following binary multiplications:


(a) 101101 x 110
(b) 101101 x 111
(c) 1011.01 x 110.1

ANSWER:
(a) 101101 x 110 = 100001110
(b) 101101 x 111 = 100111011

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 13


(c) 1011.01 x 110.1 = 1001001.001

iii) Convert the following binary numbers to decimal form:

(a) 0.10101

(b) 11.0110

(c) 101.11110

(d) 100.110

ANSWER:
(a) 0.6562510 (b) 3.37510 (c) 5.937510 (d) 4.7510

iv) Convert the following hexadecimal numbers to decimal form:

(a) 3216 (b) CCD16 (c) EFE16 (d) 119 16 (e) 32816

ANSWER:
(a) 6310 (b) 5210 (c) 6610
(d) 64010 (e) 51210
v) Convert the following binary numbers to decimal form:

(a) 0101 (b) 1111 (c) 10101101110

(d) 10111111 (e) 1011001

ANSWER:
(a) 510 (b) 1510 (c) 139010 (d) 19110 (e) 8910
45) What is an event in Visual basics? Give two examples.

ANSWER:
An event is something that happens, usually but not always due to the user at the keyboard,
during a program’s operation.

Examples: Click, double-click

46) Differentiate between a variable from variable address.

ANSWER:
A variable address helps to locate it in the memory (It is the address that helps to locate the
variable in the memory).

while

A variable is a memory zone which is used to store data.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 14


47) Write an algorithm which stores 5 numbers entered by a user in array and display them to the
user.

ANSWER:
Var a(4) as array
Start
For (i=0 to 5)
Do
Write(“ enter a number:”)
Read (a(i))
End
For (i=0 to 5) do
Write(a(i))
End for

48) Give the codes for movenext, moveprevious methods in VB.

ANSWER:

Private sub cmdmovenext_click()

Adodc1.recordset.movenext

End sub

Private sub cmdmoveprevious_click()

Adodc1.recordset.moveprevious

End sub

49) What are the meanings of the following commands?

a) Date:
b) Ls
c) MD or mkdir

ANSWER:

Date: to display the current date

LS: Show listing of file in present directory

MD or mkdir: to create directory

50) Describe the system call in operating system.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 15


ANSWER:
A system call is a strategy or mechanism of calling a function which is in operating system in
order to realize a specific task (or is mechanism used by an application for requesting a service
from the operating system)

51) What are the outs of the following program.


#include <iostream>
using namespace std;
void prevnext (int x, int&prev, int&next){
Prev=x-1;
Next=x+1;}
int main()
int x=100, y, z;
prevnext(x, y, z);
cout<< “ Previous=” << y << “ , Next =” <<z;

ANSWER:
Previous=99, Next=101

52) a) What are the functions of a database management system?

ANSWER:

A role of DBMS is to manage access and ensure that all users have access and are used in
accordance with permissions and restrictions.

b) What are the roles of Intersection in SQL?

ANSWER:
The intersection operator INTERSECT returns a result set common to both data sets .

c) Give examples of intersection.

ANSWER:
SELECT * FROM Table_a

INTERSECT

SELECT * FROM Table_b

53) What are the 3 characteristics of a printer?

ANSWER:

The characteristics of a printer are:


 Its type
 Its print speed
 Its resolution expressed in DPI (Dowry Per Inch) or point per inch.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 16


 Its number of cartridges
 Its functionalities such as photo quality, reading of memory board extinct PC and
impression of the photographs, etc…

54) Write a program in C++ language to find a greater number of five numbers stored in array.

ANSWER:
#include<iostream>
using namespace std;
int main (){
int a[5], largest;
cout<<"Enter any numbers :"<<endl;
//Read n elements in an array
for(int i=0; i<5; i++){
cin>>a[i];
//consider first element as largest
largest =a[0];
for(int i=0; i<5; i++)
if(a[i]>largest){
largest=a[i];
}}
//print out the result
cout<<"Largest numbers is :"<<largest<<endl;
return 0;}

55) Define a Computer

ANSWER:
A computer is an electronic device capable of receiving raw facts (data) and performing a
sequence of operations on the data based on special computer instructions (processing) to
produce desired output (information).

56) Discuss the Characteristics of Read Only Memory (ROM).

ANSWER:

1. One can only read its content but you cannot write on it unless it is a special type of ROM.
2. It is non-volatile i.e. its content is not lost when the computer is switched off.
3. Stores permanent or semi-permanent instructions from the manufacturer called firmware. It
can store semi-permanent instructions because some variations of ROM chips can be
programmed according to the user’s specification.

57) Outline the procedure you would follow to put out fire in a computer lab that may have been
caused by electrical fault.
ANSWER:

Switch off power from main switch or circuit breaker; Use non-water non-powder based
extinguisher to put out the fire.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 17


58) a)By using simple words, define computer security?

ANSWER:
Computer security refers to techniques developed to safeguard information and systems stored
on computers.

b) Explain how a computer user can cause the errors to information system.

ANSWER:

A computer user can cause the errors to information system by using the wrong information.

59) What is a computer attack? Differentiate active attack to passive attack.

ANSWER:

A computer attack is any attempt to expose, alter, disable, destroy, steal or gain unauthorized
access to or make unauthorized use of an asset.
An active attack attempts to alter system resources or affect their operation while a passive attack
attempts to learn or make use of information from the system but does not affect system
resources

60) a)How to recognize that a document in a computer is infected by virus?

ANSWER:

You can know that a new document is virus infected by its extension .exe or .com

b) Explain what is social engineering in computer security.

ANSWER:
In computer security, a social engineer is a person who is able to gain access to equipment or a
network by tricking people into providing the necessary access information.

61) Write the following abbreviations in full:


a)NIC
b)HTTP
c)FDDI
d)SMTP
e)FTP
f)IMAP
g)ISO
h)WWW
i)UDP
j)WEP

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 18


ANSWER:
a)NIC: Network interface card

b)HTTP: Hypertext Transfer Protocol


c)FDDI: Fiber Distributed Data Interface
d)SMTP: Simple Mail Transfer Protocol
e)FTP : File Transfer Protocol
f)IMAP : Internet Message Access Protocol
g)ISO: International Standard Organization
h)WWW: World Wide Web
i)UDP: User Datagram Protocol
j)WEP : Wired Equivalent Privacy

62) Discuss the difference between logical and physical threats and give examples for each?
ANSWER:

Physical threats are digital storage media and hardware that can damage or destroy the
computer system. Example: Humidity, water
While logical threats are events or attacks that remove, corrupt, deny access, or steal
information. Example: viruses and spyware

63) Explain the difference between hardware and software failure.

ANSWER:

Hardware failure is a malfunction within the electronic circuits or electromechanical


components (disks, tapes) of a computer system while software failure is the inability of a
program to continue processing due to erroneous.
64) What is the main reason of the creation of OSI model? /
ANSWER:

The OSI model was created to help vendors create interoperable network devices and software in
the form of protocols so that different vendor networks could work with each other. It divides the
network communication process into smaller and simpler components, thus aiding component
development, design, and troubleshooting; it allows various types of network hardware and
software to communicate; and it prevents changes in one layer from affecting other layers.

65) By using clear example, compare access control and parental control.

ANSWER:

The comparisons between access control and parental control


Access control is a security technique that can be used to regulate who or what can view or use
resources in a computing environment while the Parental Controls feature is a valuable tool for
controlling the amount of time your children spend on the computer and the programs they’re
using.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 19


The access control model used by some operating system ensures authorized use of its objects
by security principals while Parental controls can filter the web, blocking inadvertent access to
inappropriate websites.

66) Why routers and switches do not operate at the same OSI reference model layer?

ANSWER:
Routers (layer 3 devices) use logical addressing and provide what is called packet switching.
Routers use a routing table (map of the internetwork) to make path selections and to forward
packets to remote networks. On the other side, switches (layer 2 devices) are not used to create
internetworks because they do not break up broadcast domains by default; they are employed to
add functionality to a network LAN. The main purpose of switches is to make a LAN work well
and do not forward packets to other networks as routers do.

67) Explain the different types of cybercrimes.

ANSWER:

Cybercrime types
 Cyberbullying is bullying that takes place using electronic technology
 Sexting is the sending and receiving of text, photo or video messages of children and
young people that are inappropriate and sexually explicit.
 Grooming is the way sexual predators get from bad intentions to sexual exploitation.
Basically, grooming is manipulation. It’s the process pedophiles use to get children they
target online to meet with them offline, the simple goal being sex.

68) Describe each one of the major components of a Local Area Network?

ANSWER:
 Hardware (Computers, Network Interface Card (NIC), Media or Cables, Hub, Switches,
repeaters)
 Access Methods: Rules that define how a computer puts data on and takes it from the
network cable.
 Network Topology: the logical or physical arrangement of network devices (nodes).
 Software: Programs to access and / or to manage the network.

69) How does a collision occur in a network?

ANSWER:
A data collision occurs when two or more computers send data at the same time. When this
happens, each computer stops data transmission and waits to resend it when the cable is free.

70) Discuss the importance of switches within a LAN.

ANSWER:
Advantages of switches are:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 20


 Switches increase available network bandwidth
 Switches reduce the workload on individual computers
 Switches increase network performance
 Networks that include switches experience fewer frame collisions because switches
create collision domains for each connection (a process called micro segmentation)
 Switches connect directly to workstations

71) Describe any 5 layers of the OSI model.

ANSWER:

a. Application: To allow access to network users


b. Presentation: To translate, encrypt and compress data
c. Session: To establish, manage and terminate sessions. For example, once user/ password
verification is done, the remote host maintains this session for a while and does not ask for
verification again in that time span.
d. Transport: This layer is responsible for end-to-end delivery between hosts.
e. Network: To move packets from source to destination to provide internetworking.
f. Data link: To organize bits into frames; to provide hop-to-hop delivery
g. Physical: To transmit bits over a medium; to provide mechanical and electrical specifications.
72) Discuss the advantages and disadvantages of FDDI within a Local Area Network.

ANSWER:

Advantages of FDDI
 FDDI supports transmission rates of 100 megabits per second on token-passing networks.
 FDDI provides high-speed network backbones that can be used to connect and extend
LANs.
 Fiber-optic cable such as the cable used with Fiber Distributed Data Interface (FDDI) can
support very large volumes of data over large distances.

Disadvantages
 Fiber Distributed Data Interface (FDDI) is an expensive technology to set up than
twisted-pair cable.
 Because most Fiber Distributed Data Interface (FDDI) installations use a redundant
second ring, more cabling is required.

73) Terambera Company Ltd is running a business and wishes to manage the information of all
employees in computerized way. The database of business contains one of the following entity
named “Employees” (id, name, age, address, salary).

Write SQL Commands to find a solution to get the following:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 21


i. The highly paid employees
ANSWER:

Select max(salary) as Highly_paid_employee from customers;

ii. The least paid employees


ANSWER:

Select min(salary) as Least_paid_employee from customers;

iii. The oldest employees


ANSWER:
Select max (age) as oldest from customers;

iv. The youngest employees


ANSWER:

Select min (age) as youngest from customers;

v. To generate total amount of salary at a given day.


ANSWER:

Select sum (Salary) as total_Salary from employees;


vi. To retrieve only the names and age of all employees
ANSWER:

Select names, age from employees;

vii. Add new column “sex”


ANSWER:
Alter table employees add Sex varchar (20);
viii. Change the data type of salary to decimals
ANSWER:

Alter table employees modify salary decimal(10,3);


ix. Add “Not null” constraint to age field (column)
ANSWER:

Alter table employees modify Age integer not null;


x. Remove the column “sex”
ANSWER:
Alter table employees drop Sex;

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 22


74) Explain the following terms:
a) Algorithm

b) Flowchart

ANSWER:

a) Algorithm is a step-by-step procedure, which defines a set of instructions to be executed in


certain order to get the desired output.

b) Flowchart is a diagrammatic or symbolic representation of step-by-step solution to a given


problem.

Flowchart is a diagrammatic representation that illustrates the sequence of operations to be


performed to get the solution of a problem. It is a graphical representation of an algorithm.

75) Draw the following gates and their truth tables.


a) NAND Gate

ANSWER:

b) XNOR Gate

ANSWER:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 23


76) Demonstrate and outline steps on how to access the disk management utility.
ANSWER:
1. Right click This PC icon/ Computer,
2. Click on Manage to display Computer management window
3. Click Disk management under storage
4. Right click the drive you wish to manage on the right pane

77) Give an illustration of the following logic gates: NOT, AND

NOT

AND

78) State three advantages of using functions.

ANSWER:

A modular program is easier to understand


Easier to debug or modify a modular program
Increases programmer productivity
Libraries can be used in other programs

79) Convert the following code segment into switch case construct.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 24


int ch;
cin>>ch;
If(ch = = 1)
{ cout<<“ Laptop”;
}
else If(ch = = 2)
{
cout<<“Desktop ”;
}
else if(ch= = 3)
{
cout<<“Notebook”;
}
else
{
cout<<“Invalid Choice”;
}

ANSWER:
int ch;
cin>>ch;
switch(ch)
{
Case 1 : cout<<“ Laptop”; break;
Case 2: cout<<“Desktop ”; break;
Case 3: cout<<“Notebook”;break;
Default : cout<<“Invalid Choice”;
}

80) a)Convert an octal number (345)8 to a binary number


ANSWER:

Octal 3 is equivalent to 011


Octal 4 is equivalent to 100
Octal 5 is equivalent to 101
Thus (345)8 is equivalent to (011100101)2

b) Convert binary number (10011101)2 to decimal

ANSWER:
1*27 + 0*26 + 0*25 + 1*24 + 1*23 + 1*22 + 0*21 + 1*20 = 157.
(10011101)2 = (157)10

81) To reference storage of a variable in main memory, two operators, namely size of and
address of (&) may be used, differentiate between the two operators.

ANSWER:
The sizeof() returns memory size allocated to a variable in bytes, while & returns actual address.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 25


82) Write the following acronyms in full: NTFS

ANSWER:
NTFS: New Technology File System

83) Explain two component of CPU

ANSWER:
The CPU is made up of three distinct components within it:
1. The Arithmetic Logic Unit (ALU): performs all arithmetic and logical operations.
2. Control Unit: interprets instructions and controls speed of execution using a clock.
3. Registers: special memories within the CPU for holding instructions and data.

84 a) Justify the reason why smartphones need an operating system.

ANSWER:
Smartphones are special purpose computers. They have similar resources and are used to
perform complex tasks similar computers hence the need for an operating system. They have a
fast processor, large memory, many user applications, fast access to the internet etc.

b) List five types of instructions of a computer program?

ANSWER:

The types of instructions of computer program are:

 Input instructions
 Output instructions
 Processing instructions
 Declaration instructions
 Assignment instructions

85) Write in full the following abbreviations:

a) RJ45 b) VPN c) ISP d) ISO e) UTP

ANSWER:

a)RJ45: Registered Jack b) VPN: Virtual Private Network c) ISP: Internet Service Provider

d)ISO: International Standards Organizations e) UTP: Unshielded Twisted Pair

86) Differentiate between the following terms


a) Hub and switch in LAN?

b) Data inconsistency and data integrity


ANSWER:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 26


A hub is a network hardware device for connecting multiple devices together and making them
act as a single network segment.
Hub receives message on one port and then send it out to all other ports, this means that when
hub receives message, the received message is regenerated or duplicated and sent to all
computers connected to the hub, each computer on the network receives the message. While
Switch filters and segments network traffic by sending messages only to the device to which it
is sent. This means that when a switch receives a message do not duplicate it, it sends it directly
to the destination computer. This provides higher dedicated bandwidth to each device on the
network.
b) Data inconsistency and data integrity
Data inconsistency is a situation where there are multiple tables within a database that deal with
the same data but may receive it from different inputs. while
Data integrity” refers to the accuracy and consistency of data stored in a database.

87) What meant by the ipconfig command?


ANSWER:
 ipconfig command: is used to find out your current local IP address, default gateway,
TCP/IP settings and more.

88) a)What is the difference between Traditional File Processing Systems (TFPS) and Database
Management System (DBMS)?

ANSWER:
The main difference between file system and DBMS is that the file system helps to store a
collection of raw data files into the hard disk while the DBMS helps to easily store, retrieve and
manipulate data in a database.

b) What is the difference between Logical data independence and Physical data independence .

ANSWER:
Physical Data Independence modifies the physical schema without causing the application
program to be rewritten. While

Logical data independence is the ability to modify the logical schema without causing
application programs to be rewritten.

89) Complete the following statement using suitable word.


A network usually confined to a geographic area, such as a single building or a computer Lab is
called ………………………………………………………
ANSWER:
LAN

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 27


90) Discuss the concept of data independence and explain its importance in Database
environment.
Data Independence: The ability to modify a schema definition in one level without affecting a
schema definition in the next higher level is called Data Independence. It is independence
between the programs and the data.

IMPORTANCE:
Data independence plays crucial role in database environment.
 Improve performance.
 Change in data structure does not require change in application program.
 Hide implementation details from the users.
 Allow users to concentrate on the general structure, rather than on low-level
implementation details.
 Standards can be enforced.
 Security can be improved.
 Integrity can be improved.
 Better service to the users.
 Cost of developing and maintaining systems is lower.
 Flexibility in system improvement.
 Inconsistencies can be reduced.
 In essence, Integrity, consistency, security and availability can be ensured.

91) Differentiate between the following terms:


a. Bit and byte
b. Pseudocode and flowchart
c. Constant and variable
ANSWER:

a. Bit refers to the smallest unit of computer memory that has ability to store a maximum of two
different values while byte composed of 8bits can hold 256 different values.
b. A pseudocode is standard method of describing an algorithm without use any specific
programming language while a flowchart is symbolic representation of step by- step solution to a
given problem.
c. A variable can be defined as a name also known as identifier that represents data values which
can change while a constant is a fixed value which cannot be changed.

92) Give and explain the main components of an Operating System.

ANSWER:

Components of the operating system: Kernel, Shell, file system and System resources
a)Kernel

The kernel is the central component of most computer operating system. Its responsibilities
include managing the system’s resources (the communication between hardware and software
components). It is the part of the Operating system which is in charge of the basics functions of

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 28


the Operating System such as Management of memory, Management of Peripherals, and so on. It
is the heart of an OS.

b)Shell

Shell is a program that sits on the computer as interface between users and kernel. This part of
the Operating System is in charge of controlling all interpreted commands on the computer.

c)File System

File system is a way of an Operating System used to handle its file and folder and differentiate
one file to another according to their extensions. File management (rm, cat, ls, rmdir, mkdir); or
file system is used to store and organize data on computer. This part is in charge of file
management, manipulation and access.

d)System resources
The operating system supervises the use of scarce system resources. Scarce because every
application on the computer competes to use these resources.

93) Is it possible to log on more than 1 user using one computer simultaneously? Explain your
answer.

ANSWER:

Yes, because any windows computer has the feature of switching users so that you can switch
more users simultaneously. OR in other words, you can log off one user and log in another user.

94) Give 4 expansion cards available in the computer.

ANSWER:

Four expansions cards are:

 Graphics card or Video card


 Network Interface Card (NIC)
 TV cards
 Sound Card
 Modem Adapter
 RAID adapter

95) What is int, float and char?

ANSWER:

Int: specifies the integer (positive and negative natural) numbers. A number that has no digits
after the decimal point.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 29


Float: is a floating-point number, which is a number that can have digits after the decimal point.

Char: declares or specifies a single character. It is a data type that is intended for holding
characters, as in alphanumeric strings.

96) Explain 3 Data Manipulation Language statements.

ANSWER:

A data manipulation language (DML) is a computer programming language used for adding
(inserting), deleting, and modifying (updating) data in a database.

Select: is used to retrieve the data in database. It is used to select data from a database.

Insert: is used to enter data in database. It is used to add new rows of data into a table in the
database.

Update: is used to modify a kind of data in database.

Delete: is used to erase/ delete some data or Rows in database. It is used to delete the existing
records from a table.

97) a)What is a protocol?

ANSWER:

It is a set of rules that governing communication between computers in the network. Protocol is a
set of rules that governs data communication.

b) Give 5 main functions of the protocols.

ANSWER:

Main functions of the protocols:

 Identifying errors
 Compressing data
 Deciding how data will be sent
 Addressing data
 Deciding how to announce sent and received data
 Network protocols enable computers to exchange data with each other in a meaningful,
organized and efficient way.
 They provide the path to increase the network connections
 They enhance the data transmission rate
 Provide easy working to users
 They enhance the speed of the connection
98) Describe the friend function

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 30


ANSWER:

Friend Function is a function that is given the same access as methods to private and protected
data.

A friend function of a class is defined outside that class’s cope but it has the right to access all
private and protected members of the class. Even though the prototypes for friend functions
appear in the class definition, friends are not member functions.

To declare a function as a friend of a class, precede the function prototype in the class definition
with keyword Friend.

99) Convert the following in Decimal number.

ANSWER:

(a)(1237)8 = (1*83) + (2*82) + (3*81) + (7*80)

=512+128+24+7=67110

(b)(10101)2 = (1*24) + (0*23) + (1*22) + (0*21) + (1*20)

=16+0+4+0+1=2110

100) what is a computer program?

ANSWER:

A computer program is an organized list of instructions that, when executed causes the computer
to behave in a predetermined manner.

101) What is computer programming?

ANSWER:

Programming means designing or creates a set of instructions to ask the computer to carry out
certain jobs which normally are very much faster than human being can do.

102) a) Explain the term stored procedure.

ANSWER:

Stored Procedures are groups/ set of instructions that run in the database server and can be
called with a single SQL statement.

b) Briefly explain the advantages of using stored procedures.

ANSWER:

Advantages of using stored procedures:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 31


 They are useful in situation where the processing should be on the server side rather than
 Also, since the procedures are centralized to the server, code writing and maintenance is
simplified, because the client programs do not have to duplicate the application logic.
 Stored procedures can also be used to reduce network communication. The results of
stored procedures can be analyzed and kept on the database server.
 Data validation is the process of ensuring that a program operates on clean, correct and
useful data.
 Access Control: is any mechanism by which a system grants or revokes the rights to
access same data, or perform some action.
 Consolidate logic
 Overhead

103) what will be the output of the following code?

#include<iostream>

#define max 10+2

int main (){

int i;

i=max * max;

cout<< i;

return 0;}

ANSWER:

Output: 32

i=max * max

i=10+2*10+2

i=10+20+2

104) In the table below give and explain with examples the 6 Arithmetic Operators of Visual
Basics

ANSWER:

Operator Meaning in words Example (Arithmetic Expression)


+ Addition 5+5=10
- Subtraction 10-5=5
/ division 25/5=5
* Multiplication 4*5=20
Mod Modulus(returns the remainder) 20 mod 6=2 ; 255mod 10 =5

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 32


^ Exponent(Power of) 3^3=27

105) a) What is Visual Basic?

ANSWER:

Visual Basic is a high level programming language evolved from the earlier DOS version called
BASIC. BASIC means Beginner’s All-purpose Symbolic Instruction Code.

OR

Visual Basic is a programming language that allows you to create your own software with the
look of window programs that you are familiar with.

b) How is VB program made up?

ANSWER:

A Visual Basic program is made up of many subprograms each has its own program codes, and
each can be executed independently and at the same time each can be linked together in one way
or another.

OR

There are three parts for creating VB application:

 Design the user interface: When you plan the user interface we draw a sketch of the
screen that user will see when running our project.
 Plan the properties: For each object write down the properties that you plan to set or
change during the design of the form.
 Plan the basic code: This step is where you plan procedures that will execute when our
project runs. We will determine which events require action to be taken and then make a step by
step plan for those actions.

106) What are the responsibilities of a DBA (Database Administrator)?

ANSWER:

The Database Administrator is responsible for:

 Designing the logical and physical schemas, as well as widely used portion of the
external schemas.
 Security and authorization
 Data availability and recovery from failures

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 33


 Database tuning: The DBA is responsible for evolving the schemas, to ensure adequate
performance as user requirements change.

OR

The database administrator responsible for:

 Configuration
 Upgrade
 Administration
 Monitoring and
 Maintenance of database in an organization.

107) Define the following terms:


a)Data
ANSWER:

Data refers to a collection of text, numbers and symbols, images with no meaning.

b)Information

ANSWER:

Information is the result of processing data, usually by computer. Information is data that has
meaning.

c) Database

ANSWER:

Database is an organized collection of related data. A database is a collection of one or more


relations, where each relation is a table made of rows and columns.

108) a) What is a node?

ANSWER:

Node is any device that has its own network card and is connected to a computer network. OR

A node is a computer or any other device that is directly connected to a computer network. Some
examples of nodes are: Printers, routers, switches, servers, and computers.

b) Which network topology uses terminators?

ANSWER:

It is Bus topology. It uses terminators to absorb the signals at the end of the cable.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 34


109) Explain term DBMS (Database Management system) and give four examples of DBMS
software.

ANSWER:

Database Management system (DBMS) is referred to as a software system that is used to store,
access, manage, organize, maintain, modify and delete data from databases.

Examples: Microsoft Access, Oracle, Microsoft SQL Server, MySQL, SQL Server

110) a) What is the Encapsulation in networking?

ANSWER:

Encapsulation is the process of packing data for transportation.

b) What is a peripheral?

ANSWER:

A peripheral is a device or hardware that is added to a computer to add additional functionality


or to improve existing functionality.

c) What does an access method describe?

ANSWER:

An access method describes how a computer transmits data in the network.

111) Explain three database system users.

ANSWER:
When considering users of a Database system, there are three broad classes to consider:

1. The database administrator (DBA): Responsible for authorizing access to the database, for
coordinating and monitoring its use, acquiring software and hardware resources, controlling its
use and monitoring efficiency of operations.

2. The database designer: Responsible to define the content, the structure, the constraints, and
functions or transactions against the database. They must communicate with the end-users and
understand their needs.

3. The End-users: They use the data for queries, reports and some of them update the database
content.

112) Which topology is used in modern LAN networks?

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 35


ANSWER:

Star topology

113) a) What is meant by Data Independence?


ANSWER:

Data Independence: The ability to modify a scheme definition in one level without affecting a
scheme definition in a higher level.

b) Differentiate between Logical data independence and Physical data independence.


ANSWER:

Logical data independence refers the ability to modify the conceptual scheme without causing
application programs to be rewritten.

Physical data independence refers the ability to modify the internal scheme without having to
change the conceptual or external schemas. Modifications at this level are usually to improve
performance.

114) a) What is the use of a switch in a computer network?

ANSWER:

In a computer network, a switch is used to connect multiple computers. For example, an 8 ports'
switch allows us to connect 8 computers in a single network.

b) Why do we do the networking?

ANSWER:

We do the networking to share the information, resources, and applications.

c) Define what IP address is.

ANSWER:
It is the unique number which identifies any electronic device on a network. OR
An IP address is an address used in order to uniquely identify a device on a computer network.
Also,
An IP address can be defined as the numeric identity of a node in the network.

d) What do you understand by transmission medium?

ANSWER:
Transmission media is a pathway that carries the data or information from sender to receiver.

e) Explain the difference between static and dynamic IP addresses?

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 36


ANSWER:

A Static IP address is assigned manually. Once assigned it does not change unless it is changed
manually again. While,

A Dynamic IP address is assigned by a service usually DHCP. It can change at any time.

Static IP addresses Dynamic IP addresses

They don’t change They change

They are more flexible They are not flexible


They are usually assigned to servers They are usually assigned to clients
They are manually assigned by network They are dynamically assigned by DHCP
administrator server.

They are expensive than dynamic IP They are Cheaper than static IP addresses
addresses

115) Explain why the MS Access is used as database application software.

ANSWER:

The MS Access is used as database application software because it is a relational database


model. The user can create table, query, form, reports, and macro.

 User can create relationship between tables.


 Sharing data (sharing data) between users.
 User can store data without redundancy.
 Data security.
 Compilation or Centralization administration.
116) Explain the advantages of using database management system than a file system of an end
user?

ANSWER:

The DBMS (Database Management System) is preferred ever the conventional file processing
system due to the following advantages:

 Controlling Data Redundancy


 Elimination of Inconsistency
 Better service to the users because data are shared.
 Flexibility of the system is improved.
 Integrity can be improved
 Standards can be enforced

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 37


 Security can be improved
 Organization’s requirement can be identified.
 Cost of developing and maintaining systems is lower
 Provides backup and recovery.
117) Explain the following terms briefly:

a)Attribute,

ANSWER:

Attribute is a property or description of an entity. A toy department employee entity could have
attributes describing the employee’s name, salary, and years of service.

b)Entity,

ANSWER:

Entity is an object in the real world that is distinguishable from other objects

c) Relationship,

ANSWER:

Relationship refers to an association among two or more entities.

d) Relationship Set

ANSWER:

Relationship set refers to a collection of similar relationships.

e) One-to-many relationship,

ANSWER:

One-to-many relationship is a key constraint that indicates that one entity can be associated
with many of another entity. An example of a one-to-many relationship is when an employee can
work for only one department, and a department can have many employees.

f) Many-to-many relationship,

ANSWER:

Many-to-many relationship is key constraint that indicates that many of one entity can be
associated with many of another entity. An example of a many to many relationship is employees
and their: a person can have many different hobbies, and many people can have the same hobby.

g)Participation Constraint,

ANSWER:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 38


Participation Constraint determines whether relationships must involve certain entities. An
example is if every department entity has a manager entity. Participation constraints can either be
total or partial. A total participation constraint says that every department has a manager. A
partial participation constraint says that every employee does not have to be a manager.

h) Weak entity set

ANSWER:

Weak entity set is an entity that cannot be identified uniquely without considering some primary
key attributes of another identifying owner entity. An example is including dependent
information for employees for insurance purposes.

i) Aggregation,

ANSWER:

Aggregation is a feature of the entity relationship model that allows a relationship set to
participate in another relationship set. This is indicated on an ER Diagram by drawing a dashed
box around the aggregation.

k) Role indicator.

ANSWER:

Role indicator: if an entity set plays more than one role, role indicators describe the different
purpose in the relationship. An example is a single employee entity set with a relation reports to
that relates supervisors and subordinates.

118) Rewrite the following if-else segment using switch-case statement.

Char ch=’A’;

If(ch==’A’)

System.out.println(“Account”);

If((ch==’C’) || (ch==’G’))

System.out.println(“Admin”);

If(ch==’F’)

System.out.println(“Advisor”);

ANSWER:

Char ch =’A’
Switch (ch){

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 39


Case’A’:
System.out.println(“Account”)
Break;
Case’C’:
System.out.println(“Admin”)
Break;
Case’G’:
System.out.println(“Admin”)
Break;
default:
System.out.println(“Advisor”)}

119) What is meant by case sensitive? Is Java case sensitive?

ANSWER:

Case sensitive means that variable name declared in lower case is different with variable
declared in upper case letter. Therefore, Java is case sensitive.

120) List any 3 objectives of a website.

ANSWER:

The objectives of the website:

 To be known all over the world


 Communication to many people
 Advertisement purpose
 Buying and Selling Online
 Marketing purpose
121) Give the syntax of declaring a structure.

ANSWER:

The syntax of declaring a structure is:

Struct<Structure name>{

Structure element 1;

Structure element 2;

Structure element 3;

} Object names;

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 40


122) List the basic operations carried out in a linked list.

ANSWER:

Basic operations of linked list are:

 Add(insert) and delete (remove).


 Creation of a list
 Insertion of a node
 Deletion of a node
 Modification of node
 Traversal of the list

123) What are the four functions of an operating system?

ANSWER:

Functions of Operating System are:

 Memory Management
 Processor Management
 Device management
 File Management
 Security
 Control over system performance
 Job accounting
 Error detecting aids
 Coordination between other software and users
 I/O devices management
 Authorization management
 Communication management
 Applications program management
124) What are the hardware devices used for computer graphics?

ANSWER:

Hardware devices used in computer graphics are:

Digital cameras, Scanner, Printer, Smartphones, Selfie Sticker, Monitor, flash disk, etc

125) Enumerate Advantages of Object Oriented Programming.


ANSWER:

 Code Reuse and Recycling: Objects created for Object Oriented

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 41


 Programming can easily be reused in other programs.
 Data Redundancy: Inheritance is the good feature for data redundancy.
 Data hiding: Implementation details are hidden from other modules and
 Other modules have a clearly defined interface.
 Design Benefits: Large programs are very difficult to write.
 Software Maintenance: An Object Oriented Program is much easier to modify and
maintain than a non-Object Oriented Program.

126) Distinguish the different families of computers.

ANSWER:

There are 4 families of computers:

 Personnel Computer
 Mini Computer
 Mainframe Computer
 Super Computer

127) State five differences between DOS and Linux.

ANSWER:

MS DOS Linux
MS DOS is a 16 bit Operating System with Linux is a 32-bit and 64-bit Operating System
software available utilize 32-bit features
MS DOS only has buit-in support for single Linux was designed from the ground up for
tasking multitasking.
MS DOS only supports one user. Linux supports multiple users
MS DOS is closed -source Linux is Open-source, available under the
terms of the GPL
MS DOS is tied to the 80X 86 platforms Linux can run on multiple achitectures.
128) List four different types of Web Browsers

ANSWER:

 Internet Explorer
 Mozila Firefox
 Safari
 Opera
 Google chrome
 Netscape Navigator/ Netscape

129) a) Convert 1011.1012 to decimal.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 42


ANSWER:

=(1*23)+(0*22)+(1*21)+(1*20)+(1*2-1)+(0*2-2)+(1*2-3)

b) Convert 18310 to binary.

ANSWER:

Note that the power of 2 are:

1 , 2, 4, 8, 16, 32, 64, 128, 256, 512.

Now write 183 using just these powers:

Thus 183= 128 + 55

=128+32+23

=128+32+16+7

=128+32+16+4+2+1

130) Explain the DOS commands below:

FDISK:

FORMAT:

ATTRIB:

SYS:

CHKDSK:

TREE:

ANSWER:

DOS Meaning
FDISK FDISK is the DOS utility to low level format/partition your hard drive
FORMAT FORMAT is used for Formatting a disk for use with Windows.
ATTRIB ATTRIB is used for Displaying or changing file or directory attributes.
SYS This command is used to make a boot disk
CHKDSK Is used to Check a disk and display a status report.
TREE Graphically displays the directory structure of a drive or
path.

131) What is an algorithm and how are algorithms essential?

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 43


ANSWER:

a) Algorithm is a step-by-step procedure, which defines a set of instructions to be executed in a


certain order to get the desired output.

Algorithm refers to a step-by-step procedure that specifies how to perform a task or solve a
problem.

b) Algorithms are essential to the way computers process information, because a computer
program is essentially an algorithm that tells the computer what specific steps to perform (in
what specific order) in order to carry out a specified task.

132) What does e-commerce mean?

ANSWER:

Electronic Commerce (E-Commerce) consists primarily of the distributing, buying, selling,


marking and servicing of products or services over electronic systems such as the Internet and
other computer networks

133) What is a browser?

ANSWER:

Browse (Web browse) is program used for displaying and viewing web pages on the World
Wide Web (WWW), for example, Mosaic, Netscape Navigator, Internet Explorer, Mozilla
Firefox, Opera and Google Chrome amongst others. The web pages can be accessed using a web
browser.

134) Explain the advantages of using database management system than a file system of an end
user?

ANSWER:

The DBMS (Database Management System) is preferred ever the conventional file processing
system due to the following advantages:

 Controlling Data Redundancy


 Elimination of Inconsistency
 Better service to the users because data are shared.
 Flexibility of the system is improved.
 Integrity can be improved
 Standards can be enforced

 Security can be improved


 Organization’s requirement can be identified.
 Cost of developing and maintaining systems is lower

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 44


 Provides backup and recovery.

135) What is Computer Programming?

ANSWER:

Computer programming is a systematic process of writing a computer program using


programming languages. Or
Computer programming is the act of writing computer programs, using a Computer
Programming Language to perform a specified task by the computer. computer programming is
also called program coding.
136) What are the uses of a computer?

ANSWER:

 A computer is an important tool for keeping databases, filing systems, track records
 It helps an organization save tons of times. It has made data analysis extremely easy, and
it can be done at a single click of the mouse.
 Computers also serve as useful tools for communications. Normal post is now commonly
referred to as e mail, as the must fast email has replaced it.
 Computer is important because it makes our tasks easier to do and it helps us search
different things that we need to know instantly and automatically through world wide
connectivity.

137) Define the term Client-Server?

ANSWER:

The term Client-Server can be defined as architecture that can distribute the processing of an
application between a front-end workstation component and a back-end server component.

138) Define “front-ends” and explain why they are called so.

ANSWER:

The front-end can be defined as an application that can be used to view and manipulate the data
in the back-end. The back-end is a set of related database tables. This system is introduced to
simplify the complexity of database based applications in the windows environment.

139) Which is the correct hierarchy of data from the smallest to the largest is :

(a) Bits --->Characters ---> fields --->records ---> files

(b) Characters ---> records ---> fields ---> files --->Database

(c) Database--->files ---> fields --->records ---> characters

(d) Fields--->files ---> records --->Characters ---> database

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 45


ANSWER:

(a) Bits --->Characters ---> fields --->records ---> files

140)How many Flash disks of 4GB can be found in Hard disk of 1TB?
ANSWER:

Number of flash disks=1TB


=1024GB / 4GB
=256flash disks

141) Give two importance of computer power supply.

ANSWER:

 Converts alternating current (AC) from mains to direct current (DC) required by internal
computer components
 Supplies current to the internal component

142)What are the two examples of electronic devices connected to VGA Port.

ANSWER:

 Projector
 Monitor

143)A School needs to store information about Teacher (identified by TeacherId, FirstName,
Surname, Salary, Qualification, Address, Contact); Combination (identified by CombinationId,
CombinationName),Student (identified by StudentId, FirstName, Surname, Address, Schoolfees,
ContactNumber) and Subject (identified by subjectId, SubjectTitle). Describe the logical
relationships between objects Teacher-Student, Teacher-Combination, Student-Combination and
Teacher-Subject?

ANSWER
 Teacher-Student= Teacher teaches Student
 One to many relationship
 Teacher-Subject= Subject is taught by Teacher
 One to many relationship
 Teacher-Combination=Teacher teaches in Combination
 One to many relationship
 Student-Combination=Students belongs to combination Many to one relationship

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 46


144) a) What do you understand by transmission medium?
ANSWER:

Transmission media is a pathway that carries the data or information from sender to receiver.

b) Discuss various transmission medium used in computer network.


ANSWER:

Transmission media is broadly classified into two groups:


 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.

145) Read the following statements that describe the OSI layers and write the name of layer
correspond to each statement:
a. To organize bits into frames; to provide hop-to-hop delivery
b. This layer is responsible for end-to-end delivery between hosts.
c. To establish, manage and terminate sessions.
d. To translate, encrypt and compress data
e. To move packets from source to destination to provide internetworking.
f. To allow access to network users
g. To transmit bits over a medium; to provide mechanical and electrical specifications.

ANSWER:
a. Data link: To organize bits into frames; to provide hop-to-hop delivery
b. Transport: This layer is responsible for end-to-end delivery between hosts.
c. Session: To establish, manage and terminate sessions.
d. Presentation: To translate, encrypt and compress data
e. Network: To move packets from source to destination to provide internetworking.
f. Application: To allow access to network users
g. Physical: To transmit bits over a medium; to provide mechanical and electrical specifications

146) a) Which of the following cables can be used to have the connection?
i. VGA (Video Graphic Array) cable;
ii. Network cable;
iii. AC Power cable.

b) Describe the role of the remaining cables.


ANSWER:
a) If you want to connect your laptop computer to internet use Network cable.
b) VGA (Video Graphic Array) cable is used to connect laptop computer to another display
device.
AC Power cable is used to connect your laptop to the electrical outlet

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 47


147) What is Front end?

ANSWER:
The term Front End refers to the user interface, where the user interacts with the program
through the use of the screen forms and reports.

148) a) What do you understand by an array?

ANSWER:
An array is a collection of data items, all of the same type, accessed using a common name.

b) Explain how to access Array Data?


ANSWER:
Data in an array can be accessed by referring to the name of the array and the element’s index
number.

149) a) Why is it necessary to login to computer with a password?


ANSWER:
It is important to login to computer with password because the computer must be used with
someone who knows the password. This means that the computer is used by appropriate users.
b) What is the purpose of creating deferent computer users?

ANSWER:

The purpose of creating different computer users is to give different user permissions or access
to different computer resources.

150) Explain the following terms:


a)Thread
b)Process
c) Process control block
d) Deadlock
e) Process scheduling

ANSWER:

a) Thread is the smallest unit of processing that can be performed in an Operating System. A
thread is also called a lightweight process. Threads provide a way to improve application
performance through parallelism
b) A process is a program in execution. It is an instance of program execution and it is not as
same as program code but a lot more than it.
c) Process control block is a data structure maintained by the Operating System for every
process. It is also called Task Control Block and it is storage for information about processes.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 48


d) Deadlock is a situation where a process or a set of processes are blocked, waiting for some
resource that is held by some other waiting processes.
e) Process scheduling refers to the order in which the resources are allocated to different
processes to be executed. Process scheduling is done by the process manager by removing
running processes from the CPU and selects another process on the basis of a particular strategy

151) Describe the simple measures that can be taken to protect data in the school computer lab.

ANSWER:
 Installing anti-virus in all computers
 Protect all computers with password
 Install Firewall.
 Install Antivirus Software.
 Install Anti-Spyware Software.
 Use Complex and Secure Passwords.
 Check on the Security Settings of the Browser.

152) Declare both one dimensional and two dimensional arrays which can keep 100 in VB.
ANSWER:

One dimensional array:


Dim IdentStudent(100) as Double

Two dimensional array:

Dim IdentStudent(10,10) as Double

153) a) By using simple words, define computer security?

b) Write briefly on importance of computer security at your school, in Rwanda and in the
whole world.

ANSWER:

a. Computer security refers to techniques developed to safeguard information and systems


stored on computers.

b. Computer security is important in the following ways:


Computer security helps to keep safely data and equipment functioning and provide
access only to appropriate people.
Computer security is important, because of keeping information protected. It’s also
important for the computer’s overall health, helping to prevent viruses and malware and helping
programs run more smoothly.
Computer and data stored can be protected from potential outside problems.
Computer security is important for helping programs to run more smoothly
Computer security is important for preventing theft of data, software, services and
equipment

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 49


154) Fill in the blanks with the appropriate device between hub, switch and router.

ANSWER:

Description Device
This device sends and receives information Router
about the Network layer.
This device uses hardware addresses to filter a Bridge or Switch
network.
This device can measure the distance to a re- Router
mote network.

155) a) How to recognize that a document in a computer is infected by virus?

ANSWER:
You can know that a new document is virus infected by its extension .exe or .com
b) Use an example; explain how virus damage can reduce the production of any institution.

ANSWER:
Example: If in a bank, some computers are attacked by virus and all computers work in same
network. This means if some documents are shared through different ways, other computers in
network can be affected, and this can cause the loss of important information.

156)In a bank, any customer can create and use an identity (e.g., a user name and password) to
log into that bank's online service but the bank's pol-icy must ensure that the user can only access
to his/her individual ac-count online once his/her identity is verified.
a) Identify which type of security is used in this bank?

ANSWER:
The type of security used here is authorization

b) Why is it important?

ANSWER:

It is important because authorization give someone permission to do or have something. In this


example, if your identity is not verified you can’t access to bank account, this means no one else
can’t access to your account without your permission.

c) What is the difference between anti-virus and anti-spyware?

ANSWER:
Antivirus software are computer programs that attempt to identify, neutralize or eliminate virus
while Anti-spyware is a type of program designed to prevent and detect unwanted spyware
program installations and to remove those programs if installed

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 50


157) List three Objectives of Process Scheduling Algorithms.

ANSWER:
 Maximization of CPU utilization by keeping the CPU as busy as possible.
 Fair allocation of CPU to the processes.
 To maximize the number of processes that completes their execution per time unit. This
is
 Called throughput.
 To minimize the time taken by a process to finish its execution.
 To minimize the time a process waits in ready queue.
 To minimize the time it takes from when a request is submitted until the first response is
 Produced.

158) a)What is a computer attack?

b) Differentiate active attack to passive attack.

ANSWER:

A computer attack is any attempt to expose, alter, disable, destroy, steal or gain unauthorized
access to or make unauthorized use of an asset.

An active attack attempts to alter system resources or affect their operation while a
passive attack attempts to learn or make use of information from the system but does not
affect system resources

159) How a user can protect physical equipment of a computer.

ANSWER:

use physical equipment against fire


use metallic doors and windows against theft
use security camera, security guard and alarms to detect theft
use UPS to protect system failure and data loos due to the power failure

160) Explain the difference between social engineering and Shoulder Surfing techniques.

ANSWER:

In computer security, shoulder surfing is a type of social engineer who obtain information such
as personal identification number, password and other confidential data by looking over the
owner of information while as Social Engineering is a technique/ method used by someone by
trying to socialize with someone else with the purpose of picking/getting his/her credentials or
user name and password with intention to use them during his/her absence.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 51


161) What is the major difference between process and program?

ANSWER:

The major difference between a program and a process is that a program is a set of instructions
to perform a designated task whereas the process is a program in execution.
A program is in the secondary storage. A process is loaded into the main memory.
A program consists of a set of instructions in a programming.

162) Give 3 examples of an audio port that connects audio devices to the computer.

ANSWER:
Line in, Microphone, Line out, Game port/MIDI

OR

Green port, Pink port, Blue port

OR

Speaker port(Headphone/ air phone), Microphone port, Auxiliary input port

163) List the 3 motherboard form factors.

ANSWER:
 AT Advanced Technology (old model)
 ATX Advanced Technology Extended (most popular type of computer case used today)
 BTX Balanced Technology Extended (newest form factor known as cooling case)
 SFF Small Form Factor
 ITX Type of case found on a lot of mini and microcomputer.

164) Tick in the cell where the device matches with the device type as shown below:

ANSWER:

No DEVICES INPUT DEVICES OUTPUT STORAGE


DEVICES DEVICES
1 Touchpads 
2 Light Pen 
3 Scanner 
4 Electronic Whiteboard  
5 RAID 
6 Speaker(s) 
7 Monitor 

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 52


8 PC Card 

165) Write an algorithm that asks the user to enter two numbers and it displays the product of
those numbers if it is null, negative or positive.
ANSWER:
Var a:integer
Var:integer
Start
Write(“Enter The First Number”)
Read(a)
Write(“Enter The Second Number”)
Read(b)
If(a < 0 and b > 0)
Write(“The Product is Negative”)
Else If (a< 0 and b=0)
Write(“The Product is Null”)
Else If (a< 0 and b < 0)
Write(“The Product is Positive”)
Else If (a > 0 and b > 0)
Write(“The Product is Positive”)
Else If (a = 0 and b = 0)
Write(“The Product is Null”)
End if end
OR
Var: a, b, product as integer
Write(“ Enter Two Numbers”)
Read(a,b)
Product ← a*b
If(Product > 0) then
Write(“The Product is Positive”)
Else if (Product < 0) then
Write(“The Product is Negative”)
Else
Write(“The Product is Null”)
End if
End
166) What is a loop?

ANSWER:
A loop helps to repeat instruction or block of instructions. It assists in the algorithm where you
want you want to carry out an activity for a certain number of times until a given condition is
satisfied or become false.

167) Write an algorithm which uses do….. while loop and displays numbers from 1 to 5.

ANSWER:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 53


Var: x as integer
Start
x←1
do
write(x)
x←x+1
while(x <= 5)
end

168) Distinguish Seek Time from Data rate.

ANSWER:
The Data Rate is the number of bytes per second that the drive can deliver to the CPU. Rates
between 5 and 40 megabytes per second are common.

The Seek Time is the amount of time between when the CPU requests a file and when the first
byte of the file is sent to the CPU. Times between 10 and 20 milliseconds are common.

169) Study the program below and answer the questions that follow:

#include<stdio.h>

Int g=20;

Int main ()

{int g = 10;

Printf(“Value of g=%d\n”, g); return 0;}

(a)What is the ouput?

(b)Explain why that output.

ANSWER:
The output is 10

The local variable inside a function take preference.

170) (a)What is data structure?

(b)Show with examples how the data structures are declared.

ANSWER:
a)A data structure is a group of data elements grouped together under one name.

b)Examples

Struct product{

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 54


Int weight;
Float price;
};in
Product apple;
Product banana, melon;
OR
Struct product{
Int weight;
Float price;
}apple, banana, melon;

171) Which of the following is not derived data type in C?

(a)Function (b) Pointer (c) Enumeration

(d)Array (e) All are data type

ANSWER:
(c) Enumeration

172) Which of the following is an integral data type?

(a)Void (b) Char (c) Float (d) Double (e) None of these

ANSWER:
(b) Char

173) Explain the importance of:

(a)Plug and Play System (b) Shell

ANSWER:
a)In a plug and play system, a device manager first performs a scan on different hardware
buses, such as Peripheral Component Interconnect (PCI) or Universal Serial Bus(USB), to detect
installed devices, then searches for the appropriate drivers.

b)Shell is a piece of software that provides an interface for users of an Operating System which
provides access to the services of a kernel.

174) What is a Protocol?

ANSWER:

A Protocol is a set of rules that governs the communications between computers on a network.
In order for two computers can talk to each other, they must be speaking the same language.

175) Describe 4 advantages of using relations database system in tables.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 55


ANSWER:
 Relational databases bring tables together.
 Structured Query Language is easy to understand
 Security of data
 Sharing data
 No duplicate data

176) How is the memory in multi-process system managed?

ANSWER:
The memory management is managed according to three schemes namely: Fixed partition
Memory, variable partition memory, and variable partition allocation with compaction.

177) Describe the Trash can icon in the Linux.

ANSWER:
The Trash can icon on the desktop contains files and folders which you have deleted using the
file manager or an application run from the desktop. It is a special folder in which it is still
possible to move back the deleted items to another folder so as to undelete them.

178) Multiply (1000.10)2 by (10.1)

ANSWER:
1000.10 * 10.1= 10101.010

179) Items of tool box are used to design the application interface. These items are called
Controls, Name each control.

ANSWER:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 56


180) Differentiate logical to physical independence in database.

ANSWER:
Logical data independence refers to the ability to modify the conceptual scheme without
causing application programs to be rewritten. While
Physical data independence refers to the ability to modify the internal scheme without having
to change the conceptual or external schemas. Modifications at this level are usually to improve
performance.
181) What is the output for the following codes?
#include<iostream>
using namespace std;
int main(){
int c=0;
while(c < 5){
c++;
cout<<c;}
return 0;}

ANSWER: 1,2,3,4,5

182) Define the following terms:

a)Primary key
b)Data Structure
c)Database Normalization
d)Ping
ANSWER:
a) Primary key: is candidate key which composed of the minimum number of fields to ensure
the occurrences are unique.
b) Data Structure: is a collection of variables of different data types under a single name.
c) Database Normalization: is a database design technique that reduces data redundancy and
eliminates undesirable characteristics like Insertion, Update and Deletion Anomalies.
d) Ping: is commonly used to test connections between computers.

183) Differentiate GUI (Graphical User Interface) from CLI (Command Line Interface).

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 57


Answer: CLI GUI
CLI is difficult to use Whereas it is easy to use

It consumes low memory While consumes more memory


CLI is faster than GUI The speed of GUI is slower than CLI
CLI operating system needs only keyboard While GUI operating system need both
mouse and keyboard

In CLI, input is entered only at command While in GUI, input can be entered
prompt anywhere on the screen
In CLI, the information is shown or While in GUI, the information is
presented to the user in plain text and files shown or presented to the user in any
form such as: plain text, videos,
images, etc
In CLI, there are no menus provided While in GUI, menus are provided.
There are no graphics in CLI. While in GUI, graphics are used.
CLI do not use any pointing devices. While it uses pointing devices for
selecting and choosing items.

184) Differentiate read () and write () function used in algorithm development. (3marks)

ANSWER:
Read function (Inputs)
 A read function is a function which is used for inputs.
 It helps to receive the value entered by a user and assign it to a variable.
Syntax of read function:
Read ()

Write function (outputs)


 Write function is used for Inputs; it displays the content of a variable of displays
messages.
Syntax of write function:
Write ()

185) What are the responsibilities of DBA(Database Administrator)?


ANSWER:

DBA is :
✓ Responsible for authorizing access to the database
✓ Responsible for coordinating and monitoring its use
✓ Responsible for acquiring software and hardware resources,
✓ Controlling its use and monitoring efficiency of operations.

186) Explain why it is not advisable to eat or drink in a computer lab.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 58


The food / drink may pour into sensitive computer parts causing clogging or rusting.

187) Discuss Characteristics of Random Access Memory (RAM).


ANSWER:
1. Data can be read (retrieved) and written (stored) in it.
2. RAM is a temporary (volatile) storage because its content disappears when the computer is
switched off.

3. Its content is user defined i.e. the user dictates what is to be contained in the RAM.

188) Differentiate between the Servers and workstations.


ANSWER:

Server provides services to other computers on the network; Workstation used by the user, has
limited processing power and requests services from the server.

189) Which of the following is designed to control the operations of a computer? Explain it.

a) Application Software
b) System Software
c) Utility Software
d) User
ANSWER:
b) System Software
Explanation:
System Software is basically classified into two: System and application. System Software is
designed to control the operations and extend the processing capability of a computer system.

190)State four factors you would consider before installing computer software whether an
operating system or application software.
ANSWER:
 Memory (RAM) capacity.
 Free hard disk space.
 Processor type and speed.
 Graphics display.
191) Convert 101102 into a decimal number.
ANSWER:

The decimal equivalent number is given as:


1 × 24 + 0 × 23 + 1 × 22 + 1 × 21 + 0 × 20
= 16 + 0 + 4 + 2 + 0
= 2210.

192)Write a C++ program to assign a value of 100.235 to a double variable and then convert it to
int.
ANSWER:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 59


#include <iostream>
using namespace std;
int main()
{
double x = 100.235;
cout << (int)x << endl;
return 0;
}

193) List five rules you would follow to write code using XHTML

ANSWER:

1. Write a DOCTYPE declaration at the start of the XHTML document.


2. All elements and attributes should be written in lower case e.g <body>.
3. Each opening tag must have an equivalent closing tag.
4. Nest all the tags properly.
5. Attribute values must be enclosed in quote marks e.g. <td rowspan = “3”>.
6. Elements such as <b> and <i> have been replaced by <strong> and <em> respectively.
194) Write a C++ program to print the value of the address of the pointer to a variable whose
value is input from user.

ANSWER:

#include<iostream>
using namespace std;

int main()
{
int x, *y;
cout << "Enter a number\n";
cin >> x;
y = &x;
cout << "Value of the address of pointer of "<< x << " is "<< &y<<"\n";
return 0;
}
195) List 10 components inside computer case.

ANSWER:
Motherboard
CPU/processor
RAM (random access memory)
Hard drive

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 60


Power supply unit
Expansion cards
Video card
Sound card
Network card
Fan

196) Write an algorithm which receive a width and height of a rectangle and display its area and
perimeter.
ANSWER:
var w,l as double
Start
Write(“enter a rectangle width”)
Read(w)
Write(“enter a rectangle height”)
Read(l)
Write(“the rectangle area is:”, w*l)
Write(“write the rectangle perimeter is:”, (w+l)*2)
end

OR
Var: width, height, perimeter, area as integer
Start
Write(“enter a rectangle width”)
Read(width)
Write(“enter a rectangle height”)
Read(height)
area = width*height
perimeter = (width+height)*2
Write(area)
Write(perimeter)
end

197) Explain major types of computer software, their uses, and examples.

ANSWER:

System Software: System software coordinates the activities and functions of hardware and
software, and it controls the operations of computer hardware and provides an environment or
platform for all the other types of software to work in. It is the most basic type of software in any
computer system, which is essential for other programs, applications and the whole computer
system to function.

System software examples: Microsoft Windows XP, Mac O S, Linux, Windows Vista, Ubuntu,
device drivers, etc.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 61


Application Software: Application software is what helps the user perform the tasks of his/her
choice. They are non-essential software which are installed and run, depending upon the
requirements, in the environment provided by the system software.

Application software examples: MS Office, OpenOffice, Media Players, MS Access,


educational software, media development software, Antivirus software, etc.
Programming Software: Programming software is used to write, test, debug and develop other
software programs and applications. The various programming language editors such as
Eclipse – a Java language editor – appear under this category. They are used for creating both the
system as well as application software.

Programming software examples: Turbo C, Xilinx, Kiel, compilers, debuggers, Integrated


Development Environment (IDE), etc.

198) Write pseudocode to compare three numbers X, Y and Z in algorithm.


ANSWER:
BEGIN
PRINT Enter x, y and z
READ x, y, z;
IF x< y Then
IF x<z = Then;
least = x
ELSE
least = z
ELSE IF y<z Then
least = y
ELSE
least = z
ENDIF
PRINT least
END

199)List any five internal components of a laptop

ANSWER:

Ram, Cpu, Motherboard, Wireless card, Fan, HDD

200) Define two dimensional arrays and give their syntax for declaring it.

ANSWER:

A two dimensional array is a collection of a fixed number of elements (components) of the


same data type arranged in columns and rows making two dimensions.

The syntax for declaring a two dimensional array is:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 62


Set array name= array [row size][column size] of data types.
201) Discuss the purpose of switching table in the switch?
ANSWER:

The switch makes a forwarding decision based on the destination host’s MAC address. The
switch essentially forwarded the frame from one port’s ingress queue to another Port’s egress
queue. To perform this forwarding decision, a switch consults its MAC address table.

202) Describer the 2 function of a modem


ANSWER:
The essential functions of a modem are:

 Modulate: an analog carrier signal to carry digital information, it means to convert the
analog signal to digital signal.
 Demodulate: a similar signal so as to decode the digital information from the analog
carrier signal and it means to convert the same signal back to the analog signal then
transmitted through telephone line.
203) What is the purpose of managing information?

ANSWER:

The purpose of management information systems, including decision support systems, is to


guide the decision-making process. Specifically, MIS combines people, computer hardware,
software and communication devices to collect, store and convert raw data into useful
information, which
subsequently is communicated to the right people precisely when needed.

204) Explain three database design levels


ANSWER:
 Conceptual level: this level describes the logical structure of whole database by using
different concepts like: Entity, occurrence, properties, cardinalities, relationships or
associations.
 Logical level: this describes how data are actually stored and how they can be accessed.
 Physical level: in this level there exist a number of views which is defined apart of actual
database by using the different DBMS.

205) By using a sketch, give type of Multiple Inheritance


ANSWER:
Multiple Inheritance

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 63


206) What the following controls prefix stand for? Chk, fil,cbo,frm,txt.

ANSWER:
 Chk: Check box
 Fil: File list box
 Cbo: combo box
 Frm: form
 Txt: text box.

207) What SQL command can be used to delete columns from a table?

A MODIFY TABLE TableName DROP COLUMN ColumnName


B MODIFY TABLE TableName DROP ColumnName
C ALTER TABLE TableName DROP COLUMN ColumnName
D ALTER TABLE TableName DROP ColumnName

ANSWER:

C. ALTER TABLE TableName DROP COLUMN ColumnName

208) Rewrite the following code using while loop:

inti,j;
for(i=1,j=2;i<=6;i++,j+=2)
System.out.println(i++);
System.out.println(“Finished!!!”);

ANSWER:
inti=1,j=2;
while(i<=6)
{System.out.println(i++);
i++;
j+=2;}
System.out.println(“Finished!!!”);

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 64


209) Explain the difference between the input device and output device
Input device is an electronic device used to enter data in the computer while output device is an
electronic device used to display information from the computer.

210) Write true or false for the following statements:


a) The basic requirements for working of a communication system are sender, medium and
receiver. False (Transmitter is missing)
b) In full duplex mode, both stations can transmit and receive signals at the same time True
c) Analog signal is measured in Volts and its frequency is in Hertz True
d) In the ring topology, all nodes are connected to a central device like router, hub, or switch.
False
e) Cross over cable is used to connect devices of different types. False
f) The technique by which a digital signal is converted to analog form is known as modulation
True

211) Briefly, explain the role of the following utilities


a) Disk cleanup
b) Disk defragmenter
c) Ccleaner

ANSWER:

a) Disk cleanup: this utility is used to clean the unnecessary files on the hard disk to save disk
space
b) Disk defragmenter: this utility is used to organize files (fragments) on your hard disk for
good performance of your computer
c) Ccleaner: It protects your privacy online and makes your computer faster and more secure.
Easy to use and fast download.

212) Name the ports indicated by letters from the picture bellow

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 65


ANSWER:
A: Microphone (port)
B: VGA (port)
D: USB (port)
C: HDMI (port)
E: Ethernet/RJ45 (port)
213) Explain three database system users.

ANSWER:
When considering users of a Database system, there are three broad classes to consider:
1. The database administrator (DBA): Responsible for authorizing access to the database, for
coordinating and monitoring its use, acquiring software and hardware resources, controlling its
use and monitoring efficiency of operations.
2. The database designer: Responsible to define the content, the structure, the constraints, and
functions or transactions against the database. They must communicate with the end-users and
understand their needs.
3. The End-users: They use the data for queries, reports and some of them update the database
content.

214) i) Convert the following decimal numbers into binary numbers

(a)10310

(b) 27010

ANSWER:

(a)10310 = (1100111)2

(b) 27010 =(100001110)2

ii) Convert the following binary numbers into decimal numbers.

(a)101112

(b) 11111112

ANSWER:

(a)101112 =(23)10

(b) 11111112 = (127)10

215) Name and explain the three main parts of a computer.

ANSWER:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 66


 System Unit: it is a box (container) which contains all internal components of the
computer.
 Input Peripherals (devices): Devices that are used to enter data and commands into the
computer.
 Output Peripherals (devices): devices that are used to send out the results.

216) Explain the following concepts:

ANSWER:

(a)Computer architecture: it is description of functional parts of a computer and their


interconnections.

(b)Computer Configuration: refers to the organization for assembling and functioning the
hardware installation of a computer.

(c)Computer System: refers the set of software and hardware necessary to facilitate the user to
manipulate a computer or it is a system able to receive (read data), process them and produce
useful information to the user or it is a system that allows exchanging information by using
computer.

217) Explain the following terms:

a) Active memory

b) Dead memory

c) Main memory

d) Permanent memory

ANSWER:

a) Active memory: it is read and write memory, it is volatile, working field of the processor, it is
a memory which stores data and instructions under processing.

b) Dead memory: it is a read only memory.

c) Main memory: it is active memory

d) Permanent memory: it is a non volatile memory.

218) What is the importance of an ALU of a CPU?

ANSWER:

 The Arithmetic and Logical Unit of the CPU performs arithmetic and logical operations
to perform calculations.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 67


219) Explain why the MS Access is used as database application software.

ANSWER:

The MS Access is used as database application software because it is a relational database


model. The user can create table, query, form, reports, and macro.

 User can create relationship between tables.


 Sharing data (sharing data) between users.
 User can store data without redundancy.
 Data security.
 Compilation or Centralization administration.

220) State four types of instruction of a computer program.

ANSWER:

 Input instructions
 Output instructions
 Processing instruction
 Declaration instruction
 Assignment instruction
 Control Instructions
 Base instruction
 Structure instruction

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 68


221) Give five elements which appear in a numerical expression of programming?

ANSWER:

Variable, constants, numerical output, braces, parenthesis, operands, brackets, operators.

222) What are the steps needed to solve a problem appearing in programming?

ANSWER:

The first method

 Classify programming needs


 Analyze the problem
 Design the problem
 Code the problem
 Test the problem
 Document and maintain the problem

The second method

 Identify and understand the problem.


 Split the problem into subprogram
 Design of program
 Coding
 Compiling and debugging problem.
 Execution or running program
 Testing program

223) Write down the used C++ logical Operators

ANSWER:

 AND (&&), OR (||) , NOT (!)

224) Identify the program parts in C++.

ANSWER:

 Header file name/ processor


 Function prototype / declaration function
 The main function
 Brackets/ beginning
 Body of program / statements instruction
 Function declaration.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 69


225) Give five examples of types of errors which can appear in Computer Program.

ANSWER:

 Compiler error
 Running time error
 Logical error
 Semantic error
 Syntax error
 Linking error
 Grammatical error / Lexical error

226) Distinguish between the following:


a)ROM from RAM
b)IDE/PATA from SATA

ANSWER:

a)ROM from RAM

ROM(read only memory) RAM(Random access memory)


-Is used to store programmed instructions and Data can be read (retrieved) and written
data permanently or semi-permanently. (stored) in it.
-Data and instructions stored in ROM are RAM is a temporary (volatile) storage because
those which remain unchanged for long its content disappears when the computer is
periods of time switched off.
-It is non volitile Its content is user defined i.e. the user dictates
what is to be contained in the RAM.

b)IDE/PATA from SATA

IDE /PATA( integrated Drive Electronics/ parallel SATA(serial advanced technology


advanced technology attachment ) attachment)
The speed of data transfer as lower It supports hot-swapping
Power consumption is more SATA is one of the latest technologies
It doesn’t have the feature of hot swapping Power consumption is less
2 devices attached to the single cable SATA have usually 7pins
SATA drives offers generally 133 MB/sec transfer SATA drives offers generally 300
rate MB/sec transfer rate
It sends 8 bit data at a time Only one drive can be connected in
single SATA cable

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 70


227) Discuss different factors that must be considered before making a choice for the network
topology.
ANSWER:
 Money: Bus topology may be the least expensive way to install a network because you
do not have to purchase central devices.
 Length of cable needed: The bus topology uses shorter lengths of cable.
 Future growth: The star topology expands the network is easily used for future growth
because it is simple to add a central device.
 Cable type: The most common used cable in schools is unshielded twisted pair, which is
most often used with star topologies.

228) Define the following terms in the field of computer science


a. Computer
b. Algorithm
c. programming

ANSWER:

a. A computer is an electronic device capable of receiving raw facts (data) and performing a
sequence of operations on the data based on special computer instructions (processing) to
produce desired output (information).
b.Algorithm refers to a step-by-step procedure that specifies how to perform a task or
solve a problem
c. Programming(Computer programming) is a systematic process of writing a computer
program using programming languages

229) Define the following:


a) Portable device:

b) Smartphone:

c) Data structure

ANSWER:
a) A portable device: is a device that can easily be carried. It is a small form of a computing
device that is designed to be held and used in the hands.

b) Smartphone: is a handheld personal computer with a mobile operating system and an


integrated mobile broadband network connection for voice, SMS, and Internet data
communication.

c) Data structure: is a way of collecting and organizing data in such a way that we
can perform operations on these data in an effective way.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 71


230) Write in full the following abbreviations:
a) VPN b) TFPS c) RDBMS d)UTP
ANSWER:
a)VPN: A virtual private network
b) FTPS: File traditional file processing system.
c) RDBMS: Relational database management system
d)UTP: Unshielded twisted pairs
231) What is a browser? Give at least four different types of Web Browsers.

ANSWER:

Browse (Web browse) is program used for displaying and viewing web pages on the World
Wide Web (WWW).The web pages can be accessed using a web browser.

Four different types of Web Browsers

 Internet Explorer
 Mozila Firefox
 Safari
 Opera
 Google chrome
 Netscape Navigator/ Netscape
 Mosaic
232) What is a VPN?

ANSWER:
VPN is a technology that allows remote users to connect and access network resources securely
over the Internet. VPN stands for Virtual Private Network.

233) Which of the following is an Internet services provider in Rwanda?


a. MTN
b. Techno Brain
c. Airtel
d. RDB
e. Both a and c
f. None of the above.

ANSWER:

e. Both a and c

234) What are the responsibilities of a DBA (Database Administrator)?

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 72


ANSWER:

The Database Administrator is responsible for:

✓ Responsible for authorizing access to the database


✓ Responsible for coordinating and monitoring its use
✓ Responsible for acquiring software and hardware resources,
✓ Controlling its use and monitoring efficiency of operations.
OR

The database administrator responsible for:

 Configuration
 Upgrade
 Administration
 Monitoring and
 Maintenance of database in an organization.
235) Explain the advantages of using database management system than a file system of an end
user?

ANSWER:

The DBMS (Database Management System) is preferred ever the conventional file processing
system due to the following advantages:

 Controlling Data Redundancy


 Elimination of Inconsistency
 Better service to the users because data are shared.
 Flexibility of the system is improved.
 Integrity can be improved
 Standards can be enforced
 Security can be improved
 Organization’s requirement can be identified.
 Cost of developing and maintaining systems is lower
 Provides backup and recovery.

236) a) What is a protocol?

ANSWER:

It is a set of rules that governing communication between computers in the network. Protocol is a
set of rules that governs data communication.

b) Give 5 main functions of the protocols.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 73


ANSWER:

Main functions of the protocols:

 Identifying errors
 Compressing data
 Deciding how data will be sent
 Addressing data
 Deciding how to announce sent and received data
 Network protocols enable computers to exchange data with each other in a meaningful,
organized and efficient way.
 They provide the path to increase the network connections
 They enhance the data transmission rate
 Provide easy working to users
 They enhance the speed of the connection

237) a) Define what IP address is.


b) Explain the difference between static and dynamic IP addresses?

ANSWER:

a)It is the unique number which identifies any electronic device on a network. OR
An IP address is the numeric identity of a node in the network.

b) A Static IP address is assigned manually. Once assigned it does not change unless it is
changed manually again. While

A Dynamic IP address is assigned by a service usually DHCP. It can change at any time.

Static IP addresses Dynamic IP addresses

They don’t change They change

They are more flexible They are not flexible


They are usually assigned to servers They are usually assigned to clients
They are manually assigned by network They are dynamically assigned by DHCP
administrator server.

They are expensive than dynamic IP They are Cheaper than static IP addresses
addresses

238) Convert the following flowchart into pseudocodes.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 74


ANSWER:

START
SET radius, area As Double
CONST PI=3.14
WRITE “enter radius”
READ radius
Area=radius *radius*PI
WRITE”print area”
STOP

239) Give and explain the use of operations used in Queue and in Stack?
ANSWER:

There are three main operations related to queues:


 Enqueue: the enqueue operation inserts an items at the rear of the queue
 Dequeue: the dequeue operation deletes the item at the front of the queue
 Display: show elements in the array

The different operations performed on stacks are as follows:


Push: adds an element to the stack
Pop: removes an element from the stack
Peek: display at top element of the stack

240) Define the following terms:

a)Data Structure
b) Null pointer
c) Give the syntax of class declaration.

ANSWER:
a) Data structures study how data are stored in a computer so that operations can be
implemented efficiently.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 75


b) Null pointer: is a type of pointer that pointing to invalid memory address or means it is a
pointer that pointing nowhere.

c)The syntax of class declaration.

class class_name {
access_specifier_1:
member1;
access_specifier_2:
member2;
...
};

241) Define the following terms

a)Threat

b) Virus

c) Worms

d)Operating system

ANSWER:
a) A threat is a potential negative action or event facilitated by a vulnerability that results in an
unwanted impact to a computer system or application.

b) A computer virus (Virus) is a malicious piece of computer code designed to spread from
device to device. A subset of malware, these self-copying threats are usually designed to damage
a device or steal data.

c) Worm is a type of malware that spreads copies of itself from computer to computer. A worm
can replicate itself without any human interaction, and it does not need to attach itself to a
software program in order to cause damage.

d)Operating system is system software that manages computer hardware, software resources,
and provides common services for computer programs.

242) Name the operating systems represented by the following icons:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 76


ANSWER:

a. Apple’s iOS
b. Android OS
c. Windows Phone OS
d. BlackBerry OS.

243) Compare Compilers and interpreters

ANSWER:

Compiler that translate the entire source code to object code, While an interpreter translates
source code one statement at a time

Interpreters Compilers

Translates source code one statement at a time. Translates the entire source code at once before
execution.

Translates the program each time it is run hence Compiled object code is saved on the disk
slower than compiling. hence runs faster than interpreted programs.

Interpreted object code takes less memory Compiled programs require more storage to
compared to compiled program. store the object.

244) One example of portable device is a smartphone.


a) What portable device means?

b) Give another two (2) examples of portable devices and one feature for each.
ANSWER:

a) A portable device is a small form of a computing device that can easily be carried and is
designed to be held and used in the hands. OR
A portable device may also be called a handheld device or mobile device
b)

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 77


243) Write C++ program to print the following patterns using for loop

ANSWER:

#include<iostream>
using namespace std;
int main ()
{
for (int i=0; i<=20; i+=5)
{
for(int j=0;j<=i;j+=5)
{
cout<<j<<"\t";
}
cout<<"\n";
}
return 0;}
245) a)What is switching?

Switching is process to forward packets coming in from one port to a port leading towards the
destination. When data comes on a port it is called ingress, and when data leaves a port or goes
out it is called egress. A communication system may include number of switches and nodes.

b) How does the message switching differ from circuit switching?

When two nodes communicate with each other over a dedicated communication path, it is called
circuit switching. There 'is a need of pre-specified route from which data will travel and no other
data is permitted. In circuit switching, to transfer the data, circuit must be established so that the
data transfer can take place. While message switching first receives the whole message and
buffers it until there are resources available to transfer it to the next hop. If the next hop is not
having enough resource to accommodate large size message, the message is stored and switch
waits.

245) Define:
a)Variable
b)Pseudocode
c)Flowchart

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 78


ANSWER:
a) variable is a memory zone which is used to store data.
 It is characterized by a name, an address and a data type.
 The variable names are used to store the values.
b) Pseudocode is a standard method of describing an algorithm without use of any specific
programming language.
c)A flowchart is a diagrammatic or symbolic representation of step-by-step solution to a given
problem.

246) List three significant limitations/disadvantages of the computer. (3marks)

ANSWER:
Limitations Of Computer
 It cannot work without electricity
 Computer cannot take own discussion
 Computer has zero IQ
 Computer is completely depends on human
 Computer is costly
 Computer has no creativity

247) Briefly, give steps of designing a good database


ANSWER:

 Investigate the information.


 Identify the objects.
 Model the objects.
 Identify the types of information for each object.
 Identify the relationships between objects.
 Database optimization through normalization.
 Data entry and manipulation

248) Write the abbreviations in full as used in computer science

a) UPS
b) CPU
c) CMOS
d) OS
e) GIGO
ANSWER:

a) UPS -Uninterruptible Power Supply

b) CPU –Central Processing Unit

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 79


c) CMOS -Complementary Metal-Oxide Semi-conductor

d) OS -Operating System

e) GIGO -Garbage In Garbage Out

249) Using an arrow match the following in Group A with their corresponding in Group B

Group A Group B
a. Radio waves 1. Qualities of Computer network
Performance
b. Millions of interconnected network 2. Disadvantages of Computer network
c. Sharing resources 3. Wireless
d. Hacking attacks 4. WAN
e. Bandwidth and Latency 5. Advantages of Computer network

ANSWER:

 A=3
 B=4
 C=5
 D=2
 E=1

250) In the school environment, classify the following computers into servers, workstations, or
embedded computers:
a. Computer used to control access to hardware and software resources in a networked
environment.
b. Computer used to access hardware and software resources in a networked environment.
c. Computer used in smart cards such as those used on ATMs and automated parking.

ANSWER:
a) Servers
b) Workstation
c) Embedded computer

251) Respond the following statements by “True” or “False”.


a) “If software piracy means unauthorized copying or distribution of copyrighted software”,
Software piracy is legal and can’t result in both civil as well as criminal penalties. False
b) Among the fire extinguishers you have learnt, you have recommended installing powder
fire extinguisher in your computer lab. False
c) Surge suppressor and Uninterruptible power supply (UPS) are power protection devices

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 80


used to protect the data and computer equipment. True
252) Define the following terms:

a. Applications software
b. System software
c. Programming language
d. programmer
e. Coding

ANSWER:
a. Applications software: are programs that are designed to help users accomplish specific
tasks.
b. System software: are programs which control functionality of fundamental operations of
computer systems in general
c. Programming language: is an artificial language used to create new programs.
d. A programmer: is a person who writes computer program.
e. Coding: is the process of writing instructions to enable a computer to do a specific task.

253) Write the following abbreviations in full words:


a)COBOL
b)FORTRAN
c)BASIC
d)CPU

ANSWER:

a)COBOL: Common Business Oriented Language


b)FORTRAN: Formula Translator
c)BASIC: Beginners All-Purpose Symbolic Instruction Code
d)CPU: Central Process Unit

254) Distinguish an algorithm versus a flowchart


ANSWER:

Algorithm is a set of instructions which produce a solution to a given problem while the
flowchart is a graphical representation of an algorithm.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 81


255) Describe four common symbols used to draw a flowchart

ANSWER:

256) When is output of an AND gate FALSE


ANSWER:

An AND gate returns FALSE when all operands (inputs) are false (0).

257) Print out the results of the following codes:


var a, b, sum1, sum2 as integer
Begin:
a=3, b=2;
sum1=b + (++a); Write
(sum1); sum2=a + (++b);
Write (sum2);
End
ANSWER:

Output: 6 7
258) Explain the term “Variable”
ANSWER:
A variable is a memory zone which is used to store data.
259) Discus about the scope of variable used in C++.
ANSWER:
The scopes of variable used in C++ are global or local. A global variable is declared outside
all functions while a local variable is declared within a function.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 82


260) Distinguish the Variable declaration from variable initialization. (4 marks)
ANSWER:
Variable declaration is declared by first specifying the data type of the variable followed by a
valid variable identifier thus variable initialization is a process of assigning a value into the
variable.
261) With an example, illustrate the use of “Continue jump statement.
ANSWER:
The Continue statement is used in repetition statements to cause the program to skip the
remaining statements in the body of the loop to test the condition.

#include <iostream> using


namespace std; int main
(){
for(int n=10; n>0; n--) {
if(n==5)
continue;
cout << n << ", ";
}
return 0;}

262) Discus four types of selection (decision) control structures supported by most structured
programming languages.
ANSWER:

(a) The if selection is a control statement that performs an action if the condition is true, or
skips
the action if the condition is false.
(b) The if …else selection is conditional logic that specifies the action to be performed if
the condition is true, or an alternative the action is false
(c) The nested if…else selection is a conditional logic that tests for multiple alternatives by
placing if…else statements within another if…else statement.
(d) The switch... case control statement is used to choose from several alternatives. Within
the switch are actions (cases) associated with a constant value that must be evaluated before the
statements within each case are executed.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 83


263) Write an algorithm that request a user to enter his/her ages. If the ages are greater than 17
years old, the program displays “you are allowed to vote” otherwise “you are too young”.
ANSWER:

Var age as integer


Begin:
Write(" You have lived through a lot")
Read (age);
if (age>17) then
Write (" you are allowed to vote")
Else
Write (“you are too young”)
End if
End

264) Respond the following statements by “True” or “False”.

a)Peer to Peer network is more secure than Server-Client network. FALSE


b)If a member or variables defined in a class is public, then they are accessible by members of
the same class only and cannot be accessed from outside the class. FALSE
c)Infrared waves can be used outside of a building because sun's rays contain infrared waves
that can’t interfere with communication. FALSE
d) ToolBox is used to add controls to the forms of your project. FALSE
e) The friend functions and friend classes of the base class could be inherited. FALSE
f) Destructor functions are always defined in the private type access specifier. FALSE
g) A default constructor is a constructor which doesn’t have any argument. TRUE

265) Define the following terms:


a) A pointer d) A constructor function
b) A structure in C++ e) A variable
c) A class in C++

ANSWER:

a) A pointer: is a variable which store an address of another variable.


b) A data structure is a group of data elements grouped together under one name
c) A class in C++: Class is a way to bind the data and its associated functions together.
It is a user-defined data type that has data members and member functions.
d) A constructor function: is a member function which is automatically called when an
object of that class is declared. It has the same name as the class in which it is created.
e) A Variable is a given location memory name which is used to store information to be
referenced and manipulated in a computer program

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 84


266) Why using an infrared TV remote control in our home will not interfere with the use of our
neighbor’s infrared TV remote control.

ANSWER:
The infrared TV remote control in our home will not interfere with the use of our neighbor’s
infrared TV remote control because of its frequencies (between 300 GHZ to 400 THZ) which
cannot penetrate walls.

267) What is an event in visual basics? Give two examples.

ANSWER:
An event is a signal that informs an application that something important has occurred.
Examples: Mouse clicks, move cursor, press a button…

268) Examine the difference between Access Point and Hub?


ANSWER:

A hub is a network hardware device for connecting multiple devices together and making them
act as a single network segment. while
The Access Point is a network device connected to the Hub, switch or router (via copper
cable) and spread radio waves (wireless internet) to the rest of network.

269) Write short notes on the following terms:


(a) Computer programming,
(b) Source program
(c) Object code.

ANSWER:
a) Computer programming is a systematic process of writing a computer program using
programming languages. Or
Computer programming is the act of writing computer programs, using a Computer
Programming Language to perform a specified task by the computer.

b) Source program refers to a program that is not yet translated


c) Object code refers to the program code that is in machine readable form

270) State four types of selection control structures supported by most structured programming
languages.

ANSWER:

 Selection control structure are if, if..else, nested if and switch ..case selection

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 85


271) Define the terms binary code, mnemonics, and assembler.

ANSWER:

Binary codes are 0's and 1's, mnemonics are abbreviations and assembler converts a low-level
assembly program to machine form.
272) Explain why C++ is regarded as multi-paradigm programming language.

ANSWER:

 Because it supports imperative, OOP, and functional programming.

273) Rewrite the following mathematical expression into a C++ assignment statement:

a)Z= ax3 + bx2 + cx+10.

b)Y = ax3 + bx+ 7

ANSWER:

The assignment statement expected are:


a)Z= a*( x * x*x) + b* (* x *x)+ c*x+10;
b)Y = a*(x*x*x) + b*x +7;

274) Mr. Peter bought a new electrical kettle. On the power switch of if were two inscribed digits
0 and 1:

(a)Explain what each of the two symbols stand for.

(b) Explain why the two symbols are important in computers and computer programming.

ANSWER:

a) Sands for bits 1 and 0

b)Computers only understand machine language hence every instruction must be converted to 0's
and 1's.

275) Write a C++ Program to Find Size of int, float, double and char in your System.

ANSWER:

#include<iostream>
using namespace std;
int main() {
cout << "Size of char: " << sizeof(char) << " byte" << endl;
cout << "Size of int: " << sizeof(int) << " bytes" << endl;
cout << "Size of float: " << sizeof(float) << " bytes" << endl;
cout << "Size of double: " << sizeof(double) << " bytes" << endl;

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 86


return 0;}
276) a)Differentiate between library functions and user-defined functions.
ANSWER:

 Library functions are in-built into a compiler while user-defined are written by the
programmer

b) Define the term artificial intelligence.


ANSWER:

Artificial intelligence refers to the effort to develop computer-based systems (both hardware and
software) that behave as humans.

c) What is meant by case sensitive? Is c++ case sensitive?


ANSWER:

Yes, C++ is case sensitive


✓ C++ is case sensitive it means uppercase and lowercase letters are considered to be different.
✓ A variable named age is different from Age, which is different from AGE.
✓ int age, Age, AGE; // those 3 variables are different.

277) Explain the importance of the following compiler utilities:

(a) Preprocessor. (b) Linker.

ANSWER:

(a) Preprocessor directives prepares the source code for compilation by removing comments,
and white spaces
(b) Linker combines the object code compiled from your source code with the code for the
imported functions to produce an executable file

278) What is an algorithm and how are algorithms essential?

ANSWER:

a) Algorithm is a step-by-step procedure, which defines a set of instructions to be executed in a


certain order to get the desired output. OR

Algorithm refers to a step-by-step procedure that specifies how to perform a task or solve a
problem.

b) Algorithms are essential to the way computers process information, because a computer
program is essentially an algorithm that tells the computer what specific steps to perform (in
what specific order) in order to carry out a specified task.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 87


279) What is int, float and char?

ANSWER:

Int: specifies the integer (positive and negative natural) numbers. A number that has no digits
after the decimal point.

Float: is a floating-point number, which is a number that can have digits after the decimal point.

Char: declares or specifies a single character. It is a data type that is intended for holding
characters, as in alphanumeric strings.

280) a) Explain the programming paradigm supported by F# programming language.

ANSWER:

 F# supports functional programming paradigm.

b) List four examples of object-oriented programming languages.


ANSWER:

 Smalltalk, Objective Delphi Pascal, C++, Java, C#, Visual Basic.Net, and C#.
c) Identify Five Integrated Development Environments (IDE) or Tools that can be used to create
C++ applications.

ANSWER:

 C++ IDEs include GNU C++, Dev C++, Microsoft Visual C++, CodeLite, NetBeans and
Eclipse..

281) Give the concepts of OOP.


ANSWER:

The concepts of OOP are: Object, Class, Inheritance, Polymorphism and Encapsulation

282) Draw a Client-Server network diagram and explain the role of each
component.(4 marks)

ANSWER:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 88


In a client-server network, the client requests information or services from the server and the
server provides the requested information or service to the client

283) What are difference between bus topology and tree topology?
ANSWER:

Bus topology is a type of network topology in which each included node is


connected to a single main cable which acts as the
backbone of the network. But In tree topology, the nodes are organized in
the form of a tree.

284) Differentiate member variable and member function.


ANSWER:

Member variables (Data members): Variables in a class are referred to as member variables or
data members.
Member function(s): Member functions are functions defined within a class that act on the data
members of a class.

285) Give the syntax of the inheritance class.


ANSWER:

class base_class{ //body of subclass};


Class derived_class: access_specifier base_class{
... //statements
...
};

286) Study this C++ code and identify possible syntax error.
# include<iostream> using
namespace std; main()
{
cout>>" Is a beautiful
country"; return 0;
}

ANSWER:

The syntax error was made at extraction operator on cout>> must be written as cout<<

287) What will be output of following code?


#include<iostream.h>
#define max 8+2
int main(){

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 89


intnum=max*max;
cout<<" The value of num= "<<num<<endl;
return 0; }

ANSWER:

The value of num= 26

288) A member function of a class can be defined inside the class or outside of class. Provide
the syntax which demonstrates how to define the member function outside of class?(4
marks)
ANSWER:

return_type+ class_name :: function_name( arg1, arg2, etc){


Statements; return variable;
}

289) What are the outputs of the following program?


#include<iostream> using
namespace std; voidprevnext
(int x)
{intPrev=x-1;
int Next=x+1;
cout<<"Previous="<<Prev<<"\t Next="<<Next;
}
int main ()
{int x=100;
prevnext(x); return 0;
}
Previous= 99 Next= 101

290) Explain the use of Textbox control in VB.


ANSWER:

The textbox is the standard control for accepting input from the user as well as to display the
output

291) Write a class called person which has two data members age and name and two member
functions getdata() to input name and age of a person and display( ) to print them out.
ANSWER:

#include<iostream> using
namespace std; class Person {
public: string name; int

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 90


age;
void getdata(string y, int x)
{ name=y;
age=x;
}
void display() {
cout<<"Your name is: "<<name<<" and your age is: "<<age;
}
};
int main() { Person
Student;
string a; int b; cout<<"Enter
your name\n"; cin>>a;
cout<<"Enter age\n"; cin>>b;
Student.getdata(a,b);
Student.display();
return 0;}

292) Let consider the database with table CUSTOMER identified by CustomerName,
Address, TelephoneNumber, CreditLimit, ItemOrdered,Quantityand Price.
However, a customer may order several items and each customer in the database may order a
different number of items. This situation makes it difficult to implement the data in a
relational database, since we do not know how many order entries to allow.
Is this database structure complex? If yes, identify the anomalies it has and suggest the
solution to the database designer to make it simple.
ANSWER:

Yes, this database structure is complex, because it results too much redundancy in the database's
information. To avoid suffer from poor construction of this table, database designer is suggest
to dive into two tables: one for Customer and another one for Order, and make a relationship
between those tables.

293) a) What is a protocol?

ANSWER:

It is a set of rules and procedures that govern communication between two or more devices in
the same network
b) Explain how does protocol work

ANSWER:

The computer that is sending data performs the following tasks:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 91


1. Breaks data into packets
2. Adds addressing information to the packets
3. Prepares the data for transmission.

The computer that receiving data then performs the same tasks but in reverse order

1. Takes the packet off the cable


2. Strips the data from the packet
3. Copies the data to a buffer for reassembly
4. Passes the reassembled data to the application
294) What is the purpose of “using namespace” in C++ program?
ANSWER:

The purpose of “using namespace” is to avoid name collusion

295) Your computer starts, you hear sound and see video. BIOS conduct POST and everything
seems fine but the following error message appears: Operating system missing. Which
components could be missing or damaged?
ANSWER:

Hard disk because is where O.S stored after installed in your P.C

296) Give four disadvantages of paper based information system?


ANSWER:

i.Lack of storage space

ii.Prone to damage

iii.Inefficient document transportation iv.


Supply costs

v. Poor environmental credentials vi.

Vi. Limited collaboration

vii. Editing problems

297) What are the responsibilities of Network Layer?


ANSWER:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 92


i. Network layer determines which route is suitable from source to destination.
ii. Network layer defines the logical address or IP address.
iii. It is responsible for encapsulating data
298) When output of an OR operator and AND operator return FALSE
ANSWER:

The OR operator returns a False if both operands (input) are False (0).
The AND operator returns a False if one of its operands (input) is False (0).
299) Compute the following
a) Find the binary equivalent of (255.45)10.
b) Convert (FADE)16 to octal system.
c) Represent “-32” in sign magnitude form.
ANSWER:

a) Find the binary equivalent of (255.45)10.=11111111.0111


b) Convert (FADE)16 to octal system. =175336
c) Represent “-32” in sign magnitude form. =10100000
300) What are outputs of the following C++ program code:

#include<iostream>
using namespace std;
void swap (int m, int n) {
int x = m;
m = n;
n = x;
}
int main() {
int x = 5, y = 3; swap(x,y);
cout<<"x="<<x<<"\n"<<"y="<<y; return 0;}

ANSWER:

Output:
x=5 y=3

301) Write an algorithm that read two numbers from keyboard and inform the user if the sum
of those numbers is odd or even.
ANSWER:

Var x, y sum as integer

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 93


Begin:
Write(“enter two integers”)
Read x, y
Sum=x+y
If (sum%2==0) then //if sum mod 2=0
Write( sum,”is even number”)
Else
Write( sum,”is odd number”)
End if
End
302) What is difference between:
a) Sniffing and spoofing?

ANSWER:

Spoofing means to pretend to be someone else. While Sniffing means to illegally listen
into another’s conversation
b) Authorization and Authentication
ANSWER:

Authentication confirms who you are while Authorization is the process to confirm what you
are authorized to perform.
303) What are the different between DELETE and DROP SQL Statement?
ANSWER:

DELETE is a Data Manipulation Language command, DML command and is used to


remove tuples/records from a relation/table whereas DROP is a Data Definition
Language, DDL command and is used to remove named elements of schema like
relations/table, constraints or entire schema. ... DROP is DDL.

304) What are the components of Visual Basic IDE?


ANSWER:

The Visual Basic IDE is made up of a number of components. Menu Bar; Tool Bar; Project
Explorer; Properties window; Form Layout Window; Toolbox; Form ,etc

305) Discuss the operations that can be performed on the computer memory. Read and Write

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 94


ANSWER:

Read operation is performed when information is transferred from the memory to another
device.
Write operation is performed when information is transferred from another device to the
memory.

306) Discus four conditions that must hold simultaneously for a deadlock to occur.
ANSWER:

There are 4 simultaneously conditions for the occurrence of deadlock:


1. Mutual exclusion: processes require exclusive control of its resources (not sharing).
2. Hold and wait: process may wait for a resource while holding others.
3. No preemption: process will not give up a resource until it is finished with it
Also, processes are irreversible: unable to reset to an earlier state where
resources not held.
4. Circular wait: each process in the chain holds a resource requested by another

307) The diagram below show the log-in screen on network. To gain access to the internet the
user name and password must be entered.

a. W h a t is a password?

ANSWER:

It is a secret word or phrase that must be used to gain access to a computer system or service.
b. W r i t e VB code for login when Ok button is clicked. For example if user set user name as
“User” and Password as “Password”, Form 2 will appear on screen and Login form disappear.
ANSWER:

Pravate sub Ok_click()


If Text1.Text = "User" And Text2.Text = "Password" Then
MsgBox ("Logged successful")

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 95


Form2.Show
Login.hide
Else
MsgBox ("Logged unsuccessful, Try again") End If
End sub

308) Discuss 5 operations that can be performed on a File.


ANSWER:

The following are some of the typical file operations:

1. Creating: It helps in creating a new file at the specified location in a computer system.
The new file could be a word document, an image file or an excel worksheet.

2. Saving: It helps in saving the content written in a file at some specified location. The file
can be saved by giving it a name of our choice.

3. Opening: It helps in viewing the contents of an existing file.

4. Modifying: It helps in changing the existing content or adding new to an existing file.

5. Closing: It helps in closing an already open file.

6. Renaming: It helps in changing the name of an existing file.


7. Deleting: It helps in removing a file from the memory of the computer system.

309) List the four basic arithmetic operators/4marks


ANSWER:

+: addition
-: subtraction
*: multiplication
/: division
%: Modulus

310) Diferentiate the following terms used in computer and computer science
a) Embedded computers versus General purpose computers.

ANSWER:

Embedded computers are computing devices designed for a specific purpose. Generally, an
embedded computer has an operating system that only runs a single application, While General
purpose computer is a computer that is designed to be able to carry out many different tasks.

Examples of embedded computing devices include dishwashers, ATM machines

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 96


Examples of general purpose are Desktop computers and laptops computer

b) Servers versus workstation computers.

ANSWER:

A server is a dedicated computer that provides hardware or software resources to other


computers on a local area network (LAN) or a over the Internet, while workstation computer is
a computer connected to a server and intended to be used by one person at a time.

311) Terambere Company Ltd is running a business and wishes to manage transactions in
computerized way. The database of business contains various entities including “Customers” (id,
names, age, address, salary) and orders (id, date,customer_id, amount) which are given here
below. Help your school to find a solution to get the following:
i. The highly paid Customer
ii. The least paid Customer
iii. The oldest Customer
iv. The youngest Customers
v. To generate total amount of income at a given day.
vi. To retrieve only the names and age of all Customers
vii. To retrieve the average income at a given day.

ANSWER:

i. Select max(salary) as Highly_paid_employee from customers;


ii. Select min(salary) as Least_paid_employee from customers;
iii. Select max(age) as oldest from customers;
iv. Select min (age) as youngest from customers;
v. Select sum(amount) as total_income from orders;
vi. Select names,age from customers;
vii. Select avg(amount) as average from orders;

312) Discuss the characteristics of Random Access Memory (RAM)

ANSWER:
 Data can be read (retrieved) and written (stored) in it.
 RAM is a temporary (volatile) storage because its content disappears when the computer
is switched off
 Its content can be changed
 RAM is faster and stores the instructions which are directly accessed by the CPU
313) Explain why the MS Access is used as database application software.
ANSWER:

The MS Access is used as database application software because it provides the following
features of DBMS:
 Improved data sharing

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 97


 Improved data security
 Better data integration
 Minimized data inconsistency
 Improved data access
 Improved decision making. ...
 Increased end-user productivity.

314) Write a C++ program which prompts the user to enter two numbers and print out their sum
and average.

ANSWER:

#include<iostream.h>
int main( ) {
float a, b, sum, average;
cout<<”Enter any two integer numbers:”<<endl;
cin>>a>>b;
sum=a+b;
average =sum/2;
cout<<” Sum = ” <<sum<<endl;
cout<<”Average = ”<< average <<endl;

return 0; }

315) Consider a 4x3 array T

i) How many rows does T have?


ii) How many elements does T have?
iii) Write name of elements in the second row
iv) Write the name of elements in the third column
v) Write statement that sets the elements of T in row 1 and column 2 to zero.

ANSWER:
i)4rows

ii)12 elements

iii)T[1][0],T[1][1],T[1][2]

iv)T[0][2],T[1][2]T[2][2],T[3][2]
v)T[0][1]=0

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 98


316) Match the following generations of computers with the technology used to develop them.
A: Generation of Computer B: Main Characteristics

1. First generation A. Integrated Circuit


2. Second generation B. Microprocessors
3. Third generation C. Artificial Intelligence
4. Fourth generation D. Vacuum Tube
5. Fifth Generation E. Transistors

ANSWER:

1→D, 2→E, 3→A, 4→B, 5→C

317) What stand for following abbreviations?


a) SCSI
b) HMDI
c) IDE
ANSWER:

a) SCSI: Small Computer Systems Interface


b) HMDI: High Definition Multimedia Interface
c) IDE: Integrated Development Environment

318) List any three responsibilities of DBA (Database Administrator)?

ANSWER:

Function of DBA

 Creating and maintaining database standards and policies


 Supporting database design, creation, and testing activities
 Managing the database availability and performance, including incident and
problem management
 Administering database objects to achieve optimum utilization
 Defining and implementing event triggers that will alert on potential database
performance or integrity issues
 Performing database housekeeping, such as tuning, indexing, etc.
 Monitoring usage, transaction volumes, response times, concurrency levels, etc.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 99


 Identifying reporting, and managing database security issues, audit trails, and forensics
 Designing database backup, archiving, and storage strategy

319) List and explain the main components of central processing unit (CPU).
ANSWER:

The Central Processing Unit (CPU), also known as the processor, It is actually regarded as the
“brain” of the computer because all processing activities are carried out inside the processor.
The CPU is made up of three distinct components within it:
 The Arithmetic Logic Unit (ALU): -ALU performs all arithmetic and logical
operations.

The arithmetic and logic unit is the location within which all arithmetic and logical operations
are carried out in the CPU. Basic arithmetic operations include; addition, subtraction,
multiplication and division.
 Control Unit: -The control unit coordinates all processing activities in the CPU as well
as input, storage and output operations. It determines which operation or instruction is to
be executed next.

The control unit interprets instructions and controls speed of execution using a clock.
 Registers: special memories within the CPU for holding instructions and data.
320) List down any four internal components of computer .
ANSWER:
 Motherboard
 CPU (Microprocessor)
 Main memory (RAM)
 Expansion cards.
 Power supply unit.
 Optical disc drive.
 Hard disk drive (HDD)

320) a) Define the term Entity as used in Database.


b) Distinguish between strong and weak entity.
ANSWER:
(a) Database entity is a thing, person, place, unit, object, or any item about which the data
should be captured and stored in the form of properties, workflow, and tables.

(b) Difference between Strong and Weak Entity:


ANSWER:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 100


321) State other 3 ports that are available on desktop computer.

ANSWER:

 Serial port
 Parallel Port
 Universal Serial Bus
 Video graphics array port
 Network port
 Audio Ports
 Firewire connector
 High Definition Multimedia Interface (HMDI)
322) List 4 examples of secondary storage .
ANSWER:
Examples of secondary storage are:
 Hard disk drive
 Memory card
 Floppy disk
 DVD
 CD

323) Explain why it is good practice to install genuine copy of an operating system.

ANSWER:
Piracy is illegal. Hence installing genuine software is an ethical requirements against piracy and
intellectual property theft.

324) When you move the NIC cards from one PC to another PC, does the MAC address gets
transferred as well? Explain your answer.

ANSWER:
Yes, when you move the NIC cards from one PC to another PC, the MAC address gets
transferred because MAC address is manufactured on NIC. means MAC is the unique address of
NIC.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 101


325) a)What is operating system? (2marks)
b)Which of the following are system software and application software? (3marks)
i. Microsoft edge
ii. Windows 10
iii. UNIX
iv. Opera mini
v. Microsoft office word 2016
vi. Firmware

ANSWER:
a. An operating system (OS) is system software that manages computer hardware and software
resources and provides common services for computer programs
b)

326) a) With 2 examples for each, differentiate straight - through cable from cross-over cable .
b) Contrast Bluetooth and Wi-Fi(wireless fidelity).
c) In a network that contains two servers and twenty workstations, where is the best place to
install an antivirus program. Explain why?

ANSWER:
a) A straight-through cable is a type of twisted pair cable that is used in local area networks to
connect a computer to a network hub such as a router. OR
A straight-through cable: are used to connect the unlike devices. (1mark for correct definition)
Examples:
 Switch to router

 Switch to PC or server

 Hub to PC or server

A crossover cable is a type of ethernet cable used to connect computing devices together directly.
Also,
A crossover cable can be defined as a type of cable installation that is used for the
interconnection of two similar devices. (1mark for correct definition)
Examples:
 Switch to switch

 Switch to hub

 Hub to hub

 Router to router

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 102


 Router Ethernet port to PC NIC

 PC to PC

b) Bluetooth is a wireless technology used for exchanging data between fixed and mobile
devices over short distances. While
Wi-Fi (Wireless Fidelity) is a name of a wireless networking technology that uses radio waves
to provide wireless high speed internet and network connection.

c) An Anti-virus program must be installed on all Server and Workstation to ensure protection.
That is because individual user can access any workstation and introduce a computer virus when
plugging in their removable hard drive or flash drives.

327) Give and explain 5 properties of network

ANSWER:
Easy Sharing of Resources: Computers are able to share various resources easily over a
network. Shared resources can be Internet, files, printer, storage and others.

Performance: It is achieved by measuring the speed of data transmission with number of


network users, connectivity used and the software used. The commonly measured qualities in
the network performance are Bandwidth and Latency.

Reliability: It means that computer network provides assurance of the delivery of data to the
intended recipient.

Scalability: The possibility of adding new computer without affecting the network performance.

Security: computer network must be secured for the benefit of the user and data protection. The
security is achieved by protecting data from unauthorized access.

328) Explain the common disadvantages of using computer network

The common disadvantages of computer networking are:


a. Lack of independence: people rely on computer network and when the system is down,
people get stack. Most of organizations depend on the computer networks.

b. Security issues: Huge numbers of people use a computer network to get and share their files
and resources, a certain user’s security would be always at risk. Viruses can spread to other
computers throughout a computer network. There is a danger of hacking, particularly with wide
area networks. Security procedures are needed to prevent such abuse, Examples: The use of
Antivirus and firewall.

c. Lack of robustness: computer network’s main server breaks down; the entire system would
become useless.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 103


329) What are the types of relationships Based on cardinality, Give example for each type.

ANSWER:
a. One to One (1:1): A person can have only one passport.
b. One to Many (1: M): A class has many students.
c. Many to one (M:1) a mother has many children
d. Many to Many (M:M): many customers can purchase more than one book.

330) Explain the following terms


a. Garbage In Garbage Out(GIGO)
b. Artificial Intelligence
c. Disk Partitioning
d. Disk Defragmentation

ANSWER:
a. If the input is wrong, the computer processes wrong output hence the term Garbage In
Garbage out (GIGO). GIGO is a phrase used in computer science that implies that if invalid or
erroneous data is entered into a computer (garbage in), the computer will process and output
invalid or erroneous results (garbage out)
b. Artificial intelligence refers to the simulation of human intelligence in machines that are
programmed to think like humans and mimic their actions.

c. Partitioning a disk refers to the process of dividing a large physical disk into two or more
partitions called logical drives that are treated as independent drives.
d. Defragmentation is the process of moving file fragments to contiguous clusters to optimize
on storage space and performance.

331) Categorize the following devices according to their transmission modes.


a) TV b) Radio
ANSWER:

a) TV: Simplex mode b) Radio: Simplex mode

332) Discuss different types of transmission media in computer network.

ANSWER:

 Simplex
In simplex transmission mode, the communication between sender and receiver occurs in only
one direction. The receiver cannot reply to the sender.

To take a keyboard/monitor relationship as an example, the keyboard can only send the input to
the monitor, and the monitor can only receive the input and display it on the screen. The monitor
cannot reply, or send any feedback, to the keyboard.

 Half Duplex

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 104


The communication between sender and receiver occurs in both directions in half-duplex
transmission, but only one at a time. The sender and receiver can both send and receive the
information, but only one is allowed to send at any given time.
For example, in walkie-talkies, the speakers at both ends can speak, but they have to speak one
by one. They cannot speak simultaneously.

 Full Duplex
In full-duplex transmission mode, the communication between sender and receiver can occur
simultaneously. The sender and receiver can both transmit and receive at the same time. The
full-duplex transmission mode is like a two-way road, in which traffic can flow in both directions
at the same time.

For example, in a telephone conversation, two people communicate, and both are free to speak
and listen at the same time.
333) Give and explain different types of registers.

ANSWER:
 Instruction register: It temporarily holds an instruction before it is converted to
machine readable format.
 Address register: It temporarily stores the address of the next instruction to be
processed.
 Accumulator register: It temporarily holds the last processing step of the
Arithmetic Logic Unit (ALU).
 Storage register: It temporarily holds information waiting to be output.

334) Define two dimensional arrays and give their syntax for declaring it.

ANSWER:

A two dimensional array is a collection of a fixed number of elements (components) of the


same Data type arranged in columns and rows making two dimensions.

The syntax for declaring a two dimensional array is:


Set array name= array [row size][column size] of data types

335) In the network that contains two servers and twenty workstations, where is the best place to
install an antivirus program? Explain why?

ANSWER:

 The best place to install antivirus is in two servers.


 Because workstations access information from servers and then when the servers are safe.
All workstations are safe also.
 It will reduce cost of antivirus when you install in servers.
 It will increase the cost of antivirus when you install antivirus in twenty workstations.

336) Write the following abbreviations in full as used in computer systems: (4marks)

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 105


a. COBOL
b. SCSI
c. NTFS
d. AGP

ANSWER:
a. COBOL : Common Business Oriented Language
b. SCSI : Small Computer System Interface
c. NTFS: New Technology File System
d. AGP: Accelerated Graphics Port

337) Mention 2 examples of power protection devices that can be employed to secure a
computer from power related problems.

ANSWER:
Surge suppressors or surge protector.
Uninterruptible Power Supply (UPS).

338) Explain how computers play very important roles in the following various socio-economic
sectors:
a) In education

b) At home

ANSWER:

a) In education:
 Computers are used in teaching and learning in schools, colleges and universities;
 Online learning, and it is done through
 Use of computers in education and training
 Research through the Internet
 Online registration
b) At home
 Computers can be used at home for recreational activities such as: watching movies,
 They are used for playing music and computer games.
 They can also be used in storing personal information,
 They are used for calculating,
 They are used for keeping home budgets and research.

339) State four factors you would consider before installing computer software whether an
operating system or application software.

ANSWER:
 Memory (RAM) capacity.
 Free hard disk space.
 Processor type and speed.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 106


 Graphics display.

340) a) What is a file system?


b) List 2 examples of windows file system

ANSWER:
a) A file system is the structure used by operating system to store, retrieve and update data on
storage device.

b) Examples of Windows file systems include File Allocation Table (FAT32), New Technology
File System (NTFS) and extended FAT (extFAT).
341) Answer the following questions by true or false

i. public data members of a class can be accessed directly in the main function without an object?

ii. Every object of a class has its own copy of the data and functions.

iii. A destructor can be overloaded?

ANSWER:
i)False
ii)True
iii)False

342) Write an Algorithm that decrease the numbers for 10 to 0 number and when it reaches to
number 4 it skips that iteration, using loop.
ANSWER:
Var i as integer
Start
For(i=1 to 0) do
If(i==4) then
Continue
Write(i)
End if
End for
End

343) Give three examples of wireless devices.

ANSWER:
 Laptop
 Desktop
 Smartphone
 Tablet
 Smart TV

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 107


 Wireless speakers
 Wireless headphone
 Router
 Wireless keyboard
 Printer
 scanner

344) Explain the difference between one to many and many to many relationship. Give an
example for each.

ANSWER:
One to many relationship: An instance of one entity can relate to multiple instance of another
instance.
The relationship that associates one record of entity A to more than one record of entity B is
called one-to-many relationship.
Example of one-to-many relationship is a country having states, School has many Students.
While

Many to many relationship: Multiple instances of an entity can relate to multiple instances of
another entity.
Example of many to many relationships is Teacher and Student the relationship is many
teachers teach many students.

345) Distinguish a week entity from strong entity.

ANSWER:
A week entity is an entity which depends on another entity while a strong entity does not depend
on another entity.

346) Write equivalent switch statement for the following:


if (code = = ‘a’)
cout << “season is summer”;
else
if (code = = ‘r’)
cout << “season is rainy”;
else
if (code = = ‘w’)
cout << “season is winter”;
else
cout << wrong code”;

ANSWER:

switch(code)
{
Case ‘a’:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 108


Cout<<” season is summer”;
Break;
Case ‘r’
Cout<<” season is rainy”;
Break;
Case ‘w’ :
Cout<<” season is winter”;
Break;
Default:
Cout<<” wrong code”;
Break;}

347) Write in full the following terms


A) USB
b) VGA
c) XOR
ANSWER:

A) USB: Universal Serial Bus


b) VGA: Video Graphic Array/Adapter
c) XOR: Exclusive OR gate

348) Tick in the cell where the device matches with the device type as shown below.

ANSWER:

DEVICES INPUT DEVICES OUTPUT DEVICES STORAGE


DEVICES
RAID √
Touchpads √
Lightpen √
Scanner √
microphone √
Monitor √
speaker √
Electronic whiteboard √
printer √
Compact disk √
Hard disk √

349) Which of the following is designed to control the operations of a computer? Explain it.
a) Application software
b) System software
c) Utility software
d) User (3marks)
ANSWER:
b) System software.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 109


System software is basically classified into: System and application. System software is
designed to control the operations and extend the processing capability of a computer system.

350) Explain components of CPU.


ANSWER:
The CPU is made up of three distinct components within it:
 The Arithmetic Logic Unit (ALU): performs all arithmetic and logical operations.
 Control Unit: interprets instructions and controls speed of execution using a clock.
 Registers: special memories within the CPU for holding instructions and data.

351) a) What is constraint?

ANSWER:
Constraints are the rules enforced on the data columns of a table. These are used to limit the type
of data that can go into a table.

b) Name all the integrity constraints used during table creation?


ANSWER:
The following constraints are commonly used in SQL:
 NOT NULL: Ensures that a column cannot have a NULL value.
 UNIQUE: Ensures that all values in a column are different.
 PRIMARY KEY: A combination of a NOT NULL and UNIQUE. ...
 FOREIGN KEY: Uniquely identifies a row/record in another table

352) a) Given below the case of array a:


a[0][0] 1
a[0][1] 2
a[0][2] 3
a[1][0] 13
a[1][1] 17
a[1][2] 34
i) Give the size of the above array.
ii) Declare array a.
iii) Initialize the above array.

ANSWER:
i) Size of array: rows= 2 ; columns= 3
ii) Declaration of array a: var a[2][3] As integer.
iii) Initialization of array:
a[0][0] = 1
a[0][1] = 2
a[0][2] = 3
a[1][0] =13
a[1][1] =17
a[1][2] = 34

353) Differentiate Linear search from Binary search

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 110


ANSWER:
Linear search: This method traverses a list sequentially to locate the search key.

Binary search: This method works on sorted lists by progressively making better guesses to
find the location of a search key.

354) Which types of cables you can use to connect the following devices?

a)computer to the internet


b) Projector to the computer
c) Computer to the high speaker’s devices.
d)laptop to the electrical outlet.
e)Computer to printer

ANSWER:
a)UTP cable
b)HDMI Or VGA cable
c) Sound cable
d)Power Adapters
e)USB cable, parallel cable or serial cable
355) Explain some characteristics that make a computer suitable for processing Repetitive task.

ANSWER:
 It does not get tired (reliable)
 It can be programmed to perform a task repetitively(versatile)
 It does not have the human body weaknesses (diligent)
 Once programmed it follows instructions exactly without fail(accuracy)
356) Highlight some 3 achievements of the fifth generation computers.
ANSWER:
 Multi-processor based system.
 Use of Artificial Intelligent.
 Development of devices that are capable of learning, and respond to natural language
input (voice recognition).
 Development of natural language processing.
 Use of optical fiber in circuits
 Development of the elements of programs
 Automated audio in any language to control the workflow of the computer
 Magnetic enabled chips
 Huge development of storage
 More powerful micro and macro computers
 Development of enormous powers with AI
357) State 4 operations you can do in the list.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 111


ANSWER:
In the list you can do the following operations:
 LIST: Creates an empty list;
 INSERT: inserts an element in the list;

 DELETE: deletes an element from the list;

 RETRIEVE: retrieves an element from the list;

 TRAVERSE: traverses the list sequentially;

 EMPTY: checks the status of the list.


358) Given the following software:
Ms Word 2016, Kaspersky, Windows 8, Ms Excel 2016, Photoshop, Ms access 2016
a) Which is an operating system?
b) Which is application software?
c) Which is word processor software?
d) Which is database software?
e) Which is spread sheet software?
f) Which are Microsoft office programs?

g) Which is graphic software?


h) Which is antivirus software?
i) Which is must be installed firstly into a new computer? Why?

ANSWER:
a. Window 8
b. Ms word, Kaspersky, ms excel2016, photoshop, ms access 2016
c. Ms Word
d. Ms Access
e. Ms Excel
f. Ms Word, Ms Excel, Ms Access
g. Photoshop
h) Kaspersky

i) Windows 8: It is an Operating System, if is not installed firstly, that new computer cannot
work.

359) Which of the following data types is more commonly called Boolean?

a) Yes/No
b) Date/Time
c) Hyperlink
d) Attachment
e) No one above
ANSWER:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 112


a) yes/No

PART II: FREQUENTLY ASKED QUESTIONS OF SECTION B AND C.

360) List ten components inside computer case.


ANSWER:
1. Motherboard
2. CPU/Processor
3. RAM
4. Hard drive
5. Power supply unit
6. Expansion cards
7. Video card
8. Sound card
9. Network card
10. Fan
361) Write a VB program that would enable the user to enter student marks in three subjects. The
program should calculate mean marks and determine whether the student has passed if the pass
mark is 50%.

ANSWER:

Private Sub Command1_Click() // Command for Compute


Dim mark1, mark2, mark3, average As Double
mark1 = Val(Text1.Text)
mark2 = Val(Text2.Text)

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 113


mark3 = Val(Text2.Text)
average = (mark1 + mark2 + mark3) / 3
Text4.Text = average
If (average >= 50 And average <= 100) Then
Label5.Caption = "Pass class"
ElseIf (average < 50 And average >= 0) Then
Label5.Caption = "Fail class"
Else
Label5.Caption = "Invalid class"
End If
End Sub

Private Sub Command2_Click() //Command for Clear


Text1.Text = " "
Text2.Text = " "
Text3.Text = " "
Text4.Text = " "
End Sub

362) Write a program that calculate the Roots of a Quadratic Equation: ax2 +bx +c in C++ using
pointers.

ANSWER:

#include <iostream>
#include<math.h>
using namespace std;
intmain()
{
float a, b,c; float x,x1,x2,delta;float *aptr;float *bptr;float *cptr;
aptr=&a;
bptr=&b;
cptr=&c;
a=*aptr;
b=*bptr;
c=*cptr;
//calculate delta
delta=*bptr * *bptr -4 * *aptr * *cptr;
x1=(-*bptr + sqrt(delta))/(2* *aptr);
x2=(-*bptr - sqrt(delta))/(2* *aptr );
cout<<"x1="<<x1<<endl;
cout<<"x2="<<x2<<endl;
getch();
return 0;
}
363) Compare Database Management System and traditional File processing system

ANSWER:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 114


364) Write an algorithm that receives two numbers and informs the user whether their product is
positive ,negative or null.

ANSWER:
SET a, b As Integer
START
WRITE("enter 1st number")
READ(a)
WRITE("enter 2nd number")
READ(b)
If (a * b) > 0 Then
WRITE( "The product is positive")
Else If (a * b) = 0 Then
WRITE( "the product is null")
Else
WRITE( "the product is negative")
End If
END
OR

START
SET a, b,product As Integer
WRITE("enter 1st number")
READ(a)
WRITE("enter 2nd number")
READ(b)
Product=a*b
If product > 0 Then
WRITE( "The product is positive")

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 115


Else If (a * b) < 0 Then
WRITE( "the product is negative ")
Else
WRITE( "the product is null ")
End If
End

365) Write codes of VB 6.0 program which displays the Sum and Average of numbers ranging
from 0 to 10 use do..loop until.

ANSWER:

Dim i As integer
Dim Sum,Av As double
Private Sub command-click()
Sum=0
i=0
Do
Sum=Sum+1
i=i+1
Loop until i>10
Av=Sum/11
text1.text=Cstr(Av)
text1.text=Cstr(Sum)
End Sub

366) a) Define the term Access modifier


b) What is the difference between public, private, and protected access modifiers?

c) Write a java application that asks the user to enter two integers, obtains them from the
user and displays the larger number followed by the words “is larger”. If the numbers are equal,
print “These numbers are equal”

ANSWER:
a) Access modifiers (or access specifiers) are keywords in object-oriented languages that set the
accessibility of classes, methods, and other members

b)
Modifier Description
Default declarations are visible only within the
package (package private)
Private declarations are visible within the class only

Protected declarations are visible within the package or


all subclasses
Public declarations are visible everywhere

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 116


c)
import java.util.Scanner;
public class LagestNumber {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
int x, y, Largest;
System.out.printf("Enter first number:");
x=input.nextInt();
System.out.printf("Enter second number:");
y=input.nextInt();
if (x>y){
Largest=x;
System.out.printf("%dIs larger", Largest);}
else if (x<y){
Largest=y;
System.out.printf("&dIs larger", Largest);
}
else{
System.out.printf("Numbers are equal");
}}}
367) What is a control? Give three examples.

ANSWER:
A control is a tool on the toolbox window that you place on a form to interact with the user and
control the program flow.

Examples: textbox, label, command button


368) List four different types of web browsers.

ANSWER:
 Mozila Firefox
 Safari
 Internet Explorer
 Opera
 Google Chrome
 Netscape navigator/ netscape
369) Provide only five examples of software which can be used in database creation and
maintenance.

ANSWER:
SQL, MySQL, Ms Access, Foxpro, Oracle
370) What are three types of access specifier? Explain each other.

ANSWER:

Private members of a class are accessible only from other members of the same class or
from their friend classes

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 117


Protected members are accessible from members of their same class and friend classes
and also from members of their derived classes.
Public members are accessible from anywhere the class is visible
371) If you were a database administrator (DBA), what measures would you put in place to
ensure the safety of information in the company database?

ANSWER:
Perform daily backup
Perform daily database maintenance
Perform database authentication for database users
Install antivirus software
372) What does E-commerce mean?

ANSWER:
Electronic commerce (e-commerce) consists primarily of the distributing, buying, selling,
marketing, and serving of products or services over electronic systems such as Internet and other
computer networks.

373) Write down:

a)An algorithm to compute 100 factorial (100!).

ANSWER:
var x, factorial as numeric
start
factorial ←1to 100
factorial =factorial*x
x ←x+1
Write(The factorial is: factorial)
End
b)a program in C++ to compute 100 factorial (100!).

ANSWER:
#include<iostream>

Using namespace std;

Int main () {

Int a, factorial=1;

For(a=1; a<= 100; a++)

Factorial=factorial*a;

Cout<<” The factorial of 100 =”<<factorial<<endl;

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 118


Return 0;}

374) Write a C++ Program that accepts three digits and displays on the screen the product of the
three numbers.

ANSWER:
#iclude<iostream>

Using namespace std;

Int main () {

Int x,y,z, product;

Cout<<” Enter the values of x,y, and z: ”<<endl;

Cin>>x>>y>>z;

Product=x*y*z;

Cout<<” The product = ”<<product<<endl; Return 0;}

375) a) What is a table in SQL?

ANSWER:

The table is a collection of related data entries and it consists of columns and rows

b) Name and explain the types of identifiers.

ANSWER:

1) The simple identifier

An identifier is known as simple if it consists of only one property. The example it is with in the
entity CUSTOMER.

2) Composite identifier

An identifier is known as made up if it consists of two parts or more (more property).

3) Relative identifier

An entity has a relative identifier on if it consists in part of a property belonging to another


entity. The relative identifier is a characteristic of the weak entities.

4) Weak entities

An entity B is known as weak it can be only identified by an identifier of another entity A such
as A and B is in association.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 119


376) Write a C++ program to read through an array of any type. Write a C++ program to scan
through this array to find a particular value.

Answer:

#include<iostream.h>

#include<stdlib.h>

Main(){

Int ara[10]

Int i, n;

Cout<<”Enter 6 numbers : \n”;

For (i=0; i<6; i++)

Cin>>ara[i]

Cout<<” PLEASE ENTER NUMBER TO BE TEST :\n”;

Cin>>n;

For(i=0; i<6; i++)

If(ara[i]==n)

Cout<<” THE NUMBER IS FOUND”;

Exit(0);

Else

Cout<<” THE NUMBER IS NOT FOUND”;

}}

377) a) What is a file system ?

ANSWER:

File systems are the structures behind how your computer stores and organizes data.

Everything you install, save, edit or create on computer comprise the trillions of bits of data a file

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 120


system stores, organizes, and allows access to on a daily basis for computer users.

b)List four activities that an Operating System does / operate for file management

ANSWER:

 Keeps track of information, location, uses, status etc. The collective facilities are often
known as file system.
 Decides who gets the resources.
 Allocate the resources
 De-allocates the resources

c) What are the functions of a file system?

ANSWER:

The file system is responsible for organizing files and directories, and keeping track of which
areas of the media belong to which file and which are not used.

378) a) Write a function program in C ++ programming language to multiply two numbers.

ANSWER:

#include<iostream>
using namespace std;
int mult(int a, int b)
{
int c;
c=a*b ;
return(c);
}
int main()
{
int x, y, z;
cout<<" enter any two numbers : "<<endl;
cin>>x>>y;
z=mult(x,y);
cout<<"Product = "<<z<<endl;
return 0;}
b) The scope and lifetime of the variables defined in C is classified depending on the storage.
Give 3 classes of storage variables.

ANSWER:

The three storage classes of variables are:

Automatic variable

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 121


External variable
Static variable
Register variable

379) Using a switch, write an algorithm which receives a student name and tells him his grades
as follows:

Note 16 and above : Grade A

Note 14- 16 : Grade B

Note 12-14 : Grade C

Note below 12 : Grade D

ANSWER:

Var note as integer

Start

Write("GRADE MENU:”)

Write("Use numbers to make your choice:”)

Write("note from 16 and above, enter 1”)

Write("note 14 to 16 enter 2”)

Write("note 12 to 14 enter 3”)

Write("note less than 12 enter 4”)

Write("enter a number to see your grade”)

Read(note)

Switch(note)

Case 1

Write("You have Grade A”)

Case 2

Write("You have Grade B”)

Case 3

Write("You have Grade C”)

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 122


Case else

Write("You have Grade D”)

End switch

End

380) List and explain the functions of 10 internal components of computer.

ANSWER:

Power Supply changes normal household electricity into electricity that a computer can use.

Expansion Card lets you add new features to a computer.

Motherboard is the main circuit board of a computer. All computer components are attached to
the motherboard.

Random Access Memory (RAM) temporarily stores information inside a computer. The
information is lost when computer is turned off.

Drive Bay is the space inside the computer case where a Hard drive, Floppy drive or CD-ROM
drive sits.

Hard Drive is the primary device that a computer uses to store information.

Expansion Slot is a socket on the motherboard that Expansion Card plugs into.

Central Processing Unit (CPU) processes instructions, performs calculations and manages the
flow of information through a computer.

CD-ROM Drive reads information stored in Compact Discs (CDs).

Floppy Drive stores and retrieves information on Floppy Disks.

381) Write visual basic program to calculate factorial of a number using function

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 123


ANSWER:

Public Function fact(n As Integer, i As Integer) As Integer


fact = 1
For i = 1 To n
fact = fact * i
Next i
End Function
Private Sub Command1_Click()
Dim K As Integer
Dim i As Integer
Dim f As Integer
K = Val(Text1.Text)
f = fact(K, i)
Text2.Text = f
End Sub

Private Sub Command2_Click()


Text1.Text = ""
Text2.Text = ""
End Sub

Private Sub Command3_Click()


Unload Me
End Sub

382) Draw a flowchart that takes radius as input to calculate and display the area of a circle.
ANSWER:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 124


383) Write an algorithm allows entering a number of students in a class and the marks obtained
by those students, then calculate the sum of those marks and their average and display the
number of students, the marks, sum and average on the screen.

ANSWER:

.var ,sum,,average as float


var i,n as integer
array marks(n) as float
START
WRITE(“enter the number of students ”)
READ(n)
WRITE(“enter the marks of students”)
FOR (i=0 TO n ) do
READ(marks(i))
End for
Sum=0

FOR (i=0 TO n) do
Sum=sum+marks(i)
End for
Average=sum/n
WRITE(“the number of students is”, n)
WRITE(“ the students’ marks are”,marks(i))
WRITE(“sum of those mark is”,sum)
WRITE(“average is”, average)
END

384) Write a C++ program using array to find the average marks obtained by 5 students.

ANSWER:

#<iostream.h>
void main()
{
Inti,Sum=0,marks[5];
float avg;
cout<<”enter marks”;

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 125


for(i=0;i<5;i++)
{ cin>>marks[i];
Sum=Sum+marks[i];
}
avg=Sum/5;
cout<<”The average is:”<<avg;
}

385)a) Write the following acronyms in full:


(i) HTML
(ii) XHTML

ANSWER:

(i) HTML - Hypertext Markup Language


(ii) XHTML - Extensible Hypertext Markup Language
b)Write down html code that print the following

First Name:
Last Name:
Password:

ANSWER:
<!DOCTYPE html>
<html>
<head>
<form>
<body>
First Name: <input type="text" name="firstname"/> <br/>
Last Name: <input type="text" name="lastname"/><br/>
<label for="password">Password: </label>
<input type="password" id="password" name="password"/><br/>
</body>
</form>
</head>

386) write program using an array to store 10 integers and show them.

ANSWER:
#include<iostream.h>
main()
{
int my_arr[5]; // name of array.
cout<<”\nEnter values at: “;
for(int i = 0 ; i < 10; i++)
{

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 126


cout<<”\n”<<i+1<<” :”;
cin>>my_arr[ i ]; //stores value at ith index.
}
for(int i = 0 ; i < 10; i++)
{
cout<<”\Number at ”<<i+1<<” :”<<my_arr[ i ]; //show value at ith index.
}
}
387) Compare the advantages and disadvantages of high-level languages.

ANSWER:

Advantages
High level languages are portable i.e. they are transferable from one computer to another.
High level languages are user friendly and easy to use and learn.
High level languages are more flexible, hence they enhance the creativity of the
programmer and increase productivity in the workplace.
A program in high level languages is easier to debug.

Disadvantages
Their nature encourages use of many instructions in a word or statement hence the
complexity of these instructions cause slower program processing.
They have to be interpreted or compiled to binary form before the computer can execute
them.
They require large computer memory to run.
388) Write an algorithm which receives two numbers and informs the user whether their product
is positive or negative.
ANSWER:

SET a, b As Integer
start
WRITE("enter 1st number")
READ(a)
WRITE("enter 2nd number")
READ(b)
If (a * b) > 0 Then
WRITE( "The product is positive")
Else If (a * b) = 0 Then
WRITE( "the product is null")

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 127


Else
WRITE( "the product is negative")
End If
End
389) Write an equivalent while loop for the following code:
Int sz=25;
for(int i=0,sum=0;i<sz;i++)
sum+=i;
System.out.println(sum);

ANSWER:

int sz=25;
int i=0,sum=0;
while(i<sz)
{
sum+=i;
i++;
}
System.out.println(sum);

390) List 5 access non modifiers in java


ANSWER:

Non-access modifiers do not change the accessibility of variables and methods, but they do
provide them special properties. Non-access modifiers are of 5 types,
Final
Static
Transient
Synchronized
Volatile

391) Explain the function of the following Stack Methods.

ANSWER:

Stack methods Description


push (); add/inserts new element/object into stack

pop (); removes and return top of the stack

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 128


peek (); returns top of the stack (just returns but doesn’t
remove unlike pop () operation

boolean empty (); check whether invoking stack is empty or not


returns true, if stack is empty; otherwise, false

392) What do you understand by network subnet?

ANSWER:

Network Subnet is logical division of the network and it is the strategy used to partition a single
physical network into more than one smaller logical sub network.

393) Writes VB.6 codes that display your entered full name on the form when the application is
loaded.

ANSWER:

Private sub command1_click ()


Dim name as string
Name=Inputbox (”enter your full name”)
Print “my full name is”; name
End sub
Or
Private sub form1_load ()
Form1.show
Print “RUBANGURA Simoni”

394) Predict the output of the following program

class SampleSwitch {
public static void main(String args[]) {
for(int i=0; i<6; i++)
switch(i) {
case 0:
System.out.println("i is zero.");
break;
case 1:
System.out.println("i is one.");
break;
case 2:
System.out.println("i is two.");
break;
case 3:
System.out.println("i is three.");
break;
default:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 129


System.out.println("i is greater than 3.");
}
}
}

ANSWER:

The output produced by this program is shown here:


i is zero.
i is one.
i is two.
i is three.
i is greater than 3.
i is greater than 3.

395) Write a java program where you declare the variables school, firstname, lastname, age,
level and combination. This program should display like this: Gs Kigali, Ange Batoni is 19 years
old and in senior 4 of LKK.

ANSWER:

package education;
public class education{
public static void main(String[] args) {
String school=”GS Kigali”, firstname = “Ange”, lastname= “Batoni”;
String level=”senior4”;
String combination=”LKK”;
int age =19;
System.out.println(school+””+firstname+” “+lastname+” “+”is”+” “+age+”years old and
in”+level+”
“+”of”+” “+combination);
}}

396) Using Visual Basic, write a program that prompts a user to enter a student’s score in
Mathematics. If the score is above 45%, the program should display “Pass” otherwise it should
display “Fail” .

ANSWER:
Private Sub Command1_Click()
Dim mark As Single
mark = Val(Text1.Text)
If (mark > 45 And mark <= 100) Then
Label3.Caption = “Pass”
ElseIf (mark <= 45 And mark >= 0)
Then
Label3.Caption = “Fail”
Else
Label3.Caption = “Invalid”

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 130


End If
End Sub

397) Write a class in C++ called person which has 2 functions: getdata() and putdata(). The
getdata() prompts the user to enter his or her first name name, last name and age, the putdata()
displays on the screen the user first name last, name and age.

ANSWER:

#include<iostream>
using namespace std;
class person
{
private:
char
fname[20],lname[20];
int age;
public:
void getdata()
{
cout<<”enter the first name, last
name and age”;
cin>>fname>>lname>>age;
}
void putdata()
{
cout<<”First
name: “<<fname<<endl;
cout<<”Last
name: “<<lname<<endl;
cout<<”age:
“<<age<<endl;
}
};
intmain()
{
person a1;
a1.getdata();
a1.putdata();
return 0;}

398) Explain how you can care your laptop.


ANSWER:

Always place your laptop on a level surface.


Wash your hands before using the computer.
Fluids are the number one enemy of electronic items so it is best not to eat or drink while
working on the laptop.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 131


If liquid spills on the keyboard, turn the keyboard upside down to drain for at least 12
hours before powering on again.
Never put personal data or programs that can’t be easily recovered on your laptop.
Your laptop may, someday, unexpectedly require service. Your personal data will not be
protected if this happens and you could lose your data.
Don’t save passwords on your laptop.
Use a password that is easy for you to remember (but not easy for someone else to guess)

399) Give and explain 7 advantages and 3 disadvantages of database management system.
ANSWER:

The Database Management system (DBMS) is a referred to as a software system that is used to
store, access, manage, organize, maintain, modify and delete data from databases.

Advantages Database Management System environment

 Reduce data redundancy: Data redundancy refers to the duplication or repetition of


data. The database system is used to eliminate the problems of data redundancy and data
inconsistency.
 Data integration: Data integrity means that the data contained in the database is both
accurate and consistent.

 Data Independence: Data independence means that programs are isolated from changes
in the way the data are structured and stored.
 Reduce data inconsistency: Actually, data redundancy and data inconsistency
interrelated. If data redundancy is controlled, then data inconsistency will also be controlled
automatically. Data inconsistency means different copies of the same data will have different
values.
 Data sharing: Due to the fact that data is centralized, many different users from different
locations can share data.
 Data recovery after a crash (a break down): DBMS allows recovering data after a
crash. The crash may depend on power failure or hardware failure.
 Concurrent transaction control: A transaction means a collection of operations that
perform a single action in a database.
 Increased Data security and safety: DBMS allows data to be highly protected against
unauthorized access.

The disadvantages of the database approach are summarized as follows:


1. Complexity: The provision of the functionality that is expected of a good DBMS makes the
DBMS an extremely complex piece of software.
2. Size: The complexity and breadth of functionality makes the DBMS an extremely large piece
of software, occupying many megabytes of disk space and requiring substantial amounts of
memory to run efficiently.
3. Performance: Typically, a File Based system is written for a specific application, such as
invoicing. As a result, performance is generally very good.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 132


4. Higher impact of a failure: The centralization of resources increases the vulnerability of the
system. Since all users and applications rely on the availability of the DBMS, the failure of any
component can bring operations to a halt.
5. Cost of DBMS: The cost of DBMS varies significantly, depending on the environment and
functionality provided. There is also the regular maintenance costs.
6. Additional Hardware costs: The disk storage requirements for the DBMS and the database
may necessitate the purchase of additional storage space.
7. Cost of Conversion: In some situations, the cost of the DBMS and extra hardware may be
insignificant compared to the cost of converting existing applications to run on the new DBMS
and hardware.
400) Write the pseudocode of the program that will ask user to enter the length and width as
inputs to calculate and display Area and perimeter of rectangle.
ANSWER:
Begin
Set L, W, Area, Perimeter
Write “Enter length and width”
Read L, W
Area = L*W
Perimeter = 2*(L+W)
Write Area
Write perimeter
End

401) Discuss common uses of laptop computer in schools and society in general.

ANSWER:
Laptop is used in:
- Education field (example: Laptops are used by teachers in preparation of teaching and learning
materials)
- Medicine field (example: Laptops are used by doctors to keep patient records)
- Business field (Electronic commerce uses Laptops for example in marketing and selling
products or good and services.)
- Accessing online services (example: National ID application at www.irembo.gov.rw)
- Entertainment field (example: Playing games and watching movies while traveling)
- Communication field (example: when you send and receive an email in a public place)
- Security field (example: Laptop can be used to fight against hackers: people who access
personal information without authorization of the owner. Notice that accessing of personal
information without permission is punishable crime).

402) Write a C++ program that calculates the area and circumference of circle.

ANSWER:

#include<iostream>

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 133


using namespace;
int main()
{

Double radius, area, circumference;

Const double pi=3.14;

cout<<”Enter radius”<<endl;
cin>>radius;
area =radius*radius*3.14;
circumference=radius*2*3.14;
cout<<”the area is”<<area<<endl;
cout<<”the circumference is<<circumference<<endl;
return 0;
}

403) Compare the disadvantages of fiber optic cables and the advantages of twisted pair cables.

ANSWER:

Disadvantages of fiber optic cables are:

 They are more expensive


 They are difficult to manipulate
 They are used in a long distance network
 They can hurt a human body because of their sharpened cable ends
 Very fragile
 Require more protection
 Not able to carry electrical power
 Not robust
Advantages of the twisted pair cables are:

 They are not expensive


 They are easy to bend (manipulate)
 Easy to make-up
 They can be used in a short network
 They don’t require much knowledge in networking field as fiber optic cables
 They are mostly used in Cyber Café and in different schools network
 Very strong
 Robust
 Does not require more protection
 Able to carry electrical power
404) (a)Name different ADO Objects.

ANSWER:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 134


Different ADO object are: Adodc and Data objects.

(b)What is the difference in passing values ByRef or ByVal to a procedure?

ANSWER:

When you use By Val passing mechanism, Visual Basic copies the value of the underlying
programming element into a local variable in the procedure. The procedure code does not have
any access to element in the calling code.

Example: How By Val is being used

Private sub command1_click()

Dim Test as integer

Test = 120

TestFunction Test

MsgBox(Test)

End sub

Function TestFunction (By Val I as integer)

i= i+1

End Function

Output: 120

Whereas when you use By Ref passing mechanism, Visual Basic gives the procedure a direct
reference to the underlying programming element in the calling code.

Example: How By Ref is being used

Private sub command1_click()

Dim Test as integer

Test = 120

TestFunction Test

MsgBox(Test)

End sub

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 135


Function TestFunction (By Ref i as integer)

i= i+1

End Function

Output: 121

(c) What is the difference between list box and combo box?

ANSWER:

List Box: is used to display a list of items where only one choice is allowed.

Combo Box: User can select / choose an item from the list or enter a value.

405) Write an algorithm that request a user to enter his/her ages. If the ages are greater than 17
years old, the program displays “you are allowed to vote” otherwise “you are too young”.

ANSWER:
Var: age as integer
Begin:
Write(" Enter your age")
Read (age)
if (age>17) then
Write (" you are allowed to vote")
Else
Write (“you are too young”)
End if
End

406) Write an algorithm that read two numbers from keyboard and inform the user if the sum
of those numbers is odd or even.
ANSWER:

Var: a, b, sum as integer


Start
Write ("Enter any two numbers")
Read (a, b)
sum=a+b
if(sum %2==0) then
Write (Sum, “ : is Even”)
else
Write (Sum, “ : is Odd”)
End if

End

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 136


407) Write an algorithm program that receives three numbers entered by the user and find
Smallest Number.

ANSWER:
Var : n1, n2, n3 as double
Start
Write ( "Enter the first numbers: ")
Read ( n1)
Write ( "Enter the second numbers: ")
Read ( n2)
Write ( "Enter the third numbers: ")
Read ( n3)
if(n1 < n2 and n1 < n3) then
write (n1, " is the Smallest number)
else if(n2 < n1 and n2 < n3) then
write (n2, " is the Smallest number)
else if(n3 < n1 and n3 <n2) then
write (n3, " is the Smallest number)
else
write (" Invalid input ")
End if
End

408) Using a class, write a program to find the largest number in two numbers entered by the
user.

ANSWER:

#include<iostream>
Using namespace std;
Class biggest
{ private:
Int a,b;
Public:
Void input(); void display();};
Void biggest::input()
{cout<<”Enter two numbers: ”<<endl;
Cin>>a>>b;
}
Void biggest::display(){
If(a > b)
Cout<<”The biggest number is : ”<<a;
Else
Cout<<”The biggest number is : ”<<b;}
Int main (){
Biggest b;
b.input();
b.display();}

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 137


409) (a)Give at least five operators allowed in the WHERE Clause.

ANSWER:

Five Operators allowed in Where clause are:

 Equal(=)
 Not equal (?=)
 Less Than(<)
 Less than or equal (<=)
 Greater than (>)
 Greater than or equal(>=)
 Between
 Like
 In

(b)Complete the table below:

ANSWER:

1. Entity
2. Attribute
3. Key attribute or Primary Key
4. Relationship
5. Multi-valued attribute
410) Among 20 values given by a user, write an algorithm to display the values which are less
than their average.

ANSWER:

Var: i, n(20), sum, avg, avgbelow as integer


Start

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 138


Sum =0
For i←0 to 19 do
Write(“Enter 20 numbers:”)
Read(n(i))
Next i or i←i+1
End for
For i←0 to 19 do
sum←sum + n(20)
Next i or i←i+1
End for
For i←0 to 19 do
Avg = sum /20
Next i or i←i+1
End for
For i←0 to 19 do
If(n(i) < avg)
avgbelow←n(i)
End if
Next i or i←i+1
End for
Write (“The number less than their average is”, avgbelow)
End

411) Consider the following Entities and Relationships.

Country (con-code, name, capital)

Population (pop-code, population)

Country & Population are related with one-to one relationship.

Constraints: Primary key and country name should not be null.

(a)Create a Relation Data Base.

ANSWER:

CREATE TABLE Country(Con_Code varchar(10) PRIMARY KEY NOT NULL, Name varchar
(50) NOT NULL, Capital varchar (50));

CREATE TABLE Population(Pop_Code varchar(10) PRIMARY KEY NOT NULL, Population


int);

(b)Write queries for the following:

i)Give name and population of country whose Capital is ‘Kigali’.

ANSWER:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 139


Select Name, Population from Country, population where Capital =’Kigali’;

ii)Count the number of countries whose population is > 6,000,000.

ANSWER:

Select Count (Con_Code) from Country, Population where population> 6,000,000;

iii)Find the details of the country with the highest population.

ANSWER:

Select Con_Code, name Capital from Country, population where Population = (Select Max
(Population) from Population);

iv)Display country wise population details.

ANSWER:

Select * From Country, Population

412) Explain major types of computer software, their uses and examples.

ANSWER:

a) System software: system software coordinates the activities and functions of hardware and
software, and it controls the operations of computer hardware and provides an environment or
platform for all the other types of software to work in.
Ex: Microsoft window XP, Mac OS, Linux, Windows Vista, Ubuntu, Device drivers etc.

b) Application Software: Application software is what helps the user perform the user perform
the tasks of his/ her choice. They non essential software which are installed and run, depending
upon the requirements, in the environment provided by the system software. EX: MS Office,
Media players, Ms Access, Educational Software, Antivirus Software.
c) Programming software: is used to write, test, debug and develop other software programs
and applications.
Ex: c#,DEVC++,Compilers, IDE etc

413) Write an array program which ask user to enter ten elements and display them by using a
pointer.

ANSWER:
#include <iostream>
using namespace std;
int main()
{
int x[10];
int *ptr;
cout<<"Enter the array elements:"<<endl;
for(int e=0;e<10;e++)

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 140


{
cin>>x[e];
}
ptr = &x[0];
ptr = x;
cout<<"\n Display by using pointer:"<<endl;
for(int a=0;a<10;a++)
{
cout<<*ptr<<endl;
ptr++;
}
getchar();
return 0;}

413) Explain the following network topologies:


a) Bus topology
b) Ring topology
c) Star topology
d) Mesh topology
e) Hybrid topology

ANSWER:
a) Bus topology: Bus topology is a network type in which every computer and network device is
connected to single cable. When it has exactly two endpoints, then it is called Linear Bus
topology.

b) Ring topology: It is called ring topology because it forms a ring as each computer is
connected to another computer, with the last one connected to the first. Exactly two neighbors
for each device. In a Ring topology each device is connected directly to two other devices, one
on either side of it, to form a closed loop.

c) Star topology: In this type of topology all the computers are connected to a single hub or a
switch through a cable.

d) Mesh topology: It is a point-to-point connection to other nodes or devices. All the network
nodes are connected.

e) Hybrid topology: Hybrid, as the name suggests, is mixture of two different things. Similarly,
in this type of topology that integrate two or more different topologies to form a resultant
topology which has good points (as well as weaknesses) of all the constituent basic topologies
rather than having characteristics of one specific topology.

414) a) What is visual Basic?


b) Give and explain the components of visual basic IDE (integrated development
environment)

ANSWER:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 141


a) VISUAL BASIC is a high level and Event-driven Programming Language which evolved
from the earlier Disk Operating System (DOS) version called BASIC.
(BASIC means: Beginners' Allpurpose Symbolic Instruction Code).

b) The visual basic IDE is made up of the following components:


a. Menu Bar d. Tool Bar
b. Project Explorer e. Properties Window
c. Form Layout Window f. Tools Box

a)The Toolbox contains a set of controls that are used to place on a Form at design time thereby
creating the user interface area.

b)Form window
The form designer is the main window in the middle of the screen, in which we can design and
edit user interface

c)Code window or VB Editor


Each standard form has a code window in which the user can write to direct the behavior of a
control.

d)Project explorer
On the right side of the form design, just under the tool bar, is the Project Explorer window.

e)Properties Window
Properties are the attribute of controls. Every object has properties, for example a Pen, has its
Color, Metal Type, Ink Color, Type.

f)Menu Bar
This is where you can select actions to perform on all your project files and to access help.

g)Toolbar
It gives easy access to the menu-bar you use frequently.

415) Write an algorithm of a program that allows the user to enter(store) 24 elements in two
dimensional array

ANSWER:
BEGIN
SET a=Array[3][8] of Integer
Use variable i As integer
Use variable j As integer
WRITE “enter the array elements:”
FOR i=0 TO 2 DO
FOR j=0 TO 7 DO
READ a[i][j]
i=i+1

j=j+1
END FOR

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 142


END FOR
END

416) Briefly explain the evolution of programming languages. In each case, identify the
generation and languages used.

ANSWER:
Evolution of programming languages:
(a) First generation – machine languages.
(b) Second generation – assembly languages.
(c) Third generation – Pascal, C, COBOL, BASIC, FOTRAN, Ada.
(d) Fourth generation – Visual Basic, Delphi Pascal, Visual COBOL etc.
(e) Fifth generation languages – PROLOG, Mercury, LISP, etc.

417) Write a C++ program using an array to find the sum and average marks obtained by 5
students.

ANSWER:
#include<iostream>
using namespace std;
int main(){
int marks[5] ,i,sum=0;
float average;
cout<<"Please enter five marks:"<<endl;
for (int i = 0; i<5; i++){
cin>>marks[i];
}
for (i = 0; i<5; i++){
sum=sum+marks[i];
}
average=sum/5;
cout<<"Sum = "<<sum<<endl;
cout<<"Averages Marks= "<<average<<endl;
return 0;
}

418) Discuss advantages and disadvantage of using computer network.


ANSWER:

Advantages of Computer Network


 It enhances communication and availability of information.
 It allows for more convenient resource sharing.
 It makes file sharing easier.
 It is highly flexible.
 It is an inexpensive system.
 It increases cost efficiency.
 It boosts storage capacity.

Disadvantages of Computer Network

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 143


 It lacks independence.
 It poses security difficulties.
 It lacks robustness.
 It allows for more presence of computer viruses and malware.
 Negative usage promotes negative acts.
 It requires an efficient handler.
 It requires an expensive set-up.

419) Make a flowchart to input temperature, if temperature is less than 320 then print “Below
freezing” otherwise print “Above freezing”.

ANSWER:

420) Write a VB Code for the command button to verify if the entered number is odd or even.

ANSWER:

Private sub command1_click()


Dim x as integer
x = val(Text1.Text)
If x Mod 2 = 0 Then
MsgBox "This is an even number you entered"
Else
MsgBox "You entered the odd number"
End If
End sub

421) Discuss SQL as:


a. Data definition Language (DDL)
b. Data manipulation Language (DML)

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 144


c. Data Control Language (DCL)

ANSWER:
a) Data definition Language (DDL):

This part of SQL enables the creation of tables and relationship between those tables in a
database.
The most important DDL statements in SQL are:
 CREATE DATABASE - creates a new database
 ALTER DATABASE - modifies a database
 CREATE TABLE - creates a new table
 ALTER TABLE - modifies a table
 DROP TABLE - deletes a table
 CREATE INDEX - creates an index (search key)
 DROP INDEX - deletes an index
b) Data manipulation Language (DML).
This part of SQL enables to select, insert, update, and delete data in a table in a database
c) Data Control Language (DCL).

With this part of SQL it is possible to Grant or remove permissions to users in a database.

422) a) What protocol means in computer.


b) Give and Explain any five (5) Network protocol you know.
c) What are classes of IP address and their range?

ANSWER:
a) A protocol is defined a set of rules and procedures that control communication between
computers or other network devices on a network.

b)Internet control message protocol (ICMP)


Internet Control Message Protocol (ICMP) is used by devices on a network to send control and
error messages to computers and servers.

HTTP (Hypertext Transfer Protocol)


e.g. http://www.reb.rw/
http: stands for hypertext transfer protocol used to connect computer to the server. It provides a
standard web browser to communicate with a server FTP (File Transfer Protocol) This protocol
allows you to transfer files between two computers on internet.
TCP and UDP
Transmission Control Protocol and User Datagram Protocol are most common transport layer
both protocols that manage the communication of multiple applications.
POP (Post Office Protocol)
Post Office Protocol is a protocol designed to allow single user computer to retrieve electronic
mail from a POP server via TCP/IP.
URL
URL stands for Uniform Resource Locator. A URL is a webpage address which is a formatted
text string used by web browser, email client or other software to identify a network resource on
the internet.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 145


SMTP (Simple mail Transfer protocol)
The SMTP stands for Simple mail Transfer protocol is a TCP/IP used in sending and receiving
emails. (5marks; 1mark for each protocol)
c)

423) Write Java program to allow the user to input his/her age. Then the program will show if
the person is eligible to vote or not. A person who is eligible to vote must be older than or equal
to 18 years old.

ANSWER:
import java.util.Scanner;
public class Voting {
public static void main(String[] args){
int age;
Scanner Value=new Scanner(System.in);
System.out.print("What is your age?");
age=Value.nextInt();
if(age>=18)
{
System.out.print("you are eligible to vote");
}
else
{
System.out.print("you are not eligible to vote");
}}}

424) Using switch case writes an algorithm which grades the students.

MARKS GRADES
18 and above A
from16 to18 B
From14 to16 C
from12 to14 D
from10 to12 E
Below 10 fail

ANSWER:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 146


BEGIN
SET number AS character
PRINT (“enter 1 for marks 18 and above”)
PRINT (“enter 2 for marks from16 to18 ”)
PRINT( “enter 3 for marks from 14 to16 ”)
PRINT (“enter 4for marks from 12 to 14”)
PRINT (“enter 5for marks From10to12 ”)
PRINT( “Enter your choice”)
READ number;
SWITCH(number)
CASE of 1:
PRINT “grade is A”
CASE of 2:
PRINT “grade is B”
CASE of 3:
PRINT “grade is C”
CASE of 4:
PRINT “grade is D”
CASE of 5:
PRINT “grade is E”
DEFAULT:
PRINT “Fail”
END SWITCH
END

425) Rewrite the following code fragment so that it uses a” do….while” loop to accomplish the
same task.
int n;
Cout<<”Enter a non – negative integer :”<<endl;
cin>>n;
While(n < 0){
Cout<<”The integer you entered is negative .”<<endl;
n++;
}
ANSWER:

int n;

do{
cout<<"Enter a non - negative integer :"<<endl;
cin>>n;

if(n < 0)
cout<< " The integer you entered is negative."<<endl;
}while(n < 0);

426) With short explain give three Advantages and two Disadvantages of the Internet.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 147


ANSWER:

a)Advantages of Internet

E-mail: With e-mail you can send and receive instant electronic messages, which work like
writing letters.

Access Information: The search engines on the Internet can be help you to find data on any
subject that you need.

Shopping: With the Internet you do not need to leave your house and can do all your shopping
from the convenience of your home by using credit card.

Online Chat: The web can be accessed to meet new people, make new friends, as well as to stay
in touch with old friends.

Downloading different materials (items): you can download innumerable games, music ,
movies, videos , software programs and a host of other entertainment software from the Internet.

b) Disadvantages of Internet

Personal Information: If you use the Internet, your personal information such as your names,
address, etc. can be accessed by other people. If you use a credit card to shop online, then your
credit card information can also be stolen.

Pornography: There are thousands of pornographic sites on the Internet that can be easily found
and can be a detriment to letting children use the Internet.

Spamming: This refers to sending unsolicited e-mails in bulk, which serve no purpose and
unnecessarily clog up the entire system.

427) Explain objects, classes and clients? How do clients and components communicate?

ANSWER:

(a)In Object oriented approach to programming, any problem that is to be solved is divided into
objects.

(b)The set of data and the code to manipulate that data is known as a class.

The class is the plan for how to process information about a particular logically grouped data and
actions on that data.

(c)The term client may be defined as a program or a component which uses another component.

(d)The communication between the client and component is carried out through an Interface.

428) Give the meaning of the following queries (one line of explain is required).

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 148


(a)Select * from avion capacite < 350

union

select * from avion where localization = ‘Nairobi’;

ANSWER:

Aircrafts which have a capacity less than 350 passengers or localized in Nairobi.

(b)Select * from Vol where ville_dep = ‘Nairobi’

Intersect

Select * from Vol where ville_arr = ‘Kigali’

Intersect

Select * from Vol where h_dep > 6 PM;

ANSWER:

Flights departing from Nairobi to Kigali after 6 PM.

429) Why is a hard disk technically 80 GB but the operating system treats it as 72 GB?

ANSWER:

The computer is not exact to begin with, but it calculates the 72.72 GB’s by referencing that 1
KB equals 1024 bytes, then 1024 bytes multiplied by 1024 bytes which equals:

1,048KB or 1MB and then a gigabyte in turn equals 1,048 KB multiplied by 1,048 KB which in
turn equals 1,099.5 or 1100MB.

So if we were to calculate that out according to the computers determinations of 80GBs, we


would divide the 80.000MB that are on the hard drive by 1100MBs that the computer estimates
to be 1GB and we get: 72.72GBs.

430) a) Differentiate parallel processing from serial processing in computer system


(b) Discuss the three types of computer based on their functions.

ANSWER:

a)Serial processing is a type of processing in which one task is completed at a time and all the
tasks are executed by the processor in a sequence. while
Parallel processing is a type of processing in which multiple tasks are completed at a time by
different processors
b)Regardless of the size and processing power, a computer can be classified according to
functions they perform. In this case, we have servers, workstations and embedded computers.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 149


Servers and workstations are general purpose computers used to provide access to resources on a
network while special purpose computers are dedicated to a single task.

(i) A server
A server is a dedicated computer that provides hardware or software resources to other
computers on a local area network (LAN) or over the Internet
(ii) Workstation
A workstation is a name given to a computer connected to a server or network intended to be
used by one person at a time, they are commonly connected to a server.

(iii) Embedded computers


Embedded computers are computing devices designed for a specific purpose. Generally, an
embedded computer has an operating system that only runs a single application. Examples of
embedded computing devices include dishwashers, ATM machines, MP3 players, routers, and
point of sale POS terminals.

431) Write a C++ program that allows the user to enter marks for three subjects. The program
should calculate, then display the total and mean score of the three subjects.

ANSWER:
#include <iostream>
using namespace std;
int main() {
int a, b, c, sum;
double mean;
cout <<"Enter 1st number:" << endl;
cin >> a;
cout <<"Enter 2nd number:" << endl;
cin >> b;
cout <<"Enter 3rd number:" << endl;
cin >> c;
sum = a + b+c;
mean = sum/3;
cout <<"Sum = "<< sum << endl;
cout <<"Mean = "<< sum << endl;
return 0;
}

432) Describe any 5 common functions of operating system.

ANSWER:

(a) Booting: The operating system is responsible for completing booting process of the
computer. Booting is starting or restarting the computer.

(b) The operating system provides an appropriate User interface: The interface enables the
user to interact with the computer software and hardware. The user interface can be Command-
line interface (CLI) or Graphical user interface (GUI). With CLI, the user interacts with OS by
typing in commands at the command prompt to perform specific tasks

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 150


(c) Operating system manages resource allocation to various programs: The operating
system loads programs in computer’s primary memory, runs them and allocates them run-time,
memory space, processor time, input/output devices and instructions to use.

(d) Memory management: The OS organizes how the primary memory is used by different
programs through partitioning.

(e) Manages user’s files: The OS manipulates how files are created, stored and retrieved using
file system

(f) Operating system controls input/output peripherals: The operating system manages
reading from the input peripheral devices and writing to all peripheral devices
(g) Operating system manages files: Operating System supervises the creation, storage,
updating and deletion of files to various storage devices e.g. hard disk, flash disk, etc.

(h) Operating system manages backup storage (secondary storage or auxiliary storage).
Operating system locates and retrieves files needed by user from backup storage and monitors
how they are used.

(i) Operating system manages security and access rights of computer users. In this case, the
operating system monitors the creation of passwords, user names or account names on a
computer. It also keeps record of who accesses the computer, the activities done and the
resources used.

(j) Operating system handles errors as they happen. When the computer is used, without user
intervention or knowledge. It can suggest to the user what to do to correct errors through error
messages.

433) Write a program that calculates the Roots of a Quadratic Equation: 2x2 +6x +4 in C++
using pointers.

ANSWER:
#include<iostream>
#include<cmath>
#include<conio.h>
using namespace std;
int main ()
{
float a=2, b=6,c=4;
float x,x1,x2,delta;
float *aptr;
float *bptr;
float *cptr;
aptr=&a;
bptr=&b;
cptr=&c;
a=*aptr;
b=*bptr;

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 151


c=*cptr;
//calculate delta
delta=*bptr * *bptr - 4 * *aptr * *cptr;
x1=(-*bptr + sqrt(delta))/(2* *aptr);
x2=(-*bptr - sqrt(delta))/(2* *aptr );
cout<<"x1="<<x1<<endl;
cout<<"x2="<<x2<<endl;
getch();
return 0;}

434) Draw a flowchart that prompts for five numbers, and then calculates sum and average. The
computer should display total sum and average of the five numbers.
ANSWER:

435) (a) What were the 2 main characteristics of first generation computers?

ANSWER:

The main characteristics of first generation of computers (1940s-1950s) are:


 Power consumption – they used to consume a lot of electricity and generate a lot of heat.
 Speed : very slow
 Size: very large in size (often taking up entire room).
 Input/output devices – punched cards and paper tape.
 Main electronic component – vacuum tube

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 152


 Main memory – magnetic drums and magnetic tapes
 Programming language – machine language
 Examples – ENIAC, UNIVAC1, IBM 650, IBM 701, etc.
 Quantity – there were about 100 different vacuum tube computers produced between
1942 and1963.

(b) Briefly, discuss how integrated circuits contributed to the development of microcomputers.

ANSWER:
Integrated circuits serve a crucial function in the history of scientific inventions and the
advancement of technology as a whole. Reducing the size of critical computing components of
varying types paved the way for the creation of a multitude of other devices. Without the
integrated circuit there might not be the slim smartphones everyone carries in their pockets, cars
might not have many of the bells and whistles that come standard in most models, and many
other technologies we consider conveniences and part of everyday life may either not exist or
look completely different.

436) Explain any five Features of C++

ANSWER:

Features of C++
 Portability: Programs written in C++ are portable across multiple hardware and software
platforms.

 Object-oriented programming: The design goal of C++ is to support object-


oriented programming. As mentioned earlier, instead of using function that access global
variables, both data and variables are encapsulated into an object.

 Keywords: Keywords also referred to as reserved words are words that have special
meaning in a language and can only be used for intended purpose. C++ has a large number of
reserved words such as include, main, while, for, if, else and return.

 Identifiers: In C++ programming, identifiers are symbolic names used to identify


elements like variables and constants in a program. Because C++ s case sensitive, it
is important to observe caution when creating user-defined identifiers.

 Operators: Operators are used to evaluate an expression that returns a value.

 Storage in memory: In C++ a variable is a named storage location in computer memory


for holding data of a particular type.

 Case sensitive: C++ is case-sensitive. This means that an identifier (symbolic


name) in uppercase is different from the same identifier in lowercase.

 Type checking: C++ provides a rules and mechanism for checking data types before
execution starts

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 153


437) Write algorithm that calculate and display the sum and average of 4 numbers entered by
user.

ANSWER:
Var A[4], x ,sum as integer
Var average as float
Begin
Sum=0
Write(“enter numbers”)
For x =0 to 3
Read(A[x])
Sum=sum+A[x ]
Average=sum/4
Write(“the sum of entered numbers is:”, sum)
Write(“the average of entered numbers is:”, average)
End

438) In real life, we need to use a computer. Describe any 7 areas where a computer can be
applied.
ANSWER:

Economics
Computers enables governments, businesses and individuals to plan, budget and tract their
revenues and expenditures. Increased computing power means that it has become possible to
perform economic analysis both at macro and micro-economic level.

Retail stores
Most retail stores use computers to help in the management of daily activities like stock control.
The stock control system keeps account of what is in stock, what is sold and what is out of stock.
The management is automatically alerted whenever a particular item or items are running out of
stock that need reordering.

Offices

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 154


Computers have increased efficiency in offices by reducing the time and effort needed to access
and receive information. Most modern office functions have been automated for efficient service
delivery.

Financial institutions
In the banking sector, computers and mobile devices such as cellphones can be used to withdraw
or get any service from different branches. Special cash dispensing machines called automated
teller machines (ATM’s) have enabled automation of cash deposits and withdrawal services.
Efficiency has also been increased due to better record keeping and document processing
brought about by use of computers.

Industries
Computers are being used to monitor and control industrial processes.
The computer age has seen wide use of remote-controlled devices called robots.
Health
Computers are used to keep patients’ records in order to provide easy access to a patient’s
treatment and diagnosis history. Computerized medical devices are now being used to get a cross
sectional view of the patient’s body that enables physicians to get proper diagnosis of the
affected body parts with high levels of accuracy.

Communication
Integration of computers and telecommunication facilities has made message transmission and
reception to be very fast and efficient. Because of the speed with which information can be
transmitted around the world using computers, the world is said to have become a global village.

Security
Information stored in computers such as fingerprints, images and other identification details help
law enforcers carry out criminal investigations.

Education
Computers are used in teaching and learning in schools, colleges and universities. Learning and
teaching using computers is referred to as Computer Aided Learning (CAL) and Computer
Aided Instruction (CAI).

439) Write in Visual Basic a program to find the greatest of five numbers as shown below:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 155


ANSWER:

Private Sub Command1_Click()


Dim number()
Dim big, x As Integer
number = Array(15, 20, 45, 5, 10)
big = number(0)
For x = 0 To 4
If big < number(x) Then
big = number(x)
Next x

lblNumber = number(0) & "," & number(1) & "," & number(2) & "," & number(3) & "," &
number(4)
lblGreatest = big

End Sub

440) A “1.44 MB” floppy disk has 80 cylinder (numbered 0 to 79); 2 heads (numbered 0 to 1)
and 18 sectors (numbered 1 to 18). Calculate its capacity in sectors.

ANSWER:

Formula:

Total Storage Capacity of a Hard Drive=Total Number of Sectors*512 bytes per sector

Total Number Of Sector = Sector Per Side *Number of Heads

Sectors Per Side = Tracks Per Side *Sectors Per Track

Total Number of Sector = (80*18)*2 = 2880

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 156


Total Storage Capacity = 2880 *512 byte / sector= 1474560 bytes (1.44MB).

441) Formulate a C++ program which calculate sum of 20 float numbers received.

ANSWER:

#include<iostream>
using namespace std;
int main() {
int i;
float sum=0;
float num[20];
cout<<"enter any Twenty numbers: "<< endl;
for(i=0;i<20;i++){
cin>>num[i];}
for(i=0;i<20;i++){
sum =sum+num[i];
}
cout<<"The sum = " <<sum<< endl;
return 0;
}

442) Write a simple algorithm which will ask a user to input a value.
If the value is 1 it should display the text “The day is Monday”
If the value is 2 it should display the text “The day is Tuesday”
If the value is 3 it should display the text “The day is Wednesday”
Do the same for all days of a week.
Use the switch case statement to achieve the above

ANSWER:

Use x as integer
Start
Write “please enter number of day of week:”
Read x
Switch (x)
Case of 1:
Write “The day is Monday”
Case of 2:
Write “The day is Tuesday”
Case of 3:
Write “The day is Wednesday”
Case of 4:
Write “The day is Thursday”
Case of 5:
Write “The day is Friday”
Case of 6:
Write “The day is Saturday”

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 157


Case of 7:
Write “The day is Sunday”
Default:
Write “the invalid input!”
End switch
Stop

443) Given below the case of array marks as a:


a [0][0] 3 a [1][0] 11 a [2][0] 21
a [0][1] 10 a [1][1] 20 a [2][1] 22
a [0][2] 15 a [1][2] 14 a [2][1] 34
a [0][3] 12 a [1][3] 19 a [2][3] 38
a [0][4] 32 a [1][4] 18 a [2][4] 39
a [0][5] 17 a [1][5] 11 a [2][5] 33
a [0][6] 13 a [1][6] 25 a [2][6] 42
a [0][7] 27 a [1][7] 31 a [2][7] 45
a)Give the size of the above array,
b)Declare array a,
c)Initialize the above array,

ANSWER:
a) Array a [3][8] it has three column and eight row
b)
3 11 21
10 20 22
15 14 34
12 19 38
32 18 39
17 11 33
13 25 42
27 31 45

BEGIN
SET marks=Array[3] [8] of Integer
marks[0][0]=3
marks[0][1]=10

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 158


marks[0][2]=15
marks[0][3]=12
marks[0][4]=32
marks[0][5]=17
marks[0][6]=13
marks[0][7]=27
marks[1][0]=11
marks[1][1]=20
marks[1][2]=14
marks[1][3]=19
marks[1][4]=18
marks[1][5]=11
marks[1[6]=25
marks[1[7]=31
marks[2[0]=21
marks[2[1]=22
marks[2[2]=34
marks[2[3]=38
marks[2[4]=39
marks[2[5]=33
marks[2[6]=42
marks[2[7]=45
END

444) Explain the difference between Peer-to-Peer network and Client-Server Network

ANSWER:

Peer to Peer (P2P) network is a type of network in which two or more computers connect
without any centralized server. Each computer in P2P behaves like a client and server. Each
computer share resources and use resources of other computers in the network.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 159


Advantages of peer-to-peer network are as follows:

 The main advantage of peer-to-peer network is that it is easier to set up


 In peer-to-peer networks all nodes are act as server as well as client therefore no need of
dedicated server
 The peer-to-peer network is less expensive
 Peer to peer network is easier to set up and use this means that you can spendless time in
the configuration and implementation of peer-to-peer network.
Disadvantages of peer-to-peer network

 A computer can be accessed anytime


 Network security has to be applied to each computer separately
 Backup has to be performed on each computer separately
 No centralized server is available to manage and control the access of data.

Client-server network, the client requests information or services from the server and the server
provides the requested information or service to the client. Servers on a client-server network
commonly perform some of the processing work for client machines.

Advantages of Client-Server Network

 Centralization of control: Access, resources and integrity of the data are controlled by the
dedicated server so that a program or unauthorized client cannot damage the system.
 Scalability: You can increase the capacity of clients and servers separately. Any element
can be increased (or enhanced) at any time, you can add new nodes to the network (clients or
servers).
 Easy maintenance: Distribute the roles and responsibilities to several standalone
computers, you can replace, repair, upgrade, or even move a server, while customers will not be
affected by that change (or minimally affect).

Disadvantage of Client Server Networks

 There is a reliance on the central server, if it fails, no work can be done


 A network manager is required and this costs money

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 160


 The server costs money, as does the network operating system
 Servers are powerful, thus expensive
 Lots of network traffic.

445) Using a class, write a C++ program to find the largest number in two number entered by
the user.

ANSWER:

#include <iostream>
using namespace std;
class TwoNumbers
{
private:
int x;
int y;
public:
void input();
int largest();
void display();
};
void TwoNumbers::input()
{
cout<<"Enter two numbers: "<<endl;
cin>>x>>y;
}
int TwoNumbers::largest()
{
if(x > y)
return x;
else
return y;
}
void TwoNumbers::display()
{
cout<<"The largest number is : "<<largest()<<endl;
}
int main()
{
TwoNumbers n;
n.input();
n.display();
return 0;
}

446) a) Define database


ANSWER:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 161


Database is an organized collection of related data. Also it can be defined as a collection of one
or more relations, where each relation is a table made of rows and columns.
b) State five areas where databases is used

ANSWER:

Areas where database is used are:

1. Human resources: to track information about employees


2. Banking: to keep customer information, accounts, and loans, and banking transactions.
3. Airlines: to keep for reservations and schedule information. Airlines were among the first to
use databases in a geographically distributed manner -terminals situated around the world
accessed the central database system through phone lines and other data networks.
4. Universities: to keep student information, course registrations, and grades.
5. Credit card transactions: to keep purchases on credit cards and generation of monthly
statements.
6. Telecommunication: to keep keeping records of calls made, generating monthly bills,
maintaining balances on prepaid calling cards, and storing information about the communication
networks.
7. Finance: to keep storing information about holdings, sales, and purchases of financial
instruments such as stocks and bonds.
8. Manufacturing: to keep management of supply chain and for tracking production of items in
factories, inventories of items in warehouses / stores, and orders for items. Etc.
447) Describe the following term briefly.

a. Relationship set
b. One to many relationship
c. Many to many relationship
d. Participation constraint
e. Weak entity set.

ANSWER:
a)Relationship set: A relationship set is a set of relationships of the same type

b)One to many relationship: An instance of one entity can relate to multiple instance of another
instance. The relationship that associates one record of entity A to more than one record of entity
B is called one-to-many relationship.

c) Many-to-many (M: M): Multiple instances of an entity can relate to multiple instances of
another entity.
Example: Many teachers can teach many students

d)Participation constraint: The participation constraint specifies the number of instances of an


entity can participate in a relationship set

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 162


e)Weak entity set: The entity sets which do not have sufficient attributes to form a primary key

448) Write a VB program to display the following sequence of numbers


140,120,100,80,60,40,20,0

ANSWER:

Private sub form_activate()


Dim number as integer
For number=140 to 0 step-20
Print number
Next number
End Sub

OR

Private Sub form-Load()


Form1.show()
Dim number as integer
Number=140
While number>=0
Print number
Number=number-20
Wend
End Sub

449) Write a C++ program using class called Rectangle and an object called rect. This class
should have four members: two data members of type int with private access and two member
functions with public access: set_values() and area().Set_values() to initialize the values of
rectangle and area() to return the area of rectangle.

ANSWER:

#include <cstdlib>
#include <iostream>
using namespace std;
class rectangle{
int x,y;
public:
void set_values(int,int);
int area(){
int res;
res=x*y;
return(res);
}};
void rectangle::set_values(int a, int b)
{

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 163


x=a;
y=b;
}
int main (){
int t,v;
cout<<"enter values of a and b: "<<endl;
cin>>t>>v;
rectangle rect;
rect.set_values(t,v);
cout<<"area of rectangle is "<<rect.area()<<endl;
return 0;}

450) Write a java Program that will asks user to enter three numbers from keyboard and it
display the sum, and average of the entered numbers. if the average is below 50 it will give the
message “Fail” otherwise “Pass”.

ANSWER:

import java.util.Scanner;
public class sumavg {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter a first number: ");
int number1 = input.nextInt();
System.out.print("Enter second number: ");
int number2 = input.nextInt();
System.out.print("Enter Third number: ");
int number3 = input.nextInt();

sum= number1+number2+ number3;


avg=sum/3
System.out.println(“sum is :" +sum);
System.out.println(“average is:"+avg);
if(avg <50)
System.out.println( " Fail");
else
System.out.println( " Pass");
}
}

451) With short explanations give six advantages and four disadvantages of internet.

ANSWER:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 164


Advantages of Internet Disadvantages of Internet

 Communication  Waste Of Time

 Access To Resources & Instant


 Money Frauds
Information

 E-commerce, Digital Banking &


 Cyber Crime
Payments

 Collaboration & Donation And Funding  Isolation & Health Problems

  E Fake News & Spread of illegal


ntertainment & Lifestyle And Unethical material

 Online Education & Distant Learning  Security Threats

 Online Services, booking & Schedule &


 Addiction & Causes Distractions
Job Apply

 Video Conferencing & Screen Sharing  Pornographic and violent images

 Selling & Making Money  Not safe place for Children

452) Develop a VB program which displays the sum of numbers ranging from 0 to 10, use
do….loop until.

ANSWER:
Private Sub Form_Load()
Form1.Show
Dim i, sum As Integer
sum = 0
i=0
Do
sum = sum + i
i=i+1
Loop Until i > 10
Print sum
End Sub

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 165


453) Write a C +++ program that accepts three digits and displays on the screen the product of
the three numbers.

ANSWER:

#include<iostream>

using namespace std;

int main() {

int a, b, c, product;

cout<<"Enter any three numbers:"<<endl;

cin>>a>>b>>c;

product=a*b*c;

cout<<"Product =" <<product<<endl;

return 0;}

454) Write an algorithm and a C++ program to accept any given number and prove that the
given number is Odd or even.

ANSWER: A C ++ Program

Algorithm #include<iostream>

Variable num integer Using namespace std;

Start Int main () {

Write(“Enter any number”) Int num;

Read(num) Cout<<”Enter any number”<<endl;

If(num mod 2==0) then Cin>>num;

Write(“The given number is Even”) If(num%2 ==0){

Else Cout<<num<<”: is Even”<<endl;}

Write(“The given number is Odd”) Else{

End if Cout<<num<<”: is Odd”<<endl;}

End Return 0;}

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 166


455) What are the main tasks of an Operating System during the memory management?

ANSWER:

 Provides memory space for each processor.


 Protects process among them
 Allows memory sharing it it is necessary.
 Manager process swapping in memory portion
 Memory paging
 Memory partition
 Memory segmentation
 Virtual memory management

456) (a)State the Characteristics of memories.

ANSWER:

 Address
 Capacity
 Access time
 Memory circle
 Debit
 Volatility
 Bandwidth
 Access type
 Physical size
 Cost of Information

(b)Distinguish between the types of access to memories

ANSWER:

 Sequential Access: to access the information you must pass to all previous information.
 Direct Access: Each information has its own address allow to locate it directly(RAM).
 Semi-sequential Access: Is a combination between direct access and sequential access.
 Access by Content: Each information ID identified by research key (Selective Access).
 Random Access: The time to access any memory allocation is the same.

457) What are the main elements of the command unit which are used during memory searching
and instruction decoding (Research cycle)?

ANSWER:

 Program counter
 Timer(System lock)
 Instruction decoder

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 167


 Instruction Register
 Accumulator
 Base limiter
 State register

458) State and explain the characteristics of a good computer program.

ANSWER:

 The implementation is free of errors. The programmer must resort to methods such as
testing to establish the corrections of a program. i.e. program error file.
 The program is well documented. It is important that computer program be well
documented. Documentation exists to assist in the understanding of the uses of program. This
can be of great of value not only to those charged with maintaining or modifying a program, but
also the programmers themselves. Details particular programs or particular pieces of programs
are easily forgotten or confused without suitable documentation.
 The program is maintainable. Programs require a continuing process of maintenance and
modification to keep space with changing requirements and modifiability are essential
characteristics of a real program. A program’s ability to be read and understand is important
prerequisite to its maintainability and modifiability.
 The program must respect syntax.
 Header file: is a file which contains all elements of that need by the program for this
execution.
 Variable declaration: the variable to be used must be declared before they are used.
 Comments: are explications of the program.
 The functions are the principle elements that allow the execution of their instructions.
 Procedures=functions
 They must be correct without errors
 Modular
 Portability: (it must be potable) able to run very well or the big number of machine with
the different architecture.
 Comprehensible: must be understood by every one.

459) Write down:

(a)An algorithm to compute 100 factorial (100!).

ANSWER:

Var I, fact numeric

Start

fact←1 to 100

fact←fact*i

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 168


i ←i+1

write(The factorial is: Fact)

End

(b)A flowchart to compute 100 factorial (100!)

ANSWER:

(c)A program in C++ to compute 100 factorial (100!)

ANSWER:

#include<iostream>
using namespace std;
int main() {
int n=100;
double factorial = 1;
for(int i = 1; i <=n; ++i) {
factorial = factorial * i;
}
cout << "Factorial of "<<n<<" = "<<factorial<<endl;
return 0;
}

OR
//If the user is requested to input a number

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 169


#include <iostream>
using namespace std;
int main() {
int n;
double factorial = 1;
cout << "Enter a positive integer: "<<endl;
cin >> n;
for(int i = 1; i <=n; ++i) {
factorial = factorial * i;
}
cout << "Factorial of "<<n<<" = "<<factorial<<endl;
return 0;
}

460) By brief explanation enumerate the 5 properties of computer network.

ANSWER:

(a) Easy Sharing of Resources: Computers are able to share various resources easily over a
network. Shared resources can be Internet, files, printer, storage and others.

(b) Performance: It is achieved by measuring the speed of data transmission with number of
network users, connectivity used and the software used. The commonly measured qualities in the
network performance are Bandwidth and Latency.

(c) Reliability: It means that computer network provides assurance of the delivery of data to the
intended recipient.
(d) Scalability: The possibility of adding new computer without affecting the network
performance.

(e) Security: computer network must be secured for the benefit of the user and data protection.
The security is achieved by protecting data from unauthorized access.

(f) Quality of Service (QoS): Quality of Service refers to the mechanism that manage congested
network traffic.

(g) Fault tolerant: A fault tolerant network limits the impact of hardware or software failure and
recovers quickly when a failure occurs

461) Design a VB function program to find Factorial of an entered number.

ANSWER:
Private Sub Command1_Click()

Dim Num As Integer

Num = Val(InputBox(“Enter a number you want to calculate Factorial: “, “Number”))

Print (“ The factorial of “); Num

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 170


Print (“is: “); CalFact(Num)

End Sub

Function CalFact(ByRef Number)

Dim Fact As Integer

Fact = 1

For i = Number To 1 Step -1

Fact = Fact * i

Next i

CalFact = Fact

End Function

462) Write a java program to find the area of rectangle

ANSWER:

import java.util.Scanner;
class AreaOfRectangle
{
public static void main(String args[])
{

Scanner s= new Scanner(System.in);

System.out.println("Enter the length:");


double length = s.nextDouble();
System.out.println("Enter the width:");
double width = s.nextDouble();
double area= length * width;
System.out.println("Area of Rectangle is: " + area);
}}

463) Design a VB function to find the Maximum of three numbers.

ANSWER:

Private Sub Command1_Click()

Dim a, b, c, Big As Integer


a = Val(InputBox("Enter the first number", "Number1 "))
b = Val(InputBox("Enter the second number", "Number2 "))

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 171


c = Val(InputBox("Enter the third number", "Number3 "))
Big = FindMax(a, b, c)
Print ("The maximum number is:"), Big
End Sub
Function FindMax(ByRef num1, ByRef num2, ByRef num3) As Integer
Dim min, max As Integer
If num1 > num2 And num1 > num3 Then
max = num1
Else
If num2 > num1 And num2 > num3 Then
max = num2
Else
max = num3
End If
End If
FindMax = max
End Function

464) Write a VB program which allow a user to Input 10 elements of an array and then displays
even and odd numbers separately.

ANSWER:

Private Sub Command1_Click()


Dim Number(10) As Integer
Dim i, odd(10), even(10) As Integer
For i = 1 To 10
Number(i) = InputBox("Input the student Marks", "Input Marks")
Next i
For i = 1 To 10
If Number(i) Mod (2) = 1 Then
odd(i) = Number(i)
Else: even(i) = Number(i)
End If
Next i
Print "the odd numbers are: "
For i = 1 To 10
If odd(i) <> 0 Then
Print odd(i)
End If
Next i
Print "the even numbers are: "
For i = 1 To 10
If even(i) <> 0 Then
Print even(i)
End If
Next i
End Sub

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 172


465) List and Explain 5 basic concept of Object Oriented Programming.

ANSWER:

The five basic concepts of Object Oriented Programming are:

1. Objects

Objects are basic runtime entities in an object system. They may represent a person, a place, a
table, of data or any item that the program must handle. Objects contain data and code to
manipulate the data.

2. Class

Class is a way to bind the data and its associated functions together. A class allows its data to be
hidden from its external use.

3. Data Encapsulation

Data Encapsulation is the wrapping up of data and functions into a single unit.

4. Inheritance

Inheritance is the process by which objects of one class acquire properties of objects of another
class.

5. Polymorphism

Polymorphism means the ability to take more than one form

6. Abstraction

Abstraction refers to showing only the essential features of the application and hiding the details.
In C++, classes provide methods to the outside world to access and use the data variables, but the
variables are hidden from direct access.

7. Exception handling is a feature of OOP, to handle unresolved exceptions or errors produced


at runtime.

466) Below is a table that contains information of teachers.

TEACHER
No Names of Age Department Date of joining Salary Sex
Teacher
1 Ndahimana 36 Computer 12-Jan-99 150000 M
2 Kamili 59 Maths 4-Mar-86 250000 M
3 Neema 30 Entrepreneurship 30-Jun-12 120000 F
4 Harima 29 Geography 1 10-Apr-10 130000 F

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 173


5 Kasiimu 43 Geography 2 12-Feb-88 200000 M
6 Nzabandora 32 Physics 1-Feb-00 230000 M
7 Ruterana 45 Kinyarwanda 12-Aug-85 240000 M
8 Shakilla 29 Maths 13-Jul-12 150000 F
9 Jackline 31 Geography 1 12-Jan-11 120000 F
10 Jack 40 Physics 11-Sep-99 200000 M
11 Mutessa 28 Computer 9-Nov-14 120000 M

Write SQL commands:

a)To find the teacher that did not join on the date of (“1/feb/2000” , “ 4/mar/1986” , “
12/feb/1988”)

ANSWER:

SELECT *FROM TEACHER WHERE DateofJoin NOT IN of (“1/feb/2000” , “ 4/mar/1986” ,


“ 12/feb/1988”);

b) To show all information about the teacher of Maths Department.

ANSWER:
SELECT *FROM TEACHER WHERE DEPARTMENT=”Maths”;

c) To list the name and age of the female Teachers who are in the Geography 1 Department.

ANSWER:
SELECT NameT, age FROM TEACHER WHERE Sex=’f’ AND DEPARTMENT=
‘Geogrphy1’;

d)To list the names of all Teachers whose age is greater than 30 with their date of joining in
ascending order?

ANSWER:
SELECT NameT , DateofJoin FROM TEACHER WHERE age>’30’ ORDER BY DateofJoin;

e)To display the Names, Age and Salary for male teachers only.

ANSWER:
SELECT NameT, Salary, Age FROM TEACHER WHERE Sex=’m’;

f)Arrange the whole table in the alphabetical order of names.

ANSWER:
SELECT *FROM TEACHER ORDER BY NameT;

g)Display all Teachers whose Names contain the character “n”

ANSWER:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 174


SELECT *FROM TEACHER WHERE NameT like ’*n*’;

h)Remove duplicates Department from the table.

ANSWER:
SELECT DISTINCT Department FROM TEACHER;

466) Write an algorithm to solve quadratic equation: ax2 + bx + c

ANSWER:

Variables a, b, c, delta, x1, x2 : numeric


Begin
Write "Enter the coefficients of this polynomial:"
Read a ,b,c
Delta ←b^2-4*a*c
If delta>0 Then
x1← - b+sqr(delta)/2*a
x2← - b - sqr(delta)/2*a
Write " the equation has two distincts roots which are :",x1 , "nand ",x2
elseif delta=0 Then
x1←x2←b/2*a ;
Write"the equation has two equal roots : ",x1
else
Write " The equation has no real solutions. "
Endif
End

467) Write a java program that allows user to enter 2 inputs through the
Keyboard and calculate the sum, average and difference, use scanner

ANSWER:

import java.util.Scanner;
class AddNumbers
{
public static void main(String args[])
{
double x, y, sum, average,difference ;
System.out.println(“Enter two numbers to calculate their sum”);
Scanner in = new Scanner(System.in);
x = in.nextInt();
y = in.nextInt();
sum = x + y;
average= (x+y)/2;
difference=x-y;
System.out.println(“Sum of the integers = “ + sum);
System.out.println(“average of the integers = “ + average);

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 175


System.out.println(“difference of the integers = “ + difference);
}
}

468) Write a vb program using do while…loop to display number from


0 to 100.

ANSWER:
Private Sub Form_Load()

Form1.Show
Dim num As Integer
num = 0
Do While num <= 100
num = num + 1
print num
Loop
End Sub

469) According to the comparison between laptop, Smartphone, Cell phone, PDA and Tablet,
which one is most useful? Explain why.

ANSWER:

Smartphone is more useful than cell phone, PDA, Laptop and tablet because of the following
five reasons:
i. Always available: the smartphone is almost always within arm’s reach. Wherever you go it is
in your pocket.
ii. Connectivity: a smartphone has a 3G (or maybe even 4G) signal. Many smartphones can also
act as a Wi-Fi hotspot, enabling you to share the cellular data connection.
iii. Voice calls: with smartphone, you can make and receive calls from virtually anywhere.
iv. Text Messaging
Along with voice calls, smartphones also enable communication via text messaging.
v. Versatility: a smartphone can be a phone, or a camera, or a portable music player, or a GPS
device, or an e-reader, or just about anything else you need it to be.

470) a)Differentiate desktop and laptop computer

ANSWER:
Laptop takes electricity from the battery and can use direct power source, portable
Desktops remain plugged into a power source, not portable
Laptop processors use less power, Laptop processors create less heat so
Desktop processors create great heat quantity; Desktop processors require large cooling devices

b) List any five internal components of a laptop

ANSWER:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 176


Ram, Cpu, Motherboard, Wireless card, Fan, HDD

471) Discuss common uses of positivo BGH laptop computer in schools and society in general.
ANSWER:
Laptop is used in:
Education field (example: Laptops are used by teachers in preparation of teaching and
learning materials, used by learners for searching information on internet)
Medicine field (example: Laptops are used by doctors to keep patient records)
Business field (Electronic commerce uses Laptops for example in marketing and selling
products or good and services.)
Accessing online services (example: National ID application at
www.irembo.gov.rw)
Entertainment field (example: Playing games and watching movies while traveling)
Communication field (example: when you send and receive an email in a public place)
Security field (example: Laptop can be used to fight against hackers: people who access
personal information without authorization of the owner. Notice that accessing of personal
information without permission is punishable crime).

472) a. Is Laptop hardware maintenance difficult comparing to desktop computer maintenance?


Explain
b. Describe what is used for standalone and networked laptop computer

ANSWER:
a. Laptop hardware maintenance is difficult comparing to a desktop computer maintenance
because Laptop components are proprietary, so you may not be able to use components made by
one laptop manufacturer to repair a laptop made by another manufacturer which makes that
technicians may have to obtain certification for each laptop manufacturer they support. Desktop
components are standardized.
b. Standalone laptop can be used for either personal or work use, Completing work,
Communication, Gaming. While

Networked laptop Connect to internet, Share resources, Share files, Share drives, Central
storage , Online gaming

473) Draw a flowchart where the user is asked to input a number and print it’s factorial
ANSWER:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 177


474) a. Define a computer network. What is the purpose of computer network?
b. Discuss advantages and disadvantage of using computer network

ANSWER:

a.A computer network is a collection of computers connected together for the purpose of sharing
resources. The most common resources shared are connection to the internet, printer folder and file

b. Advantages of Computer Network


 It enhances communication and availability of information.
 It allows for more convenient resource sharing.
 It makes file sharing easier.
 It is highly flexible.
 It is an inexpensive system.
 It increases cost efficiency.
 It boosts storage capacity.

Disadvantages of Computer Network


 It lacks independence.
 It poses security difficulties.
 It lacks robustness.
 It allows for more presence of computer viruses and malware.
 Negative usage promotes negative acts.
 It requires an efficient handler.
 It requires an expensive set-up

475) Using clear examples, Distinguish Personal Area Network and Local Area Network?

ANSWER:

Personal Area Network (PAN) is a network that connects devices, such as mice, keyboards,
printers, Smartphone, and tablets within the range of an individual person. PAN has connectivity
range up to 10 meters. PAN may include wireless computer keyboard and mouse, Bluetooth
enabled headphones, wireless printers and TV remotes.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 178


All of these devices are dedicated to a single host and are most often connected with Bluetooth
technology. Bluetooth is a wireless technology that enables devices to communicate over short
distances. A Bluetooth device can connect up to seven other Bluetooth devices.

Local Area Network (LAN) traditionally, a LAN is defined as a network that covers a small
geographical area. However, the distinguishing characteristic for LANs today is that they are
typically owned by an individual, such as in a home or small business, or wholly managed by an
IT department, such as in a school or corporation. This individual or group enforces the security
and access control policies of the network.

476) Differentiate three data transmission modes in network and give example for each

ANSWER:
The data that is transmitted over the network can flow using one of three modes: simplex, half
duplex and full duplex.
Simplex: it is a single one way transmission. In a simplex transmission mode, the
communication between sender and receiver occurs only in one direction. That means only the
sender can transmit the data, and receiver can only receive the data. The receiver cannot transmit
any information back to the sender.
Example of simplex transmission is the signal that is sent from a TV station to your home TV.

Half Duplex: data flows in one direction at a time In half duplex, the channel of
communications allows alternating transmission in two directions, but not in both directions
simultaneously.
Example of Half duplex is the Talkie Walkie used by the police

Full Duplex: data flows in both directions at the same time. In a full duplex transmission mode,
the communication between sender and receiver can occur simultaneously. Sender and receiver
both can transmit and receive simultaneously at the same time.
A telephone conversation is an example of full duplex communication. Both people can talk and
be heard at the same time.

A. TV :simplex
B. Radio : simplex
C. Walkie :Talkie :half- duplex
D. Phone : Full duplex
E. Computer: Full duplex

477) Describe a topology on figure bellow:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 179


ANSWER:
A Star topology is designed with each node (file server, workstations, and peripherals)
connected directly to a central network switch or concentrator.

Data on a Star network passes through the switch or concentrator before continuing to its
destination. The switch or concentrator manages and controls all functions of the network. It also
acts as a repeater for the data flow. This configuration is common with twisted pair cable;
however, it can also be used with coaxial cable or fiber optic cable.

478) a. List any five network devices used in computer networking


b. What are the three considerations when you want to design a network?

ANSWER:

a. Hub, switch, bridge, modem, repeater, NIC


b. Money: A linear bus network may be the least expensive way to install a network; you do not
have to purchase concentrators.
Length of cable needed: The linear bus network uses shorter lengths of cable.
Cable type: The most common cable in schools is unshielded twisted pair (UTP), which is most
often used with star topologies.

479) Define database and state five areas where databases is used

ANSWER:
A database is an organized collection of related data. It is considered to be organized because
the data is stored in categories that are accessible in a logical manner. A database is a collection
of one or more relations, where each relation is a table made of rows and columns.

Areas where database is used are:

1. Human resources: to track information about employees


2. Banking: to keep customer information, accounts, and loans, and banking transactions.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 180


3. Airlines: to keep for reservations and schedule information. Airlines were among the first to
use databases in a geographically distributed manner -terminals situated around the world
accessed the central database system through phone lines and other data networks.
4. Universities: to keep student information, course registrations, and grades.
5. Credit card transactions: to keep purchases on credit cards and generation of monthly
statements.
6. Telecommunication: to keep keeping records of calls made, generating monthly bills,
maintaining balances on prepaid calling cards, and storing information about the communication
networks.
7.Finance: to keep storing information about holdings, sales, and purchases of financial
instruments such as stocks and bonds.
8.Manufacturing: to keep management of supply chain and for tracking production of items in
factories, inventories of items in warehouses / stores, and orders for items. etc.

480) a) List databases models


ANSWER:

 Hierarchical model, network model and relational model

b)Discuss the uses of databases in business environment.

ANSWER:
Using Databases to Improve Business Performance and Decision Making Businesses use their
databases to:
 Keep track of basic transactions
 Provide information that will help the company run the business more efficiently
 Help managers and employees make better decisions

c)Discuss the concept of data independence and explain its importance in Database environment.

ANSWER:

DATA INDEPENDENCE: The ability to modify a schema definition in one level without
affecting a schema definition in the next higher level is called Data Independence. It is
independence between the programs and the data.
IMPORTANCE:
Data independence plays crucial role in database environment.
Improve performance.
Change in data structure does not require change in application program.
Hide implementation details from the users.
Allow users to concentrate on the general structure, rather than on low-level
implementation details.

Standards can be enforced.


Security can be improved.
Integrity can be improved.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 181


Better service to the users.
Cost of developing and maintaining systems is lower.
Flexibility in system improvement.
Inconsistencies can be reduced.

UNIT 6 POINTERS AND STRUCTURE IN C++ (S5)

481) a. Define pointer in c++


b. Give the general syntax of declaration pointers

ANSWER:

A pointer is a variable which contains the address in memory of another variable. There can be a
pointer to any variable type. The unary or monadic operator & gives the ``address of a variable''.
The indirection or dereference operator * gives the ``contents of an object pointed to by a pointer''.

Pointer declaration Syntax:


data_type *pt_name;
where data_type is the data type of the value that the pointer is intended to point to.

1. Differentiate dereference operator and reference operator

ANSWER:

The asterisk sign (*) in the cout statements is called the dereference operator.
The ampersand sign (&) is called the reference operator. If the reference operator is used, it will
get the “address of” a variable

2. Write a c++ program using structure, facilitating user to enter and display student
identification(roll_no, student_name and age).

ANSWER:
#include <iostream>

using namespace std;

struct student{

int roll_no;

char student_name[15];

float age;

};

int main(int argc, char *argv[]){

student s1;

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 182


cout<<endl<<" Enter Roll No:";

cin>>s1.roll_no;

cout<<endl<<" Enter Student Name:";

cin>>s1.student_name;

cout<<endl<<" Enter Student Age:";

cin>>s1.age;

cout<<endl<< " PRINTING DETAILS";

cout<<endl<< " Roll No:"<<s1.roll_no;

cout<<"\t"<< " Student Name:"<<s1.student_name;

cout<< " Student_Age"<<s1.age<<endl;

system("PAUSE"); return EXIT_SUCCESS;}

3. List types of operators used for accessing members of a structure


ANSWER:
There are two types of operators used for accessing members of a structure:
1. Member operator (.) or Dot Operator
structure_variable_name.member_name
2. Structure pointeroperator (->) or Arrow Operator (->)
structure_pointer->member_name;

4. a. Define structure in c++


b. Give the general syntax of declaration structure

ANSWER:

a. Structure is a collection of variables of different data types under a single name.

b. Data structures can be declared in C++ using the following syntax:


struct type_name {
member_type1 member_name1;
member_type2 member_name2;
member_type3 member
_name3;
.
} object_names;

5. By accessing member of structure using C++ write a simple running program that will
display the output of your birthday and today date.
ANSWER:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 183


#include <iostream>
using namespace std;
intmain()
{
struct birth
{
int day;
int month;
int year;
} b1, b2;
b1.day=23;
b1.month=2;
b1.year=2010;
b2.day=15;
b2.month=3;
b2.year=2018;
cout<< "My Birth day is:"<<b1.day<<"/"<<b1.month<<"/"<<b1.year<<"\n\n";
cout<< "To day date is:"<<b2.day<<"/"<<b2.month<<"/"<<b2.year<<"\n\n";
return 0;
}

6. Write a program that calculates s the Roots of a Quadratic Equation


2x2 +6x +4 in C++ using pointers.

ANSWER:
#include <iostream>
#include<cmath>
using namespace std;
int main()
{
float a=2, b=6,c=4;
float x,x1,x2,delta;
float *aptr;
float *bptr;
float *cptr;
aptr=&a;
bptr=&b;
cptr=&c;
a=*aptr;
b=*bptr;
c=*cptr;
//calculate delta
delta=*bptr * *bptr -4 * *aptr * *cptr;
x1=(-*bptr + sqrt(delta))/(2* *aptr);
x2=(-*bptr - sqrt(delta))/(2* *aptr );
cout<<"x1="<<x1<<endl;

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 184


cout<<"x2="<<x2<<endl;
return 0;
}

UNIT 7 OBJECT ORIENTED PROGRAMMING

7. Define:
a) object
b) Polymorphism
c) Friend function
d) Class
e) Encapsulation

ANSWER:
a) Objects are basic entities in an object oriented system. They may represent a person,
a place, a table, of data or any item that the program must handle.
b) Polymorphism: means the ability to take more than one form
c) Friend Function: If a function is defined as a friend function then, the private and
protected data of a class can be accessed using the function
d) Class: this is a way of binding the data and its associated functions together.

e) Data Encapsulation is the wrapping up of data and functions into a single unit.

8. What are comparison between constructor and destructor

ANSWER:

CONSTRUCTOR DESTRUCTOR
The Same name as class The same name as class
No return type No return type
Can have parameters Cannot have parameters
No tilde sign Its name is preceded by a tilde sign
Is called when an object is created Is used to destroy an object created by a
constructor
9. List down any three advantages of Object Oriented Programming language.

ANSWER:

It facilitates to write, maintain and modify long program. It facilitates to create the
objects representing entities from real world.
The possibility of creating special functions called constructors and destructors
The possibility of overloading the operators
Program reusability

10. What are three types of access specifier? Explain each other.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 185


ANSWER:

Private members of a class are accessible only from other members of the same class or
from their friend classes
Protected members are accessible from members of their same class and friend classes
and also from members of their derived classes.
Public members are accessible from anywhere the class is visible

11. By using a sketch, give types of Inheritance


ANSWER:

A. Single inheritance
A derived class having only one single base class

b. Multiple Inheritance

Hierarchical Inheritance

Multilevel Inheritance

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 186


Hybrid Inheritance

12. Write a program in C++ using class called person which has 2 functions:getdata() and
putdata().The getdata()prompts the user to enter his or her name and age,putdata() displays on
screen the user name and age.

ANSWER:

#include<iostream.h>
class person
{
public:
char name[10];
int age;
void getdata();
void putdata();
};
void person::getdata()
{
cout<<”enter the your name”<<endl;
cin>>name;
cout<<”enter the your age”<<endl;
cin>>age;

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 187


void person:: putdata()
{
cout<<”my name is: ”<<name;
cout<<”my age is: ”<<age;

}
void main(){
person p;
p.getdata();
p.putdata();
}

13. What is the concept of data hiding? What are the advantages of its applications?
ANSWER:

Encapsulation is the process of combining data and functions into a single unit called class.
Using the method of encapsulation, the programmer cannot directly access the data. Data is only
accessible through the functions present inside the class. Data encapsulation led to the important
concept of data hiding. Data hiding is the implementation details of a class that are hidden from
the user. The concept of restricted access led programmers to write specialized functions or
methods for performing the operations on hidden members of the class. Attention must be paid to
ensure that the class is designed properly.

Unit 8 INTORDUCTION TO VISUAL BASIC

14. Observe the figure and name the objects labeled A, B, C, D, E , F, G AND H

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 188


ANSWER:
A: Menu bar B: Tool Bar C. Form Window D: Code Window E: ToolBox F: Form layout
G. Properties window
H. Project Explorer.

15. Write a VB program that requests the user to enter 2 numbers and displays their sum,
difference and product.
ANSWER:

Private Sub add_Click()


Dim num1,num2, Product, Difference, Sum As Integer

num1 = Val(Text1.Text)

num2 = Val(Text2.Text)
Sum = num1 + num2
Difference=num1-num2
Product=num1*num2
Text3.Text = Sum
Text4.Text = Product
Text5.Text = Difference
End Sub

16. State the process followed to start up Visual basic 6.0

ANSWER:

First install Microsoft visual basic 6.0 into PC, and follow the following in order to use it.

Start>all program> Microsoft visual basic 6.0> Dialog Box > Standard EXE> form window
appear.From the New Project window we can select new, existing and recent project.

17. Differentiate between desktop and web application


ANSWER:

Desktop application
A desktop application is a computer program that runs locally on a computer device, such as
desktop or laptop computer, in contrast to a web application, which is delivered to a local
device over the Internet through browser from a remote server. Different user environments can
impact whether a desktop or a web application is the best solution for your needs.

Difference between desktop and web applications

Desktop applications
They must be developed for and installed on a particular operating system.
Have strict hardware requirements that must be met to ensure that they function correctly.
Updates to the applications must be applied by the user directly to their installation and may
require hardware upgrades or other changes in order to work.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 189


Web applications

A web application is any computer program that performs a specific function by using a web
browser.The user accesses the application using the web browser and works with resources
available over the internet, including storage and CPU processing power.

18. a.Define visual basic


b.States three advantages of vb 6.0
ANSWER:

a)VISUAL BASIC is a high level and Event-driven Programming Language which evolved from
the earlier Desk Opening System (DOS) version called BASIC.
b)Visual basic 6.0 has the following advantages:
It is easier for the user to minimize code writing.0
The user will become more familiar with visual approach for other visual languages.
It provides Input box and Output box as interactive windows with user.
It is very easy program language compare with other.

19. What is a control? Give three examples.

ANSWER:
A control is a tool on the toolbox window that you place on a form to interact with the user and
control the program flow.

Examples: textbox, label, commandbutton

20. Name and give the function of labeled parts of the following toolbar

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 190


ANSWER:
A.Command Button: The command button is a very important control as it is used
to execute commands. It displays an illusion that the button is pressed when the user clicks on it.

B.Label: The label is a very useful control for Visual Basic, it is used to provide
Instructions and guides to the users, and it can also be used to display outputs.

C. Check Box: The Check Box control lets the user to select or unselect an option. When the
Check Boxes checked, its value is set to 1 and when it is unchecked, the value is set to 0.

D. Combo Box: The function of the Combo Box is to present a list of items where the user can
click and select only one item from the list

E. Image Box: The Image Box is another control that handles images and pictures.
It functions almost identically to the picture box.

F. Picture Box: The Picture Box is one of the controls that used to handle graphics.

G. Text Box: is the standard control that is used to receive input from the user as well as to
display the output. It can handle string (text) and numeric.

H. Option /RadioButton: Radio Button provides the capability to make a mutually exclusive
choice among group choices.

I.List Box: A list box displays a list of items from which the user can select one or more items.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 191


J. The Drive ListBox: The Drive ListBox is used to display a list of drives available in your
computer. When you place this control into the form and run the program, you will be able to
select different drives from your computer.

21. What are the three process of Planning and Developing a Visual Basic program

ANSWER:

Developing a VB program is mainly done in three steps namely setting up user interface,
defining the properties, and creating code.
a. Draw the interface
At this step, you will be using the object to design the interface of your application; the controls
will be taken from the tool box by dragging it from there to the form designer.
b. Set properties
At this stage, you will be setting up properties for your form and controls. Those properties are
set from the properties window.
c. Write the event code.
Coding is to be done in the code window and you get there by double clicking the object you
want to code.

22. Writes codes that display your entered full name on the form when the application is
loaded.
ANSWER:

Private sub command1_click ()


Dim name as string
Name=Inputbox (”enter your full name ”)
Print “my full name is”; name
End sub
Or
Private sub
form1_load ()
Form1.show
Print “KWIZERA Eric”

UNIT 9 VARIABLES, OPERATORS, EXPRESSIONS AND CONTROL STRUCTURES

23. Outline different rules of naming a variable in Visual Basic

ANSWER:

The rules used in naming variables in Visual Basic are:

No more than 40 characters


Variables must include letters, numbers and underscores (_)
No punctuation, spaces or other characters are permitted.
A variable name must begin with a letter

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 192


The name cannot be a reserved word (words needed by Visual Basic).For example, End
is a reserved word inVisual Basic.Net and therefore should not be used as a variable name.
24. List at least 5 data types used in VB

ANSWER:

Integer, byte, single, long, double, currency, string, Boolean

25. What will be the output of this code if the user input 8.

ANSWER:

Private Sub cmdStart_Click()


Dim x As Single, y As Single
x = Val(txtX.Text)
y = x^2 + 1
picResults.Cls
picResults.Print “x = ”, x
picResults.Print “y = ”, y
End Sub
Answer:
X=8
Y=65

26. Write a VB procedure that reads student’s note and then displays the following grades as
shown on the figure below:

NB: The student marks is entered through inputbox

marks between 85 and 100 : Greater Distinction

marks between 65 and 85 : Distinction

marks between 50 and 65 : Satisfaction

marks between 0 and 50: : Failure

marks bellow 0 and above 100: Wrong Note

ANSWER:

Private sub cmd_click()


Dim marks as integer
marks=inputbox(“enter the marks of the students”)
If marks >= 85 And marks <= 100 Then
Print "Greater Distinction"
Else
If marks >= 65 And marks <= 85 Then

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 193


Print "Distinction"
Else
If marks >= 50 And marks <= 65 Then
Print "Satisfactory"
Else
If marks >= 0 And marks <= 50 Then
Print "Failure"
Else
Print "Wrong note"
End If
End If
End If
End If
End sub

27. Write a vb Code for the command button to verify if the entered number is odd or even

ANSWER:

Private sub command_click()


Dim x as integer
x = val(Text1.Text)
If x Mod (2) = 0 Then
MsgBox "This is an even number you entered"
Else
MsgBox "You entered the odd number"
End If
End sub
28. a. Define select case in visual basic6.0
b. Write syntax of select case
ANSWER:

a. Select Case format can be used when there are multiple selection possibilities.
Select case instructions are easier to write and decode than complex nested if statements.
If the “case” matches the condition is selected and all instructions within the matching case are
executed.

b. The general format is:


Select case
expression
Casevalue 1
Block of visual basic statements
Casevalue2
Block of visual basic statements
Casevalue3

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 194


Block of visual basic statements
Casevalue4
Case Else
Block of visual basic statements
End Select

29. Write a vb program using while …wend to generate the sum of first 10 integers

ANSWER:

Private Sub Form_Load ()


Form1.Show
Dim I As Integer, Sum As Integer
I=0
Sum = 0
While I <= 10
Sum = Sum + I
I=I+1
Wend
Print “The sum of first 10 integers is”; Sum
End Sub

30. Write a vb program using do while…loop to display number from 0 to 100

ANSWER:

Private Sub Form_Load()


Form1.Show
Dim num As Integer
num = 0
Do While num <= 100
num = num + 1
print num
Loop
End Sub

31. What the following controls prefix stand for? Chk, fil,cbo,frm,txt.
ANSWER:

Chk: Check box


Fil: File list box
Cbo: combo box
Frm: form
Txt: text box.

32. Write a vb code to display The output above:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 195


Private Sub Form_Load()
Form1.Show
Dim Counter =0 As Integer
Do
Counter = Counter + 3
Print Counter
Loop Until Counter = 15
End Sub

33. Write a VB program to calculate the values of the following arithmetic operation if the
user inputs two numbers M and N into two separate text boxes
a. M^N

b. M\N
c. M Mod N

ANSWER:

Private Sub Command1_Click()


Dim M, N, exp, int_div, mode As Integer
M = Val(Text1.Text)
N = Val(Text2.Text)
exp = M ^ N
int_div = M \N
mode = M Mod N
Text3.Text = exp
Text4.Text = int_div
Text5.Text = mode
End sub
UNIT 10: INTRODUCTION TO JAVA

34. Define java and give any three advantages

ANSWER:
Java is a computer programming language. It enables programmers to write computer
instructions using English-based commands instead of having to write in numeric codes. It is
known as a high-level language because it can be read and written easily by humans.

Advantages: Secure, portable, easy to learn, robust, dynamic, Java is fast, secure, and reliable

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 196


35. Write a program in Java that after compilation and execution will display the messages:
“Unity and Peace are the engines of development in Rwanda” and “Rwanda is a best country”.

ANSWER:
public class ExampleProgram

{
public static void main(String[] args) {
System.out.println("Unity and Peace are the engines of development in Rwanda” and
“Rwanda is a best country");
}
}
36. Given two integer x= 55; y= 44; write a java program which is calculate and display the
sum of these two integers.
ANSWER:
package exampleprogram;

public class ExampleProgram {


public static void main(String[] args) {
int x=55;
int y=44;
int sum= x+y;// variable
System.out.println("Sum of x+y is");
System.out.println(sum);
}}

37. Differentiate type of errors of java programming

ANSWER:
Compile-time errors: occur when you violate the syntax rules of the Java language.

Run-time error: so-called because it does not appear until after the program has started running.
In Java, these errors occur while the interpreter is executing byte code and something goes
wrong. These errors are also called “exceptions” because they usually indicate that something
exceptional (and bad) has happened.
The logic error: If your program has logic error, it will compile and run without generating error
messages, but it will not do the right thing.

38. Write a program where you declare the variables firstname, lastname, age This program
should display like this: John Mugabe is 35 years old

ANSWER:

package exampleprogram;

public class ExampleProgram {


public static void main(String[] args) {
String firstname = "John", lastname= "Mugabe";

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 197


int age =18;// variable 1
System.out.println (firstname+" "+lastname+" "+"is"+" "+age+"years old “);
}}

39. Give the output


Int a=5+7%2;
System.out.println(a)

Answer: 6

40. Give the output

Output:
Value of x:10
Value of x:11
Value of x:12
Value of x:13
Value of x:14
Value of x:15
Value of x:16
Value of x:17
Value of x:18
Value of x:19

41. Write the difference between a statement and a comment


42. ANSWER:
Statement: A part of a program that specifies a computation.

WHILE

Comment: A part of a program that contains information about the program, but that has no
effect when the program runs.

43. Write a Java program to print 'Hello' on screen and then print your name on a separate
line.

ANSWER:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 198


Public class Exercise1
{public static void main(String[]args)
{
System.out.println("Hello\Alexandra Baranov!");
}}

44. Write a Java program that takes two numbers as input and display the product of two
numbers.

import java.util.Scanner;

public class Exercises {


public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Input first number: ");
int num1 = in.nextInt();
System.out.print("Input second number: ");
int num2 = in.nextInt();
System.out.println(num1 + " x " + num2 + " = " + num1 * num2);
}}

UNIT 11 OOP AND JAVA

45. What is the output of this program?


Class Student { int id; Stringname;
}
Class TestStudent1{
Public static void main(String args[])
{
Student
s1=new Student();
s1.id=101;
s1.name="Uwineza";
System.out.println(s1.id);
System.out.println(s1.name);
}}

ANSWER:

Output:
101
Uwineza

46. What is the output of this program?

class evaluate
{

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 199


public static void main(String args[])
{
int arr[] = new int[] {0 , 1, 2, 3, 4, 5, 6, 7, 8, 9};
int n = 6;
n = arr[arr[n] / 2];
System.out.println(arr[n] / 2);} }

ANSWER:

Output: 1

47. What is the use of “extends “keyword in Java

ANSWER:
The extends is a Java keyword used in inheritance and it indicates that you are making a new
class that derives from an existing class.

48. Differentiate Parameterized constructor with default constructor in java

ANSWER:
A default constructor is a constructor which doesn’t have any parameter and which can be called
with no arguments.

Syntax of default constructor:


<class_name>(){}
Parameterized constructor in Java
A constructor which has a specific number of parameters is called parameterized constructor.

49. Give the general form of declaring inheritance in java

ANSWER:

Class Subclass- name extends Superclass-name

{
//methods and fields
}
50. Discuss the difference between a method overloading and a method overriding in Java?

ANSWER:
Method Overloading is a feature that allows a class to have more than one method having the
same name, if their argument lists are different. While Method Overloading occurs within the
same class , Parameters must be different when we do overloading , In overloading one method
can’t hide the another

Example:
add(int, int)
add(int, int, int)

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 200


If subclass (child class) has the same method as declared in the parent class, it is known as
method overriding in java. in overriding subclass method hides that of the superclass method.
Parameters must be same. Method Overriding occurs between two classes superclass and
subclass

UNIT 12 IO AND JAVA

51. Differentiate System.in and System. out

ANSWER:
System.in are connected to keyboard inputs character data input any information that is needed
by a program to complete its execution. System.out are connected to the monitor and output
character data. The output any information that the program must convey to the user.

52. List different input stream classes that can be applied to input data from user.
ANSWER:

Scanner(), BufferedReader(), DataInputSteam()

53. Write a java program to calculate area of triangle


import java.util.Scanner;

class AreaTriangle {
public static void main(String args[]) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter the width of the Triangle:");
double base = scanner.nextDouble();
System.out.println("Enter the height of the Triangle:");
double height = scanner.nextDouble();
double area = (base* height)/2;
System.out.println("Area of Triangle is: " + area);
}
}
54. Write a java program that allows the user to enter three floats numbers and displays
them on screen

import java.util.Scanner;

public class Exercise2 {


public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.print("Input the first number: ");
double x = in.nextDouble();
System.out.print("Input the second number: ");
double y = in.nextDouble();
System.out.print("Input the third number: ");

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 201


double z = in.nextDouble();
System.out.println("the first nuber is " +" " + x );
System.out.println("the second number is " +" " + y );
System.out.println("the third number is " +" " + z );
}}
55. Using scanner, write a java program that allows the user to enter the age of KARENZI,
SINGIZWA and MPORE and print the youngest

import java.util.Scanner;

class youngest
{
public static void main(String[] args)
{
int karenzi,singizwa,mpore;
Scanner s=new Scanner(System.in);
System.out.println("Enter age of KARENZI: ");
karenzi=s.nextInt();
System.out.println("Enter age of SINGIZWA: ");
singizwa=s.nextInt();
System.out.println("Enter age of MPORE: ");
mpore=s.nextInt();
if (karenzi<singizwa && karenzi<mpore)
{
System.out.println("youngest is KARENZI with : "+karenzi +"age(s)");
}
else if (singizwa<karenzi && singizwa<mpore)
{
System.out.println("youngest is SINGIZWA with: "+singizwa +"age(s)");
}
else if (mpore<karenzi && mpore<singizwa)
{
System.out.println("youngest is MPORE with: "+mpore +"age(s)");
}
else
System.out.println("KARENZI, SINGIZWA and MPORE are in the same age" );
}
}
56. Write a java program to calculate area of circle

import java.util.Scanner;
class AreaOfCircle
{
public static void main(String args[])
{
Scanner s= new Scanner(System.in);
System.out.println("Enter the radius:");
double r= s.nextDouble();

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 202


double area=(22*r*r)/7 ;
System.out.println("Area of Circle is: " + area);
}
}

57. Write a java program that allows user to enter 2 inputs through the keyboard and
calculate the sum, average and difference

import java.util.Scanner;

class AddNumbers
{
public static void main(String args[])
{
double x, y, sum, average,difference ;
System.out.println("Enter two numbers to calculate their sum");
Scanner in = new Scanner(System.in);
x = in.nextInt();
y = in.nextInt();
sum = x + y;
average= (x+y)/2;
difference=x-y;
System.out.println("Sum of the integers = " + sum);
System.out.println("average of the integers = " + average);
System.out.println("difference of the integers = " + difference);
}
}
58. Write a java program to find the roots of and quadratic equation of type ax2+bx+c.

import java.util.Scanner;

public class Quadratic_Equation


{
public static void main(String[] args)
{
int a, b, c;
double root1, root2, d;
Scanner s = new Scanner(System.in);
System.out.println("Given quadratic equation:ax^2 + bx + c");
System.out.print("Enter a:");
a = s.nextInt();
System.out.print("Enter b:");
b = s.nextInt();
System.out.print("Enter c:");
c = s.nextInt();
System.out.println("Given quadratic equation:"+a+"x^2 + "+b+"x + "+c);
d = b * b -4 * a * c;
if(d > 0)

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 203


{
System.out.println("Roots are real and unequal");
root1 = ( -b + Math.sqrt(d))/(2*a);
root2 = (-b -Math.sqrt(d))/(2*a);
System.out.println("First root is:"+root1);
System.out.println("Second root is:"+root2);
}
else if(d == 0)
{
System.out.println("Roots are real and equal");
root1 = (-b+Math.sqrt(d))/(2*a);
System.out.println("Root:"+root1);
}
else
{
System.out.println("Roots are imaginary");
}}}

59. Write a java program which accept principle, rate and tie from the user and print the
simple interest

import java.util.Scanner;

public class Simple_Interest


{
public static void main(String args[])
{
float p, r, t;
Scanner s = new Scanner(System.in);
System.out.print("Enter the Principal : ");
p = s.nextFloat();
System.out.print("Enter the Rate of interest : ");
r = s.nextFloat();
System.out.print("Enter the Time period : ");
t = s.nextFloat();
float si;
si = (r * t * p) / 100;
System.out.print("The Simple Interest is : " + si);
}
}
60. Write java program to check whether the given number is positive or negative

import java.util.Scanner;
public class PositiveNegative
{
public static void main(String[] args)
{
int number;

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 204


Scanner scan = new Scanner(System.in);
System.out.print("Enter the number you want to check:");
number = scan.nextInt();
if(number >0)
{
System.out.println(number+" is positive number");
}
else if(number < 0)
{
System.out.println(number+" is negative number");
}
else
{
System.out.println(number+" is neither positive nor negative");
}}}

61. Write a program to check whether the given number is even or odd
import java.util.Scanner;

public class EvenOdd {


public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
System.out.print("Enter a number: ");
int num = reader.nextInt();
if(num % 2 == 0)
System.out.println(num + " is even");
else
System.out.println(num + "is odd");
}
62. Find out the output of the following source code when a number of rows is 7

import java.util.Scanner;
public class MainClass
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("How many rows you want in this pattern?");
int rows = sc.nextInt();
System.out.println("Here is your pattern....!!!");
for (int i = 1; i <= rows; i++) {
for (int j = 1; j <= i; j++)
{
System.out.print(i+" ");
}
System.out.println();
}sc.close();}}

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 205


Output :

END

UNIT 1 COMPUTER SECURITY (S6)

1. Describe the simple measures that can be taken to protect data in the school computer lab
ANSWER:
Installing anti-virus in all computers
Protect all computers with password
Install Firewall. -Install Antivirus Software.-Install Anti-Spyware Software.

-Use Complex and Secure Passwords.-Check on the Security Settings of the Browser.

2. a. By using simple words, define computer security?


b. Write briefly on importance of computer security at your school, in Rwanda and in the whole
world.

ANSWER:
a. Computer security refers to techniques developed to safeguard information and systems stored
on computers.
b. Computer security is important in the following ways:
Computer security helps to keep safely data and equipment functioning and provide
access only to appropriate people.
Computer security is important, because of keeping information protected. It’s also
important for the computer’s overall health, helping to prevent viruses and malware and helping
programs run more smoothly.
Computer and data stored can be protected from potential outside problems.
Computer security is important for helping programs to run more smoothly
Computer security is important for preventing theft of data, software, services and
equipment

3. Discuss the difference between logical and physical threats and give examples to each?

ANSWER:

Physical threats are digital storage media and hardware that can damage or destroy the computer
system.
Example: Humidity, water
While logical threats are events or attacks that remove, corrupt, deny access, or steal information.
Example: viruses and spyware

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 206


4. What is a computer attack? Differentiate active attack to passive attack.

ANSWER:

A computer attack is any attempt to expose, alter, disable, destroy, steal or gain unauthorized
access to or make unauthorized use of an asset.
An active attack attempts to alter system resources or affect their operation while a
passive attack attempts to learn or make use of information from the system but does not
affect system resources

5. Explain the difference between social engineering and Shoulder Surfing techniques

ANSWER:
In computer security a social engineer is a person who is able to gain access to equipment or a
network by tricking people into providing the necessary access information
In computer security, shoulder surfing is a type of social engineer who obtain information such
as personal identification number, password and other confidential data by looking over the
owner of information.

6. Explain the different types of cybercrimes


ANSWER:

Cyber bullying is bullying that takes place using electronic technology


Sexting is the sending and receiving of text, photo or video messages of children and
young people that are inappropriate and sexually explicit.
“Grooming” is the way sexual predators get from bad intentions to sexual exploitation.
Basically, grooming is manipulation. It’s the process pedophiles use to get children they target
online to meet with them offline, the simple goal being sex

7. How a user can protect physical equipment of a computer

ANSWER:
use physical equipment against fire
use metallic doors and windows against theft
use security camera, security guard and alarms to detect theft
use UPS to protect system failure and data loos due to the power failure

8. Differentiate between access control and parental control

ANSWER:
Access control is a security technique that can be used to regulate who or what can view or use
resources in a computing environment while the Parental Controls feature is a valuable tool for
controlling the amount of time your children spend on the computer and the programs they’re
using.

9. A hard disk is connected into a broken computer system case like the one below. When
the computer is switched on, it shows that something is wrong. The user cannot work on it
properly. It is very difficult to send a document to hard disk.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 207


a. Describe what is happening to make the computer not functioning correctly.
ANSWER:
That computer is not functioning correctly because some ports have been damaged. For example
a port where a hard disk is connected
b. Propose solutions to this problem.
ANSWER:
The solution can be taken is to take care of physical parts of computers
c. It is said that connecting devices to computers, it is a work for boy. Is it true? Say
something about it.
ANSWER:
No, It is a work for both.

10. What is difference between:


a) Encryption and decryption?
b) Authorization and Authentication.

Encryption is the process of encoding a message or information in such a way that only
authorized parties can access it. Simply, encryption is to transform representation so it is no
longer understandable

Decryption is the process of taking encoded or encrypted text or other data and converting it
back into text that you or the computer can read and understand.

ANSWER:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 208


Authentication confirms who you are. While Authorization is the process to confirm what you
are authorized to perform.

UNIT 2 LAN ARCHITECTURE, NETWORK PROTOCOLS AND MODELS

11. a. Define LAN architecture


b. Differentiate three levels of LAN architecture

ANSWER:
a. Local Area Network (LAN) architecture is the overall design of a computers network that
interconnects computers within a limited area such as a residence, school, laboratory, university
campus of office building.
b. The LAN architecture consists of three levels: Physical, Media Access Control (MAC)
and Logical Link Control (LLC).
o The LLC provides connection management, if needed.
o The Media Access Control (MAC) is a set of rules for accessing high speed physical
links and for transferring data frames from one computer to another in a network.
The Physical level deals mainly with actual transmission and reception of bits over the
transmission medium.

12. What are the major components of LAN

ANSWER:
A LAN is made of the following main components:
o Hardware:
Computers, Network interface card (NIC) linked to physical address, Media or Cables
(Unshielded twisted pair, Coaxial cable, Optical fiber, Air for wireless)
Hub, Switches, repeaters
o Access Methods: Rules that define how a computer puts data on and takes it from the
network cable.
o Software: Programs to access and / or to manage the network.

13. Your school has classrooms, computer labs and the staff room located in three different
buildings as indicated in the figure below:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 209


1. Which kind of technology can you propose to connect computers in the 3 building?
Explain your choice.
2. If you choose to install a wireless network within this school, in which building would
you place the wireless device which serves the whole school? Explain.
3. What type of Ethernet cable would you use if you are requested to interconnect those
three buildings? Explain

1. Students may choose between LAN, Token ring and FDDI technologies.
2. The device can be placed in any building. Students demonstrate how the wireless device to be
used can emit its signals to the whole school by indicating its coverage area. Student indicate
their choice between 2.4 GHz (~90 meters) and 5 GHz (~28 meters) wireless routers.
3. Students demonstrate their ability to choose proper network cable between Ethernet, Fast
Ethernet/100Base-T, Gigabit Ethernet/GigE and 10 Gigabit Ethernet taking into consideration
the cost and the maximum distance which cannot exceed 100 meters in our case

14. Write in full the following abbreviations:


a. WLAN
b. FDDI
c. CSMA/CD
d. MAC
e. NIC
f. DHCP
g. SMTP
h. FTP
i. OSI
j. TCP

ANSWER:

WLAN: Wireless Local Area Network


NIC: Network Interface Card
MAC: Media Access Control
FDDI: Fiber Distributed data Interface
CSMA/CD: Carrier Sense Multiple Access with Collision Detection
DHCP: Dynamic Host Control Protocol
SMTP: Simple Mail Transfer Protocol
FTP: File Transfer Protocol

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 210


OSI: Open system Interconnect
TCP: Transmission Control Protocol

15. Write steps How to Connect to the Internet through the Taskbar

ANSWER:

1. Select the Network icon in the notification area.

2. In the list of networks, choose the network that you want to connect to, and then select
Connect.
3. Type the security key (often called the password).
4. Follow additional instructions if there are any.

16. a. What is network protocol?


b. What are five functions of protocols?
c. List any five most used protocols
ANSWER:

a. A network protocol defines rules and conventions for communication between network
devices. Network protocols include mechanisms for devices to identify and make connections
with each other, as well as formatting rules that specify how data is packaged into messages sent
and received.
b. Transfer electronic mail from one user to another.
File transfer over the network.
Access data on the World Wide Web
Mechanisms for devices to identify and make connections with each other, as well as formatting
rules that specify how data is packaged into messages sent and received.
c. FTP, SMTP,HTTP,POP,IMAP

17. Your school has acquired 60 computers from the Rwanda Education Board (REB) and
wishes to distribute them as follows:
 Administration: 3 computers
 Staff room: 7 computers
 Computer lab for students in Ordinary level: 30 computers
 Computer lab for students in Advanced level: 20 computers

a) List all materials needed to setup 2 wireless LANs within the school.
b) Provide specifications for your materials and equipment
c) Is it possible to secure those wireless networks?
d) Indicate the type of wireless security to be used.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 211


a) The following are possible alternatives:

ANSWER:
 Two Wireless Routers, UTP cable, laptop or desktop
 One Wireless Router and one Access Point, UTP cable, laptop or desktop

b) It is better to use a 2.4 GHz 802.11nstandard or 802.11ac standard wireless router / Access
Point regardless of the model because it has greater range than 5GHz routers.UTP cat6 or cat7
can be used

c) yes

d) Students will choose between WEP, WPA and WPA2

18. What are the common steps in configuring both wireless routers and access points?

ANSWER:
Common steps may include but are not limited to:
 Entering into the device’s configuration interface
 Defining the wireless name of SSID Setting wireless security mode and password

19. What are the advantages of using OSI layered model?

ANSWER:

 It prevents changes in one layer from affecting other layers.


 It describes what functions occur at each layer of the model that encourages industry
standardization.
 It allows different types of network hardware and software to communicate.

20. List seven layers in the OSI reference model and 4 layers in the TCP/IP model

ANSWER:
OSI model
Application
Presentation
Session
Transport
Network
Data Link
Physical

TCP/IP model
Application
Transport
Internet

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 212


Network Access

UNIT 3 NETWORKING PROJECT

21. List any five tools required to build P2P network

ANSWER:
Cable testing, crimping tool, scissor, drilling machine, cable cutter, cable stripper

22. Using the color names, make a respected order while making an Ethernet cable.

568B- put the wires in the following order, from left to right;

 White orange
 Orange
 White green
 Blue
 White blue
 Green
 White brown
 Brown.
568A- put the wires in the following order, from left to right;

 White green
 Green
 White orange
 Blue
 White blue
 Orange
 White brown
 Brown.
.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 213


23. The figure below shows a typical Home Network Setup. Identify the network

component marked by those letters

ANSWER:
The network component are:
A: Modem or Broadband router
B: Ethernet cable
C: Wireless Signal
E: Linksys Wireless Router

24. What do you understand by a Wireless Access Point and Give at least 4 benefits of using
a wireless network connection?

ANSWER:
A Wireless Access Point is a specially configured node on wireless local area networks (WLAN)
which acts as a central transmitter and receiver of WLAN radio signals
Benefits of wireless network connections are:
 Mobility – With a laptop computer or mobile device, access to a wireless network can be
available throughout a school, on an airplane, …
 Fast setup – if your computer has a wireless adapter, locating a wireless network can be
as simple as clicking “Connect to a network”
 Expandability – Adding a new computer to a wireless network is easy as turning a
computer on (as long as you do not exceed the maximum number of devices).

Cost – setting up a wireless network is not more expensive than buying and installing cables

25. What is the appropriate cable to use when you want to connect following devices?
a. PC to PC

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 214


b. Router to Router
c. Switch to Router
d. PC to Hub or PC to Switch
ANSWER:
a)PC to PC
 Crossover
b)Router to Router
 Crossover
c)Switch to Router
 Straight-through Cable
d)PC to Hub or PC to Switch
 Straight-through cable

26. State different steps to build peer to peer network

ANSWER:
Step 1: Make sure all computers are turned off, organized and arranged.
Step 2: Install central devices (Switch or hub).
Step 3: Connect each end of the UTP CAT 6 straight through cables to connect computers to
Switch/ Hub.
Step 4: Define IP address scheme
Step 5: Configure static IP address for each computer.
Step 6: Ping each computer to verify if they are connected
Step 7: do the same as what you did on step 5 to all PCs

27. State different steps to configure wireless router

Step 1: Prepare router and switch on it.


Step2: Connect router to the Laptop/PC with wireless capability
Step3: Access Dashboard using default IP address and Password
Step4: Configure internet using information from the ISP
Step5: Configure LAN and IP using DHCP
Step 5: DHCP Settings and select disable the DHCP Server.
Step 6: Set the IP from ISP and go to the System Tools and Reboot the device

28. What are advantages of Client/server network?

ANSWER:
1) Centralization
2) Proper Management

3) Back-up and Recovery possible

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 215


4) Up gradation and Scalability in Client-server set-up
5) Accessibility
6) Security Servers can play different roles for different clients

UNIT 4 SQL and database project

29. Match the following:

I.SELECT __ A. Determines which records are to be retrieved from a table.


II.FROM ___ B. Determines how retrieved records are to be sorted.
III.WHERE __ C. Used to give a field name to a computation.
IV.ORDER BY- D. Determines what fields are included in the query output.
V.AS ___ E. Specifies the tables from which data is to be extracted.

ANSWER:
ID IIE IIIA IVB VC

30. Consider the table BOOKS below:

BookID Bookname Edition Author Publisheddate

B001 C++ Ed2 H.olivier 1997

B002 Database Ed1 P. Albert 2001

B003 VB Ed3 M.Claude 1985

B004 Webdesign Ed1 J.Mata 1998

By using the table above, write the SQL commands to do the following
a. List the all Books records
b. What are the books that were published before 2001
c. Delete the books that were published in 1985
d. Change the edition of database to Ed2

ANSWER:
ANSWER:
SELECT * FROM BOOKS;
SELECT * FROM BOOKS WHERE Publisheddate<’2001’;
DELETE * FROM BOOKS WHERE Publisheddate=’1985’;

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 216


UPDATE TABLE BOOKS SET Edition=Ed2 WHERE BookID=’B002’;

31. Discuss SQL as:


a. Data definition Language (DDL)
b. Data manipulation Language (DML)
c. Data Control Language (DCL)

ANSWER:

a) Data definition Language (DDL):

This part of SQL enables the creation of tables and relationship between those tables in a
database. The most important DDL statements in SQL are:

 CREATE DATABASE - creates a new database


 ALTER DATABASE - modifies a database
 CREATE TABLE - creates a new table
 ALTER TABLE - modifies a table
 DROP TABLE - deletes a table
 CREATE INDEX - creates an index (search key)
 DROP INDEX - deletes an index

b) Data manipulation Language (DML). /5marks


This part of SQL enables to select, insert, update and delete data in a table in a database
c) Data Control Language (DCL). /5marks
It’s possible to Grant or remove permissions to users in a database. This is made using the DCL

32. It is common to implement database control measures to protect databases against the
loss of integrity, loss of availability and/or loss of confidentiality threats. Give and explain at
least 10 control measures that can be implemented.

ANSWER:
 Access control: Refers to creating user accounts and passwords to control the login
process by the DBMS.

 Inference control: The data provided to Database users should be controlled so that they
do not guess confidential information from that data if they should not see it.
 Flow control: The flow control prevents information from flowing in such a way that it
reaches unauthorized users.
 Data encryption: Data encryption is used to protect sensitive data (such as credit card
numbers) that is transmitted via some type of communications network. Here, data should be
encoded before it is transmitted.
 Database auditing: Database auditing involves observing a database so as to be aware of
the actions of database users.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 217


 Authentication control: Refers to controlling if the user is the one he/she claims to be.
 Authorization control: Refers to controlling if the user is allowed to access and use the
database.
 Integrity control: refers to controlling the trustworthiness or faithfulness of information
over its entire life cycle.
 Backup: The process of backing up a database refers to copying and archiving the
database so that it may be used to restore the original after a data loss event.
 Database Application security: The application used to access and use the database
should also be controlled and secured

33. The table below is called Cars, observe it clearly and respond to the questions related.
Mark Plaque Series Number
BENZ R15 RLL 451212
TORD C12 RCC 421213
FUSSO CO13 RTT 421314
CARINA ES10 MAC 451315
a. What will be the output of this query on the table?

ANSWER:
SELECT Mark, Series FROM Cars order by Mark ASC;
b. Write the SQL commands to display
Plaque
R15
C12
CO13
ES10
State the output of those queries:
c. SELECT * FROM Cars WHERE Plaque =R15
d. SELECT * FROM Cars WHERE Plaque <>R15
e. SELECT * FROM Cars OREDER BY Mark ASC

a.

Mark Series
BANZ RLL
CARINA MAC
FUSSO RTT
TORD RCC

b. Select * from Cars;


c.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 218


Mark Plaque Series Number
BANZ R15 RLL 451212
d.

Mark Plaque Series Number


TORD C12 RCC 421213
FUSSO CO13 RTT 421314
CARINA ES10 MAC 451315
e.

Mark Plaque Series Number


BANZ R15 RLL 451212
CARINA ES10 MAC 451315
FUSSO CO13 RTT 421314
TORD C12 RCC 421213

34. Group the following SQL commands (SELECT, UPDATE, REVOKE, CREATE,
DELETE, ALTER, DROP, INSERT, GRANT) according to:
a. Data Definition Language(DDL) commands,
b. Data Manipulation Language (DML) commands, and
c. Data Control Language (DCL) commands.
ANSWER:

UNIT 5 ARRAYS, FUNCTIONS AND PROCEDURES

35. Give The general format to declare a one dimensional array in vb6.0 and give an
example

ANSWER:
Dim arrayName(subs) as dataType where subs indicates the last subscript in the array.
Example
Dim StudName(10) as String

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 219


36. Write a VB program which allow a user to Input 10 elements of an array and then
displays those numbers

ANSWER:

Private Sub Command1_Click()


dim numbers(10) As integer
dim i As Integer
For i = 1 To 10
numbers(i) = InputBox("Input ten numbers", "Input number")
Next i
For i = 1 To 10
List1.Item numbers(i)
Next i
End sub

37. Define function prototype and give their syntax in visual basic

ANSWER:

A function prototype is simply the declaration of a function that specifies function's name,
parameters and return type. It doesn't contain function body. A function prototype gives
information to the compiler that the function may later be used in the program.

Syntax of function prototype in VB


Function Function Name(arg1 As type1, arg2 As type2, ...) As return data types
In the above example public,
Function FunctionName(argument1 As type1, argument As type2,...) As return data types

38. Write a VB program using Input box that accept an integer value from the keyboard
displays its sinus, cosinus and tangent

ANSWER:

Private Sub Command1_Click()


Dim N As Integer
Dim sinresult, cosresult, tanresult As Double
N = Val(InputBox("Input number", "Input number"))
sinresult = Sin(N)
cosresult = Cos(N)
tanresult = Tan(N)
Print ("The entered number is "); N
Print ("Its sinus is:"); sinresult
Print ("Its cosinus is: "); cosresult
Print ("Its tangente is:"); tanresult
End Sub

39. Design a VB function program to find Factorial of an entered number

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 220


ANSWER:
Private Sub Command1_Click()
Dim Num As Integer
Num = Val(InputBox("Enter a number you want to calculate Factorial: ", "Number"))
Print (" The factorial of "); Num
Print ("is: "); CalFact(Num)
End Sub
Function CalFact(ByRef Number)
Dim Fact As Integer
Fact = 1
For i = Number To 1 Step -1
Fact = Fact * i
Next i
CalFact = Fact
End Function

40. Mention when to use Function procedures and what are its characteristics?

ANSWER:
You use Function procedures when you want to execute a series of statements and return a value.
Function procedures start and end with Function and End Function statements
A function procedure may or may not take input.
Function procedures return a value by assigning the value to its name

UNIT 6 VISUAL BASIC PROJECT

41. Give the syntax and example of a method to add data in database connected to a VB
project using ADO.

ANSWER:
add new
Syntax: control name.recordset.Add new
Ex:Adddc1.recordset.add row

42. What is Front end?

The term Front End refers to the user interface, where the user interacts with the program
through the use of the screen forms and reports.

43. Suppose you have connected your VB project to Ms_Access database, give the syntax
and example of:
a) to add a record into your database
b) to delete a record by preventing the blank record

a)Add record into a database


To add a record into a database we use the method AddNew.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 221


Syntax: Controlname.RecordSet.AddNew
Ex. Adodc1.RecordSet.AddNew
b)Delete a record
To delete a record, we use delete method:
Private Sub CmdDelete_Click()
Adodc1.RecordSet.Delete
End Sub
NOTE: To prevent the display of blank record, we move the record:
Private Sub CmdDelete_Click()
Adodc1.Recordset.Delete
End sub
44. ISHIMWE wants to connect MS Access database to his VB form, but unfortunately he
does not see ADO data control on visual basic toolbox. What are the steps can you tell him to
follow so that he can be able to view ADO on visual basic toolbox?

ANSWER:

Add the ADO control on the form, perform the following steps:
1. Select the command Component in the project menu
2. Click on Controls in the dialog box which opens
3. Select
Microsoft Ado Data Controls 6.0 (OLEDB)
4. Click ok button
5. This control will be added to the toolbox.
6. To connect ADO objects on the data source use a «Connection String» and specify the
datasource (the database name you want to connect)
7. Then you have to specify the access path after clicking the connection property.

45. What are the three ways to connect to a database in visual basic?

ANSWER:
There are three ways to connect to a database: using a data link, using an ODBC data source and
connection string (that has been used in student content).

UNIT 7 PROCESS MANAGEMENT AND SCHEDULING ALGORITHM

46. Using a diagram, show all 3 states of a process to be executed?

Ready Interruption or Blocked

Quantum expires Release Waiting

Running

ANSWER:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 222


 Every process must pass first in Ready state before being executed
 Then if the processor is ready for the operation, the process passes in the running so as to
be processed.
 When an error is occurred, the process will pass to the blocked state (will be interrupted).
 The process will be stopped only at:
 A new request from the I/O device

47. Explain the following terms:


i. Thread
ii. Process
iii. Process control block
iv. Deadlock
v. Process scheduling

ANSWER:

i. Thread is the smallest unit of processing that can be performed in an Operating System. A
thread is also called a lightweight process. Threads provide a way to improve application
performance through parallelism

ii. A process is a program in execution. It is an instance of program execution and it is not as


same as program code but a lot more than it. A process is an 'active' entity as opposed to program
which is considered to be a 'passive' entity. Attributes held by process include hardware state,
memory, CPU etc.

iii. Process control block is a data structure maintained by the Operating System for every
process. It is also called Task Control Block and it is storage for information about processes.

iv. Deadlock is a situation where a process or a set of processes are blocked, waiting for some
resource that is held by some other waiting processes. Here a group of processes are permanently
blocked as a result of each process having acquired a subset of the resources needed for its
completion and waiting for the release of the remaining resource held by other processes in the
same group. This makes it impossible for any of the processes to proceed

v. Process scheduling refers to the order in which the resources are allocated to different
processes to be executed. Process scheduling is done by the process manager by removing
running processes from the CPU and selects another process on the basis of a particular strategy

48. Consider the following set of processes with their arrival time and CPU burst time in
milliseconds.
Process CPU Burst Time (ms) Arrival time

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 223


A 24 0
B 3 0
C 3 0

When A, B and C arrive in the order A, B, C


Calculate:
a. Average Wait Time (AWT)
b. Average Turnaround Time (ATA)
c. Draw a Gantt Chart

ANSWER:

The wait time of each process is calculated as follows:

Wait Time: Completion Time –Burst time

Wait Time
Process
A 0
B 24
C 27

a. Average Wait Time (AWT)= (0+24+27) / 3 = 17ms


b. And Average Turnaround Time (ATAT) = (24+27+30)/3 = 27ms
c.

49. What is the major difference between process and program

ANSWER:

The major difference between a program and a process is that a program is a set of instructions
to perform a designated task whereas the process is a program in execution.
A program is in the secondary storage. A process is loaded into the main memory.
A program consists of a set of instructions in a programming

50. List three Objectives of Process Scheduling Algorithms

ANSWER:

 Maximization of CPU utilization by keeping the CPU as busy as possible.


 Fair allocation of CPU to the processes.
 To maximize the number of processes that complete their execution per time unit. This is
 called throughput.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 224


 To minimize the time taken by a process to finish its execution.
 To minimize the time a process waits in ready queue.
 To minimize the time it takes from when a request is submitted until the first response is
 produced.

51. What are the five major activities of an operating system in regard to process
management?

ANSWER:

 Creation and deletion of user and system processes.


 Suspension and resumption of processes.
 A mechanism for process synchronization.
 A mechanism for process communication.
 A mechanism for deadlock handling.

UNIT 8 FILE MANAGEMENT

52. List and explain five file operations in file management system

ANSWER:

Five file operations in file management system are:

 Open: Make a file read for processing


 Close: Make a file unavailable for processing
 Read: Input data from the file
 Write output data to file
 Seek: select a position in the file for subsequent data transfer

53. Explain three types of files

ANSWER:
a) Ordinary Files or Regular File
Therefore, all files created by a user are Ordinary Files and belong to any type of application
program.
Ordinary Files are used for storing the information about the user Programs
Example: Notepad, Paint, C Program, Songs, Database, Image

b) Directory files
There are files stored into the particular directory or folder.
Example: a folder named songs which contains many songs.
c) Special Files

The special files are files which are not created by the user and are files needed to run a System
and are created by the Operating System. It means all the files of an operating system are
referred as special files.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 225


54. List three access file mechanism

ANSWER:
There are 3 ways to access files: Sequential access, Direct Access and Index Access

55. What is file space allocation?

ANSWER:

File space allocation is the method by which data is apportioned physical storage space in the
operating system.

There are three types of allocation:


 Contiguous allocation
 Linked allocation
 Indexed allocation

56. What is the function of file management in operating system?

ANSWER:
A file management program is a tool for organizing files into folders on your computer, as well
as locating, moving, opening and copying existing files.

57. Explain how files are managed by operating system.

ANSWER:
The OS allows you to organize the contents of your computer in a hierarchical structure of
directories that includes files, folders, libraries, and drives. Windows Explorer helps you manage
your files and folders by showing the location and contents of every drive, folder, and file on
your computer

UNIT 9 MEMORY MANAGEMENT

58. What are the principle problems to be handled by the operating system’s memory
management?

ANSWER:
 To provide the memory space to enable several processes to be executed at the same
time.
 To provide a satisfactory level of performance (process execution speed) for the system
users.
 To protect each process from each other.
 Where desired, to enable sharing of memory space between processes.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 226


 To make at the addressing of memory space as transparent as possible for the
programmer.

59. What is the difference between a page and a segment?

ANSWER:
A page is a fixed subdivision of a process. This division is done according to the fixed size. A
segment is a variable subdivision of a process. The size reflects the logical structure of a process.

60. What is a virtual memory?

ANSWER:
Virtual memory is a memory created by the operating system when swapping processes
between the space on the secondary memory and the main memory.

61. Briefly, give the difference between fixed partition and variable partition?

ANSWER:

 Fixed partition is a process of dividing a memory into fixed blocks which cannot
be changed.
 Variable partition is a process of dividing a memory into variable blocks which
can be changed according to the size of the process.

62. What are characteristics of a memory?

ANSWER:
 Capacity
 Type (Primary: RAM, registers, cache memory. Secondary: Hard disk, CD,DVD,
memory card, etc)
 Speed (Read/Write)
 Form (depends on manufacturer)
 Non-volatility

63. What is The difference between memory and storage

ANSWER:
The term memory refers to the amount of RAM installed in the computer whereas the term
storage refer to the capacity of the computer’s hard disk. Computers have two kinds of storage:
temporary and permanent. A computer’s memory is used for temporary storage, while a
computer’s hard drive is used for permanent storage.

64. Explain the following policies: best fit policy, first fit policy, and worst fit policy

ANSWER:
 Best fit policy: an incoming process is placed in a hole in which it fits mostly ‘tightly’

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 227


 First fit policy: an incoming process is placed in the first available hole which can
accommodate it.
 Worst fit policy: an incoming process is placed in the hole which leaves the maximum
amount of unused space, which logically must be the current largest hole.

65. Differentiate internal fragmentation and external fragmentation

ANSWER:
In reality, all processes are not of same size but they are of different size. With this scheme,
small process will occupy some partition and a lot of space in this partition will be wasted,
because in one partition only one program (process) can be loaded. This wastage is called
“Internal fragmentation”. Sometimes some programs occupy some memory area, after their
completion; they release this area. But if these released areas are far (non-contiguous), a big
program cannot be loaded in memory. This problem is called “External Fragmentation”.

134) Write a VB program using Input box that accepts an integer value from the keyboard
displays its sinus, cosinus and tangent.

ANSWER:

Private Sub Command1_Click()


Dim N As Integer
Dim sinresult, cosresult, tanresult As Double
N = Val(InputBox("Input number", "Input number"))
sinresult = Sin(N)
cosresult = Cos(N)
tanresult = Tan(N)
Print ("The entered number is "); N
Print ("Its sinus is:"); sinresult
Print ("Its cosinus is: "); cosresult
Print ("Its tangente is:"); tanresult
End Sub

135) You are given a flat database named “Library”, with a relation Book (ISBN (Text, primary
key), title (text), author (text), pages (integer), and price (integer)).

i.Create this database and relation, then insert at least five records.

ANSWER:
Create database Library;
Use Library;
Create Table Book(ISBN Text(50), title text(20) , author text(20), pages int(20), price int(20),
primary key(ISBN)) ;
Insert into Book values (………..);

ii. Retrieve the amount to get when all books are sold.
ANSWER:

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 228


Select sum(Price) as Total_Amount from Book;
iii.Retrieve the most expensive book.

ANSWER:
Select Title, max (Price) as Most_Expensive from Book;

iv. Select the least expensive book


ANSWER:

Select min (Price) as Cheap_Book from Book;

v. Show the total number of the books in book relation.


ANSWER:
Select count(ISBN) as Total_Number_of_Books from Book;

vi. Find the average price of the books


ANSWER:

Select avg (price) as Average_Price from Book;

vii. Reverse the name of the author who wrote the book “Imigenzo”.
ANSWER:
Select Author, reverse(Author) as Reversed_Name from Book where Title=’ Imigenzo’

viii.Compare the names “Aloys” and “Alexis”.


ANSWER:

Select strcmp(‘Aloys’,’Alex’);

ix. Change “Ndi umunyarwanda” in upper case.


ANSWER:

Select upper(‘Ndi umunyarwanda’);

x. Change “HELP EACH OTHER” in lower case

ANSWER:

Select lower(‘HELP EACH OTHER’);

UNIT 10 COLLECTIONS IN JAVA

66. What are the benefits of Java Collections Framework?

There are primarily four qualities that make Java Collections Framework extremely useful for
the programmers.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 229


ANSWER:

 Performance – Collection classes are highly efficient data structures to improve speed
and accuracy.
 Reusability – Collection classes can intermix with other types to promote reusability.
 Maintainability – Supports consistency and interoperability in the implementation and
hence makes the code easy to maintain.
 Extensibility – Allows customization of primitive collection types as per developer’s
requirements.

67. A tree is a connected simple path without cycles. The traversal is the process of visiting
all the nodes in the tree. Since the tree is non-linear data structure, there is no unique traversal.
Consider this traversal visits nodes by levels, from top to bottom left right:

a. Represent all nodes using pre-order traversals


b. Represent all nodes using in-order traversals
c. Represent all nodes using post-order traversals
d. Represent all nodes using level-order traversals

Visiting a Tree:
Pre-order: 8, 5, 9, 7, 1, 12, 2, 4, 11, 3
In=order: 9, 5, 1, 7, 2, 12, 8, 4, 3, 11
Post-order: 9, 1, 2, 12, 7, 5, 3, 11, 4, 8
Level-order: 8, 5, 4, 9, 7, 11, 1, 12, 3, 2

68. a. What interface represents a collection that does not allow duplicate elements?

ANSWER: Set
b.What interface represents a double-ended queue?

ANSWER: Deque

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 230


c.What interface represents an ordered collection that may contain duplicate elements?
ANSWER: List

d.What interface represents a collection that holds elements prior to processing?

ANSWER: Queue

e.What interface represents a type that maps keys to values?

ANSWER: Map
482) Write a pseudocode that takes length and width of a rectangle, then calculates its area and
perimeter.

ANSWER:

BEGIN
PRINT Enter length of rectangle
READ length;
PRINT Enter width of rectangle
READ width;
Area = length x width
Perimeter = 2 x (length + width)
PRINT area, perimeter
END

483) Neema deposited FRW 200,000 in his savings account. The amount deposited earns a 3%
annual interest. Design an algorithm that would be used to calculate interest after n years.
ANSWER:

Var: deposit, rate, amount as double


BEGIN
PRINT Enter deposit
READ deposit
PRINT Enter interest rate
READ rate;
Amount = deposit x (1.03)n
PRINT Amount
END.

484) Write an algorithm to accept any given number and prove that the given number is Odd or
Even.

ANSWER:
Var number as integer
Start
Write(“ Enter any number”)
Read number

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 231


If(number mod 2==0) then
Write(“the given number is even”)
Else
Write(“the given number is odd”)
End if
End
485) Write an algorithm that asks the user to enter two numbers and it displays the product of
that numbers if is null, negative or positive.

ANSWER:
Var number1, number2, product as integer

Write (“Enter any two numbers”)

Read(number1, number2)

Product=number1*number2

If(product>0)then

Write (“The product is positive”)

Else if (product<0) then

Write (“The product is negative”)

Else

Write (“The product is null”)

End if

End

486) Write a VB program that requests the user to enter 2 numbers and displays their sum,
difference and product.
Answer:

Private Sub add_Click()


Dim num1,num2, Product, Difference, Sum As Integer
num1 = Val(Text1.Text)

num2 = Val(Text2.Text)
Sum = num1 + num2
Difference=num1-num2
Product=num1*num2
Text3.Text = Sum
Text4.Text = Product

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 232


Text5.Text = Difference
End Sub

487) Write C++ program to print the following pattern:

*
* *
* * *
* * * *
* * * * *
* * * * * *
ANSWER:

#include <iostream>
using namespace std;

int main()
{
int rows=6;

for(int i = 1; i <= rows; ++i)


{
for(int j = 1; j <= i; ++j)
{
cout << "* ";
}
cout << "\n";
}
return 0;
}

488) Write an algorithm and and a C++ program to accept any given number and prove that the
given number is odd or even.

ANSWER:
An algorithm
Variable a as integer
Start
Write(“Enter any number “)
Read
If(a mod2 ==0) then
Write(“ a is even”)
Else
Write (“a is odd”)
End if

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 233


End

C++ program
# include<iostream>
Using namespace std;
Int main () {
Int x;
Cout<< “ Enter any number”<<endl;
Cin>>x;
If(x%2==0){
Cout<<x<<” : is even ”<<endl;}
Else{
Cout<<x<<” : is Odd”<<endl;}
Return 0;
}

489) Write an algorithm which receives a number and informs the user whether the given
number is Positive or Negative.

ANSWER:
Var number as integer
Start
Write(“ Enter any number”)
Read number
If(number mod 2=0) then
Write(“the given number is even”)
Else
Write(“the given number is odd”)
End if
End

490) Write a C++ program that decreases the numbers from 100 to 1 number and when it
reaches to number 67 it skips that iteration, using a while loop.

ANSWER:
#include<iostream>
using namespace std;
int main (){
int number;
for(number=100; number > = 1; number--){
if (number==67) continue;

cout<< number <<" , ";


}
return 0;}

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 234


491) Write a C++ program that receives three numbers entered by the user and find Smallest
Number.

#include <iostream> #include <iostream>


using namespace std; using namespace std;
int main() { int main() {
float n1, n2, n3; float n1, n2, n3;
cout << "Enter any three numbers: "<< endl; cout << "Enter any three numbers: "<< endl;
cin >> n1 >> n2 >> n3; cin >> n1 >> n2 >> n3;
if(n1 < n2 && n1 < n3) { if(n1 <= n2 && n1 <= n3) {
cout << " The Smallest number is : " << n1<< cout << " The Smallest number is : " << n1<<
endl; } endl; }
else if(n2 < n1 && n2 < n3) { else if(n2 <= n1 && n2 <= n3) {
cout << "The Smallest number is : " << n2<< cout << "The Smallest number is : " << n2<<
endl; } endl; }
else if(n3 < n1 && n3 <n2) { else if(n3 <= n1 && n3 <= n2) {
cout << " The Smallest number is : " << n3<< cout << " The Smallest number is : " << n3<<
endl; } endl; }
else{ else{
cout << " Invalid input " << endl; } cout << " Invalid input " << endl; }
return 0;
} return 0;
}

492) Write a C++ program that would be used to display odd integers between 1 and 200.

ANSWERS:

ANSWER: ANSWER:
#include <iostream> #include <iostream>
using namespace std; using namespace std;
int main () { int main () {
int number ;
for (int count=1; count<=200;
number=1;
count=count+2 ) { while (number <= 200) {
cout << count << " , "; if(number%2 !=0)
} cout <<number <<endl;
returnQUESTIONS
0;} AND ANSWERS OF COMPUTER SCIENCE number ++; 235

}
return 0; }
ANSWER:
ANSWER: #include<iostream>
#include <iostream> using namespace std;
using namespace std; int main () {
int main () { int number ;
int number ; number=1;
number=1; do {
while (number <= 200) { cout <<number <<endl;
cout <<number <<endl; number = number + 2;
number = number + 2; }while (number <= 200);
} return 0;
return 0; } }

493) Write a C++ program that asks the user to input the radius of the circle and displays its
Area and Circumference, Using Const double PI=3.14.

ANSWER:

#include<iostream>
using namespace std;
int main () {
const double PI = 3.14;
double radius, area, circumference;
cout << "Enter the radius of Circle:"<<endl;
cin >> radius;
circumference= (2 * radius )* PI;
area = (radius * radius )* PI;
cout <<"Circumference = "<<circumference<< endl;
cout << "Area = "<<area<< endl;
return 0;}

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 236


494) Write an algorithm that asks the user to enter two numbers and it displays the product of
that numbers if is null, negative or positive.

ANSWER:

Var number1, number2, product as integer


Write (“Enter any two numbers”)
Read (number1, number2)
Product=number1*number2
If (product>0) then
Write (“The product is positive”)
Else if (product<0) then
Write (“The product is negative”)
Else
Write (“The product is null”)
End if
End

495) Write a C ++ program that prompts a user to enter the radius of a sphere, the program then
calculates the surface area and volume of the sphere. In the source code, you must declare Pi as a
symbolic constant whose value is 3.142.

ANSWER:

#include<iostream>
using namespace std;
int main(){
const double pi = 3.142;
double radius, volume, area;
cout << "Please enter the radius of sphere" << endl;
cin >> radius;
volume = ((4.0 / 3.0) * pi * radius*radius*radius);
area = 4.0 * pi * radius*radius;
cout << "The volume area is: "<< volume << endl;
cout << "The surface area is: "<< area << endl;
return 0;
}

OR

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 237


#include<iostream>
#include<cmath>
using namespace std;
int main(){
const double pi = 3.142;
double radius, volume, area;
cout << "Please enter the radius of sphere" << endl;
cin >> radius;
volume = ((4.0 / 3.0) * pow(radius,3)*pi );
area = 4.0 * pi *pow(radius,2);
cout << "The volume area is: "<< volume << endl;
cout << "The surface area is: "<< area << endl;
return 0;}

496) Write an algorithm that asks the user to enter two numbers and it displays the product of
those numbers if it is null, negative or positive.

ANSWER:

Var a:integer
Var:integer
Start
Write(“Enter The First Number”)
Read(a)
Write(“Enter The Second Number”)
Read(b)
If(a < 0 and b > 0)
Write(“The Product is Negative”)
Else If (a< 0 and b=0)
Write(“The Product is Null”)
Else If (a< 0 and b < 0)
Write(“The Product is Positive”)
Else If (a > 0 and b > 0)
Write(“The Product is Positive”)
Else If (a = 0 and b = 0)
Write(“The Product is Null”)
End if end

OR

Var: a, b, product as integer


Write(“ Enter Two Numbers”)
Read(a,b)
Product ← a*b
If(Product > 0) then
Write(“The Product is Positive”)
Else if (Product < 0) then
Write(“The Product is Negative”)

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 238


Else
Write(“The Product is Null”)
End if
End

497) Discuss the advantages and disadvantages of high-level languages.


ANSWER:

Advantages
 High level languages are portable i.e. they are transferable from one computer to another.
 High level languages are user friendly and easy to use and learn.
 High level languages are more flexible, hence they enhance the creativity of the
programmer and increase productivity in the workplace.
 A program in high level languages is easier to debug.

Disadvantages
 Their nature encourages use of many instructions in a word or statement hence the
complexitof these instructions cause slower program processing.
 They have to be interpreted or compiled to binary form before the computer can execute
them.
 They require large computer memory to run.

498) Using pow () Function, write a C++ program to compute the power of a given number.
ANSWER:

#include<iostream>
#include<cmath>

using namespace std;

int main()
{
double base, ThePower, result;

cout << "Enter any number: "<<endl;


cin >> base;
cout << "Enter the power respectively:"<<endl;
cin>> ThePower;

result = pow(base, ThePower);

cout<<"The Power of entered number: "<< base << "^" << ThePower << " = " << result;

return 0;}

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 239


499) Write a C++ program that prompts the user to enter a number and check whether the
entered number is Even or Odd using ternary operators.
ANSWER:

#include <iostream>
using namespace std;

int main() {
int n;

cout <<"Enter any number integer of your choice:"<<endl;


cin >> n;

(n % 2 == 0) ? cout<<"The entered number: "<<n<<" is even." : cout<<"The entered number:


"<<n<< " is odd."<<endl;

return 0;
}

500) Write a C++ program that calculates and displays alternative roots of a quadratic equation:
root = ax2 + bx + c.
ANSWER:

#include <iostream>
#include <cmath>
using namespace std;
int main() {
double a, b, c;
double x1, x2, delta;
cout<< "Enter the coefficient: a"<<endl;
cin >> a;
cout<< "Enter the coefficient: b "<<endl;
cin>> b;
cout<< "Enter the coefficient: c "<<endl;
cin>> c;

delta = (pow(b,2) - 4*a*c);


x1 = (((-b) + sqrt(delta))/(2*a));
x2 = (((-b) - sqrt(delta))/(2*a));

if (delta == 0) {
cout<<"The delta is " << delta <<endl;
cout <<"x1=x2 :"<<x1<<endl;
}
else if (delta > 0) {
cout<<"The delta is " << delta <<endl;
cout<<"x1 = "<< x1<<endl;
cout<<"x2 = "<< x2<<endl;

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 240


}
else {
cout <<"The equation has complex roots."<<endl;
}
return 0;
}

501) Write a C++ program that uses an array to find the sum and average marks obtained by 20
students.
ANSWER:

#include<iostream>
using namespace std;
int main(){
int marks[20] ,i, sum=0;
float average;
cout<<"Please enter Twenty marks:"<<endl;
for (int i = 0; i < 20; i++){
cin>>marks[i];
}
for (i = 0; i < 20; i++){
sum=sum+marks[i];
}
average=sum/20;
cout<<"Sum = "<<sum<<endl;
cout<<"Averages Marks= "<<average<<endl;
return 0;}

502) Write a function program named “multiplying ()” in C ++ programming language to get
the product of two numbers entered by a user.

ANSWER:

#include<iostream>
using namespace std;

int multiplying (int a, int b){


int c;
c=a*b;
return(c);
}
int main() {

int x, y, product;
cout<<"Please enter the first number:"<<endl;
cin>>x;

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 241


cout<<"Please enter the second number:"<<endl;
cin>>y;
product = multiplying (x,y);
cout<<"The Product = "<<product<<endl;
return 0;}

503) Write a C ++ Function program to print Fibonacci series (0 1 1 2 3 5 8 13).

ANSWER:

// Fibonacci series using Function


// Fibonacci series without using Function
#include<iostream> #include <iostream>
using namespace std; using namespace std;
int fibonacci(int n){ int main() {
if((n==1)||(n==0)) { int n1=0,n2=1,n3,x,number;
return(n); cout<<"Enter the number of elements:
} "<<endl;
else { cin>>number;
return(fibonacci(n-1)+fibonacci(n-2)); cout<<n1<<" "<<n2<<" "; //printing 0 and 1
}} for(x=2;x<number;++x) //loop starts from 2
int main(){ because 0 and 1 are already printed
int n, i=0; {
cout<<"Enter number of terms for Fibonacci n3=n1+n2;
Series:"<<endl; cout<<n3<<" ";
cin>>n; n1=n2;
cout<<"The is the Fibonnaci Series :"; n2=n3;
while(i<n) { }
cout<<" , "<<fibonacci(i); return 0; }
i++;}
return 0;}

504) Write a C++ program that prompts the user to input a positive integer and calculate, then
display the Factorial of that given number.

ANSWER:

#include<iostream> #include <iostream>


using namespace std; using namespace std;
int factorial (int n){ int main() {
if (n > 1) int n;
return (n * factorial (n-1)); int factorial = 1;
else return 1; cout << "Enter a positive integer: "<<endl;
}QUESTIONS AND ANSWERS OF COMPUTER SCIENCE cin >> n; 242

int main () { for(int x = 1; x <=n; ++x) {


int number, result; factorial = factorial * x;
cout << "Please type a number: "<<endl; }
505) Write a required code to make a program that calculates the volume of a cylinder using the
VB interface as designed below:

When you run the program, you should be able to see the interface as shown in. If you enter a
value each in the radius box and the height box, then click Calculate; the value of the volume
will be displayed in the volume box.

ANSWER:

Private Sub Command1_Click()

Dim radius, height, volume As Double

Const Pi As Double = 22 / 7

radius = Val(Text1.Text)

height = Val(Text2.Text)

volume = Pi * (radius ^ 2) * height

Text3.Text = volume

End Sub

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 243


506) Below is a table that contains information of teachers.

TEACHER
No Names of Age Department Date of joining Salary Sex
Teacher
1 Ndahimana 36 Computer 12-Jan-99 150000 M
2 Kamili 59 Maths 4-Mar-86 250000 M
3 Neema 30 Entrepreneurship 30-Jun-12 120000 F
4 Harima 29 Geography 1 10-Apr-10 130000 F
5 Kasiimu 43 Geography 2 12-Feb-88 200000 M
6 Nzabandora 32 Physics 1-Feb-00 230000 M
7 Ruterana 45 Kinyarwanda 12-Aug-85 240000 M
8 Shakilla 29 Maths 13-Jul-12 150000 F
9 Jackline 31 Geography 1 12-Jan-11 120000 F
10 Jack 40 Physics 11-Sep-99 200000 M
11 Mutessa 28 Computer 9-Nov-14 120000 M

Write SQL commands:

a) To find the teacher that did not join on the date of (“1/feb/2000” , “ 4/mar/1986” , “
12/feb/1988”)

ANSWER:

SELECT *FROM TEACHER WHERE DateofJoin NOT IN of (“1/feb/2000” , “ 4/mar/1986” ,


“ 12/feb/1988”);

b) To show all information about the teacher of Maths Department.

ANSWER:

SELECT *FROM TEACHER WHERE DEPARTMENT=”Maths”;

c) To list the name and age of the female Teachers who are in the Geography 1 Department.

ANSWER:

SELECT NameT, age FROM TEACHER WHERE Sex=’f’ AND DEPARTMENT=


‘Geogrphy1’;

d)To list the names of all Teachers whose age is greater than 30 with their date of joining in
ascending order?

ANSWER:

SELECT NameT , DateofJoin FROM TEACHER WHERE age>’30’ ORDER BY DateofJoin;

e)To display the Names, Age and Salary for male teachers only.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 244


SELECT NameT, Salary, Age FROM TEACHER WHERE Sex=’m’;

f)Arrange the whole table in the alphabetical order of names.

ANSWER:

SELECT *FROM TEACHER ORDER BY NameT;

g)Display all Teachers whose Names contain the character “n”.

ANSWER:

SELECT *FROM TEACHER WHERE NameT like ’*n*’;

h)Remove duplicates Department from the table.

ANSWER:

SELECT DISTINCT Department FROM TEACHER;

507) Given the following software:

Ms Word 2016, Kaspersky, Windows 8, Ms Excel 2016, Photoshop, Ms access 2016

a) Which is an operating system?


b) Which is application software?
c) Which is word processor software?
d) Which is database software?
e) Which is spread sheet software?
f) Which are Microsoft office programs?

g) Which is graphic software?


h) Which is antivirus software?
i) Which is must be installed firstly into a new computer? Why?

ANSWER:

a. Window 8
b. Ms word, Kaspersky, ms excel2016, photoshop, ms access 2016
c. Ms Word
d. Ms Access
e. Ms Excel
f. Ms Word, Ms Excel, Ms Access
g. Photoshop
h) Kaspersky

i) Windows 8: It is an Operating System, if is not installed firstly, that new computer cannot
work.

QUESTIONS AND ANSWERS OF COMPUTER SCIENCE 245

You might also like