Pre-Board Examination 2023 (Computer Science Question Paper)

Pre-Board Examination 2023


Gird your keyboards, coders! The Pre-Board Examination 2023 for Computer Science is upon us. It’s time to sharpen your logic, conquer those algorithms, and prove your programming prowess. Dive into this practice test and emerge victorious, ready to ace the real exam! Good luck!

HSLC Computer Science Question Paper 2024 PDF

1. Answer the following questions:

(a) This Clause is used to search the data within the range (specified lower and upper limit). What is the name of the clause?

Ans: The clause used to search data within a specified range (with lower and upper limits) is called the “BETWEEN” clause.

(b) This operator displays only those records that do not satisfy the specified condition. What is the name of the operator? 

Ans: The operator that displays only those records that do not satisfy the specified condition is called the “NOT” operator.

2. Fill in the Blanks:

(a) The ping command is used to _____.

Ans: Check the connectivity between two networked devices.

(b) The ___ element includes both on and off tags. 

Ans:  <body> 

(c) A list inside another list is called ____.

Ans: A nested list.

d) The number of column _____ denotes the degree of the table. 

Ans: Attributes

(e) A MySQL statement is terminated by a _____.

Ans:  Semicolon (;).

3. Choose the correct option:

(a) IP address can be automatically assigned if the network is connected with

i. Access Point ii. Mail server

iii. Web Server iv. DHCP Server

Ans: iv) DHCP Server.

() Which of the following is used to define the style for a single HTML page?

i. Inline CSS ü. Internal CSS

iii. External CSS iv. None of these

Ans: i) Inline CSS.

(c) What is the output of the C Program?

int main()

{

int a-25;

while(a<=27)

{

printf(“%d “, a);

a++;

}

return 0;

}

i. 25 25 25 ii. 25 26 27

iii. 27 27 27 iv. Compiler error

Ans: ii. 25 26 27

(d) Which loop is faster in C Language, for, while, or Do While?

i) for ii) while iii) do while iv) All work at the same speed

Ans: iv) All work at the same speed

4. Answer the following questions:

(a) What is the basic difference between POP and SMTP?

Ans: The basic difference between POP and SMTP is that POP (Post Office Protocol) is used for receiving emails from a mail server to a client’s computer or device, while SMTP (Simple Mail Transfer Protocol) is used for sending emails from a client’s computer or device to a mail server.

(b) What is the use of TCP?

Ans: The use of TCP (Transmission Control Protocol) is to provide reliable, ordered, and error-checked delivery of a stream of bytes between applications running on hosts communicating via an IP network.

(c) What is Cascading Style Sheet?

Ans: Cascading Style Sheet (CSS) is a style sheet language used for describing the presentation of a document written in HTML or XML. CSS defines how elements are to be displayed on screen, paper, or in other media.

(d) Define Padding property.

Ans: Padding property in CSS generates space around an element’s content, inside any defined borders. It can be set using values such as pixels, ems, percentages, etc.

(e) Write the syntax for using the list-style-type property.

Ans: selector {

  list-style-type: value;

}

(f) Flow are images added in an HTML document.

Ans: Images are added in an HTML document using the <img> element. The <img> element has an attribute called src which specifies the path to the image file.

(g) What is the need for a global variable?

Ans: The need for a global variable arises when a variable needs to be accessible from anywhere within the program, including inside functions and across different files.

(h) What is data abstraction?

Ans: Data abstraction is the process of hiding the implementation details of a data type and only showing the essential features or interface to the outside world.

(i) What will be the output of the following code segment:

#include <stdio.h>

int main() {

int weeks = 1, days_in_week = 7;

for (int i = 1; i <= weeks; i++) {

printf(“Week: %d\n”, i);

for (int j = 1; j <= days_in_week; j++) {

printf(“Day: %d\n”, j);

}

}

return 0;

}

Ans: Week: 1

Day: 1

Day: 2

Day: 3

Day: 4

Day: 5

Day: 6

Day: 7 

5. Answer the following questions:

(a) What is the use of ARP protocol and ping command?

Ans: The ARP (Address Resolution Protocol) protocol is used to map IP addresses to MAC addresses on a local network, while the ping command is used to test the reachability of a host on an IP network.

(b) What is the working principle of TCP and IP?

Ans: The working principle of TCP (Transmission Control Protocol) involves establishing a connection between two hosts, ensuring reliable and ordered delivery of data packets, and handling error checking and correction. IP (Internet Protocol) is responsible for routing packets of data across networks based on IP addresses.

(c) Write any two features of HTML.

Ans: Two features of HTML are:

  • HTML allows the creation of hyperlinks, enabling navigation between different web pages.
  • HTML supports the embedding of multimedia elements such as images, audio, and video.

(d) Write the uses of unordered and description lists in HTML.

Ans: Uses of unordered lists and description lists in HTML:

  • Unordered lists <ul> are used to create lists of items that are not ordered in a particular sequence.
  • Description lists <dl> are used to create lists of terms and their corresponding descriptions.

(e) What is a constraint? Name any two constraints.

Ans: In DBMS, constraints are rules that limit the type or value of data stored. They ensure data accuracy and consistency. Two constraints are

  • Primary Key constraint: Ensures each row in a table is uniquely identified.
  • Foreign Key constraint: Establishes a relationship between two tables based on a column in one table referencing the primary key of another table.

(f) What are the rules for naming a table in MySQL?

Ans: Rules for naming a table in MySQL include:

  • Table names can contain letters, numbers, and underscores.
  • Table names must start with a letter or an underscore.
  • Table names cannot exceed 64 characters in length.

(g) List the Relational Operators used in MySQL.

Ans: Relational operators used in MySQL include:

  1. Equal to (=)
  2. Not equal to (!= or <>)
  3. Greater than (>)
  4. Less than (<)
  5. Greater than or equal to (>=)
  6. Less than or equal to (<=)

(h) What is the meaning of COUNT () and COUNT(*)?

Ans: COUNT() in SQL is a function used to count the number of rows returned by a query. COUNT(*) counts all rows, including those with NULL values, while COUNT(column_name) counts the number of rows where the specified column is not NULL.

(i) Write a C program to display the elements of the odd positions.

Ans: 

#include <stdio.h>

    int main() {

        int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

        int n = sizeof(arr) / sizeof(arr[0]);

        for (int i = 0; i < n; i++) {

            if (i % 2 != 0) {

                printf(“%d “, arr[i]);

            }

        }

        return 0;

    }  

(j) Define data hiding and data binding.

Ans: Data hiding is the process of encapsulating the implementation details of a class and exposing only the necessary features to the outside world. Data binding refers to the process of connecting the application’s UI (User Interface) with the application’s business logic or data model.

(k) Define object and class.

Ans: In object-oriented programming, an object is an instance of a class. A class is a blueprint or template that defines the properties and behaviors common to all objects of that type.

(l) What is the output of the following code segment:

int *ptr, x=9;

ptr=&x;

int y= ++(*ptr);

printf(“\n%d”, y);

Ans: 10

6. Answer the following questions:

(a) Write a C program to find the summation of the digits of an integer.

Ans:

#include <stdio.h>

int main() {

    int num, remainder, sum = 0;

    printf(“Enter an integer: “);

    scanf(“%d”, &num);

    while (num != 0) {

        remainder = num % 10; // Extract the last digit

        sum += remainder;

        num /= 10; // Remove the last digit

    }

    printf(“Sum of digits: %d\n”, sum);

    return 0;

}

(b) Write a C program and declare an integer-type array with 7 elements in it. Display the address of the individual elements in the array.

Ans: 

#include <stdio.h>

int main() {

    int arr[7]; // Declare an integer array with 7 elements

    int i;

    printf(“Array elements and their addresses:\n”);

    for (i = 0; i < 7; i++) {

        printf(“arr[%d] (address): %p\n”, i, &arr[i]);

    }

    return 0;

}

(c) Write a C program to display the string characters.

Ans: 

#include <stdio.h>

int main() {

    char str[] = “Hello, World!”; // Declare a string

    printf(“String characters:\n”);

    for (int i = 0; str[i] != ‘\0’; i++) {

        printf(“%c “, str[i]);

    }

    printf(“\n”);

    return 0;

}

(d) Write a C program and define a recursive function to find the summation of first N natural numbers.

Ans: 

#include <stdio.h>

int sumOfN(int n) {

    if (n == 0)

        return 0;

    else

        return n + sumOfN(n – 1);

}

int main() {

    int n, sum; 

    printf(“Enter a positive integer: “);

    scanf(“%d”, &n);   

    sum = sumOfN(n);

    printf(“Sum of first %d natural numbers: %d\n”, n, sum);   

    return 0;

}

(f) Explain the five categories of SQL Commands.

Ans: The five categories of SQL Commands are:

Data Definition Language (DDL): Used to define, alter, or drop database objects like tables, views, indexes, etc.

Data Manipulation Language (DML): Used to manipulate data stored in the database, including querying, inserting, updating, and deleting data.

Data Control Language (DCL): Used to control access to data within the database, including granting and revoking privileges.

Transaction Control Language (TCL): Used to manage transactions within the database, including committing or rolling back transactions.Data Query Language (DQL): Used to retrieve data from the database using SELECT statements.

Leave a Comment