S5-COMP-MCE-Q-A
S5-COMP-MCE-Q-A
DURATION: 3HOURS
INSTRUCTIONS
1
Section A: Attempt all 12 questions from this section (55marks)
1. Choose the correct answer, what is the most important safety precaution to
take when cleaning a laptop? (3 marks)
a) Use harsh chemicals.
a) Len()
b) Length()
c) StrLength()
d) StringLength()
11. When running a Java program with multiple classes, how does the Java
Virtual Machine (JVM) identify the main class? (4 marks)
2
C) By using the class specified with the -cp option
D) By using the class specified with the public static void main(String[] args)
method
3
Section B: Attempt any (3) three questions from this Section (30marks)
13. Write a C++ Program to find the Fibonacci series up to a given term.
(10 marks)
14. Analyse the program given below and give its output appropriately.
(10 marks)
#include <iostream>
int main() {
int arr[5] = {10, 20, 30, 40, 50};
}
std::cout << "\nModified elements of the array using pointer:\n";
}
return 0;
}
15. Consider the following declarations and answer the questions given
below: (10 marks)
class living_being {
char name[20];
protected:
void outputdata(); }
4
class animal: protected living_being {
int tail;
protected:
int legs;
public:
void writedata();
(i) Name the base class and derived class of the class animal.
(ii) Name the data member(s) that can be accessed from function displaydata.
(iii) Name the data member(s) that can be accessed by an object of cow class.
17. Write Java program that uses an array to calculate the sum of the first
20 numbers. (10 marks)
5
Section C: Attempt any (1) one question from this Section (15marks)
19. Write a Java program that reads data from a file named "source.txt"
using FileInputStream and writes it to a file named "destination.txt"
using FileOutputStream. (15 marks)
6
COMPUTER SCIENCE
DURATION: 3HOURS
INSTRUCTIONS
7
Section A: Attempt all 12 questions from this section (55marks)
1. Choose the correct answer, what is the most important safety precaution to
take when cleaning a laptop? (3 marks)
a) Use harsh chemicals.
Answer
Example:
Talkie- Walkie
intercom,
string phone
Full-Duplex: the communication between sender and receiver can occur
simultaneously. or data flows in both directions at the same time.
both
direction at the same times
Example:
telephone conversation
8
was widely used in the early days of computing, but it has since been
replaced by more flexible models such as the relational model.
The tables or relation are related to each other. The relational model is
the most widely used database model.
4. Define many to one relationship and give an example. (5 marks)
Answer
In a many-to-one relationship, multiple entities or records from one
entity can be associated with a single entity or record from another
entity.
Transitive Dependency:
9
Implication: Transitive dependency violates the second normal form (2NF) in
database normalization.
Answer
A class is a template for creating objects, whereas an object is an instance of
a class. For example, "Car" is a class, and "BMW" or "Toyota" are objects of
the "Car" class.
7. List any 5 basic Object Oriented Programming concepts. (5 marks)
Answer
Classes.
Objects
Encapsulation
Abstraction
Inheritance
Polymorphism
Interfaces
Answer
Debugging is the process of identifying, isolating, and fixing errors or bugs in
computer software or hardware. The goal of debugging is to ensure that the
program runs as intended and produces the expected output without errors or
unexpected behavior.
a) Len()
b) Length()
c) StrLength()
d) StringLength()
answer
a) Len()
10
10. Define method overloading and give an example. (5 marks)
Answer
Method overloading is a feature in object-oriented programming where a class
can have multiple methods with the same name but with different parameters
or arguments. In method overloading, the methods must have the same name
but can differ in the number, order, or type of parameters.
11. When running a Java program with multiple classes, how does the Java
Virtual Machine (JVM) identify the main class? (4 marks)
method
Answer
D) By using the class specified with the public static void main(String[] args)
method
11
D) It defines a new method in a class.
Answer
B) It allocates memory for a new object.
Section B: Attempt any (3) three questions from this Section (30marks)
13. Write a C++ Program to find the Fibonacci series up to a given term.
(10 marks)
Answer
#include<iostream>
using namespace std;
main() {
int n, c, first = 0, second = 1, next;
cout << "Enter the number of terms of Fibonacci series you want" <<
endl;
cin >> n;
cout << "First " << n << " terms of Fibonacci series are :" << endl;
#include <iostream>
int main() {
int arr[5] = {10, 20, 30, 40, 50};
12
int *ptr = &arr[4];
std::cout << "Elements of the array accessed using pointer:\n";
}
std::cout << "\nModified elements of the array using pointer:\n";
}
return 0;
}
Answer
15. Consider the following declarations and answer the questions given
below: (10 marks)
class living_being {
char name[20];
protected:
13
void outputdata(); }
int tail;
protected:
int legs;
public:
void writedata();
(i) Name the base class and derived class of the class animal.
(ii) Name the data member(s) that can be accessed from function
displaydata.
(iii) Name the data member(s) that can be accessed by an object of cow
class.
(iv) Is the member function outputdata accessible to the objects of
animal class.
Answer
(iv) No
14
Vb6.0 Vb.net
Private Sub Public Class Form1
Command1_Click()
Dim a As Integer Private Sub
Dim result As Button1_Click(sender As Object,
Integer e As EventArgs) Handles
a = Val(Text1.Text) Button1.Click
result = a * a * a
Label1.Caption = Dim a As Integer
result Dim result As Integer
End Sub
a = Val(TextBox1.Text)
result = a * a * a
Label1.Text = result
End Sub
End Class
17. Write Java program that uses an array to calculate the sum of the first
20 numbers. (10 marks)
Answer
int sum = 0;
numbers[i] = i + 1; }
sum += numbers[i]; }
15
Section C: Attempt any (1) one question from this Section (15marks)
Next
End Sub
End Class
19. Write a Java program that reads data from a file named "source.txt"
using FileInputStream and writes it to a file named "destination.txt" using
FileOutputStream. (15 marks)
Answer
import java.io.*;
public class Filecopy {
16
public static void main(String[] args) {
// Step 1: Define the input and output filepaths
String sourceFile = "source.txt";
String destinationFile = "destination.txt";
// Step 2: Create FileInputStream and FileOutputStream objects
try (FileInputStream inputStream = new
FileInputStream(sourceFile);
FileOutputStream outputStream = new
FileOutputStream(destinationFile)) {
// Step 3: Read data from the source file and write it to the
destination file
int data;
while ((data = inputStream.read()) != -1) {
outputStream.write(data); }
// Step 4: Display a message indicating successful copy
System.out.println("File copied successfully!");
} catch (IOException e) {
// Step 5: Handle any exceptions that may occur during file
operations
e.printStackTrace();
}
}
}
20. Observe the IP address192.168.2.143/22 and respond to the questions
below: (15 marks)
a. What class does it belong
b. Write down the network id and host id of the above IP address
c. Which subnet mask does the network above have?
d. How many bits reserved to network?
e. How many hosts does the network above host?
Answer
a. IT BELONG TO CLASS C
b. NETWOR ID: 192.168.2 HOST ID 143
c. SUBNET MASK 255.255.252.0
d. 22 bits
e. HOSTS: 210-2=1022 HOSTS
17