Loading...
Ministry of Food

Post: Network/Website Manager (CSE)
Exam Date:21-05-2025; Exam Taker: BPSC
1. Explain the concept of polymorphism in Object-oriented Programming with example. ৫

Polymorphism is a core concept of Object-Oriented Programming (OOP). The word “polymorphism” means “many forms”. It allows the same method or function name to perform different tasks depending on the object.

Types of Polymorphism:
1. Compile-time Polymorphism – Achieved by Method Overloading.
• Same method name but different parameters.
• Example: add(int a, int b) and add(int a, int b, int c).

2. Runtime Polymorphism – Achieved by Method Overriding.
• Subclass provides its own implementation of a method defined in superclass.
• Example:
Class Shape → method draw()
Class Circle → overrides draw()
Class Rectangle → overrides draw()
When draw() is called using Shape reference, the method of the actual object is executed.

Polymorphism allows one interface, multiple implementations. It increases code flexibility and reusability.

Polymorphism হলো Object-Oriented Programming (OOP)–এর একটি গুরুত্বপূর্ণ ধারণা। “Polymorphism” অর্থ “many forms”। এটি একই method বা function নামকে ভিন্ন object অনুযায়ী ভিন্ন কাজ করতে দেয়।

Polymorphism–এর প্রকারভেদ:
1. Compile-time Polymorphism – Method Overloading দ্বারা অর্জিত হয়।
• একই method নাম , কিন্তু ভিন্ন parameter।
• উদাহরণ: add(int a, int b) এবং add(int a, int b, int c)।

2. Runtime Polymorphism – Method Overriding দ্বারা অর্জিত হয়।
• Subclass, superclass–এর method–এর নিজস্ব implementation দেয়।
• উদাহরণ:
Class Shape → method draw()
Class Circle → draw() override করে
Class Rectangle → draw() override করে
Shape reference দিয়ে draw() কল করলে actual object–এর method execute হয়।

Polymorphism মানে এক interface, একাধিক implementation। এটি code–এর flexibility এবং reusability বৃদ্ধি করে।

2. Write an Algorithm to detect a cycle in a directed graph.

Cycle Detection in Directed Graph (Using DFS)

Idea:
Use DFS (Depth First Search) and keep track of nodes in the current recursion stack. If we visit a node already in the recursion stack → cycle exists.

Algorithm:

Algorithm DetectCycle(Graph G)

1. For each vertex v in G:
       visited[v] = false
       recStack[v] = false

2. For each vertex v in G:
       if visited[v] == false:
            if DFS(v) == true:
                 return "Cycle Found"

3. Return "No Cycle"


Function DFS(v):

1. visited[v] = true
2. recStack[v] = true

3. For each neighbor u of v:
       if visited[u] == false:
            if DFS(u) == true:
                 return true
       else if recStack[u] == true:
            return true

4. recStack[v] = false
5. return false
3. Design a full adder using two half adders and an OR gate.
Full Adder By using Two Half adder
4. Compare "Paging" and "Segmentation" memory management technique.

Comparison between Paging and Segmentation

  • Basic Concept: Paging divides memory into fixed-size blocks (pages), while Segmentation divides memory into variable-size segments.
  • Size: Pages are of equal size; segments are of different sizes.
  • Addressing: Paging uses page number + offset; Segmentation uses segment number + offset.
  • Fragmentation: Paging causes internal fragmentation; Segmentation causes external fragmentation.
  • User View: Paging is invisible to the user; Segmentation is visible and logical (like code, data, stack).
  • Complexity: Paging is simpler to implement; Segmentation is more complex.

Paging এবং Segmentation-এর তুলনা

  • Basic Concept: Paging-এ memory fixed size page-এ ভাগ করা হয়; Segmentation-এ memory variable size segment-এ ভাগ করা হয়।
  • Size: Page সমান আকারের; Segment ভিন্ন ভিন্ন আকারের হয়।
  • Addressing: Paging-এ page number + offset; Segmentation-এ segment number + offset ব্যবহৃত হয়।
  • Fragmentation: Paging-এ internal fragmentation হয়; Segmentation-এ external fragmentation হয়।
  • User View: Paging user-এর কাছে দেখা যায় না; Segmentation logical structure হিসেবে দেখা যায় (code, data, stack)।
  • Complexity: Paging সহজ; Segmentation তুলনামূলক জটিল।
5. What is a Man-in-The-Middle (MitM) attack? How can it be prevented?

A Man-in-the-Middle (MitM) attack is a type of cyber attack where an attacker secretly intercepts and possibly alters communication between two parties without their knowledge.

  • Working: The attacker positions themselves between sender and receiver to eavesdrop or modify data.
  • Example: Intercepting login credentials over unsecured public Wi-Fi.
  • Risk: Theft of sensitive data like passwords, banking information, etc

Prevention Methods

  • Use HTTPS: Encrypts communication between client and server.
  • Secure Wi-Fi: Avoid using public or unsecured networks.
  • VPN: Encrypts internet traffic for safe communication.
  • Authentication: Use strong passwords and multi-factor authentication (MFA).
  • Certificate Validation: Ensure websites have valid SSL certificates.

Man-in-the-Middle (MitM) Attack

Man-in-the-Middle (MitM) attack হলো একটি cyber attack যেখানে attacker গোপনে দুইটি পক্ষের মধ্যে যোগাযোগে ঢুকে data intercept বা পরিবর্তন করে।

  • Working: Attacker sender এবং receiver-এর মাঝখানে অবস্থান নিয়ে data শুনতে বা পরিবর্তন করতে পারে।
  • Example: Public Wi-Fi ব্যবহার করার সময় login তথ্য চুরি করা।
  • Risk: Password, banking তথ্যসহ sensitive data চুরি হতে পারে।

Prevention (প্রতিরোধের উপায়)

  • HTTPS ব্যবহার: Data encryption নিশ্চিত করে।
  • Secure Wi-Fi: Unsecured public network এড়িয়ে চলা।
  • VPN ব্যবহার: Internet traffic secure করে।
  • Authentication: Strong password এবং MFA ব্যবহার করা।
  • Certificate Check: Website-এর SSL certificate সঠিক কিনা যাচাই করা।
6. Write a C program to find the sum of digits of an integer number using "recursion"
#include <stdio.h>

// Recursive function to find sum of digits
int sumDigits(int n) {
    if (n == 0)
        return 0;
    return (n % 10) + sumDigits(n / 10);
}

int main() {
    int num;

    printf("Enter a number: ");
    scanf("%d", &num);

    printf("Sum of digits = %d\n", sumDigits(num));

    return 0;
}
7. Write down the Pseudo Code for recursive binary search algorithm. Use the following function definition: binarySearch (array, target, low, high)
binarySearch(array, target, low, high):

1. if low > high:
       return -1   // not found

2. mid = (low + high) / 2

3. if array[mid] == target:
       return mid

4. else if target < array[mid]:
       return binarySearch(array, target, low, mid - 1)

5. else:
       return binarySearch(array, target, mid + 1, high)
8. Write down the names of different stages of instruction pipelining in a multi-cycle datapath architecture. What is a data-hazard in a pipelined datapath?

Stages of Instruction Pipelining

In a multi-cycle datapath architecture, instruction execution is divided into several stages:

  • IF (Instruction Fetch): Fetch the instruction from memory.
  • ID (Instruction Decode): Decode the instruction and read registers.
  • EX (Execute): Perform arithmetic or logical operations.
  • MEM (Memory Access): Access memory for load/store instructions.
  • WB (Write Back): Write the result back to the register.

A data hazard occurs when an instruction depends on the result of a previous instruction that has not yet completed.

  • Cause: Overlapping execution of instructions in pipeline.
  • Example: If Instruction 2 needs data from Instruction 1, but Instruction 1 has not finished execution.
  • Effect: Incorrect results or need to stall the pipeline.
  • Solution: Pipeline stalling, data forwarding (bypassing).

Instruction Pipelining-এর Stage

Multi-cycle datapath architecture-এ instruction execution কয়েকটি stage-এ ভাগ করা হয়:

  • IF (Instruction Fetch): Memory থেকে instruction আনা।
  • ID (Instruction Decode): Instruction decode করা এবং register পড়া।
  • EX (Execute): Arithmetic বা logical operation করা।
  • MEM (Memory Access): Load/store-এর জন্য memory access করা।
  • WB (Write Back): Result register-এ লিখে রাখা।

Data hazard তখন ঘটে যখন একটি instruction পূর্ববর্তী instruction-এর result-এর উপর নির্ভর করে কিন্তু সেই result এখনো প্রস্তুত হয়নি।

  • Cause: Pipeline-এ একাধিক instruction একসাথে চলার কারণে।
  • Example: Instruction 2, Instruction 1-এর data ব্যবহার করতে চায় কিন্তু Instruction 1 এখনো শেষ হয়নি।
  • Effect: ভুল ফলাফল বা pipeline stall হতে পারে।
  • Solution: Pipeline stall বা data forwarding ব্যবহার করা হয়।
9. There are 3 tasks P1. P2, and P3. The arrival time and duration of each task is given below. Apply the round-robin scheduling algorithm with quantum size=20 to schedule the tasks in a single core machine. Calculate the turnaround time for each task. (All tasks have the same priority)
TaskArrival time (ms)Duration (ms)
P1040
P2540
P31020

You must subscribe & Login to view more.

Don’t have an account? Register

Or your subscription is under review by admin. Please message on WhatsApp / Telegram.

Leave a Comment

Latest Post
Field Based Job Question & Solution
Bank IT Job Solution

MCQ + Written from Bangladesh Bank, Sonali, Combined Bank IT recruitment.

BPSC IT Job Solution

BPSC Computer/IT cadre & non-cadre post Question papers with full solutions.

Gas Field IT Job Solution

Gas field like TGTDCL, BGDCL, JGTDSL, KGDCL, SGCL, RPGCL, GTCL etc. question solution

Power Sector IT Job Solution

Power sector such as NESCO, DESCO, DPDC, WZPDCL, BPDB, PGCB, BREB etc

Other IT Job Solution

Other Govt. Semi govt. organization like BCC, BTCL, CAAB, NSI etc.

NTRCA IT Job Solution (upcoming)

NTRCA ICT-related posts such as Assistant Teacher, Demonstrator, Lecturer.

IT MCQ Job Solution

Collected MCQ Job solution of BANK, BPSC, POWER SECTOR, GAS Field and Others.

Topic Based Q&S
WhatsApp Telegram Messenger