BITAC Assistant Programmer Exam: 27.10.2023 (BUTEX)প্রশ্ন ও সমাধান
- Set by
- BITAC
- Post
- Assistant Programmer
- Exam date
- 27 Oct 2023
- Questions
- 5 (0 MCQ, 5 written)
- Exam guide
- Government IT officer posts · সরকারি প্রতিষ্ঠানের আইটি পদ
- Computer Architecture · কম্পিউটার আর্কিটেকচার 2
- Programming · প্রোগ্রামিং 2
- Algorithms · অ্যালগরিদম 1
Write Concept of cache memory in computer. How its change performance of computer?
Sign up free to see the model answer · উত্তর দেখতে বিনামূল্যে সাইন আপ করুন
What is dual channel RAM? Difference between single In-Line and Dual In-Line Memory Module.
Sign up free to see the model answer · উত্তর দেখতে বিনামূল্যে সাইন আপ করুন
What is virtual function with example?
Model answer
A virtual function is a member function declared in a base class with the virtual keyword that a derived class can override; when called through a base-class pointer or reference, C++ resolves which version to execute at runtime, based on the actual object type — this is runtime (dynamic) polymorphism.
#include <iostream>
using namespace std;
class Animal {
public:
virtual void sound() { // virtual function
cout << "Animal makes a sound" << endl;
}
};
class Dog : public Animal {
public:
void sound() override { // overriding
cout << "Dog barks" << endl;
}
};
int main() {
Animal *a;
Dog d;
a = &d;
a->sound(); // calls Dog::sound() at runtime, not Animal::sound()
return 0;
}
Output:
Dog barks
Without virtual, a->sound() would call Animal::sound() based purely on the pointer's declared type (static binding) — virtual defers that decision to runtime using a vtable (virtual function table) that stores the correct overridden function's address for each class.
classDiagram
class Animal { +sound() virtual }
class Dog { +sound() override }
Animal <|-- Dog
Exam takeaway: virtual + a base-class pointer/reference + an override in the derived class = runtime polymorphism, implemented internally via a vtable/vpointer mechanism.
Write a C code that show factorial of a number.
Sign up free to see the model answer · উত্তর দেখতে বিনামূল্যে সাইন আপ করুন
Which one of the following regular expressions represents the language: The set of all binary strings having two consecutive 0's and two consecutive 1's? Explain why?
Sign up free to see the model answer · উত্তর দেখতে বিনামূল্যে সাইন আপ করুন
Question text is from the public recruitment exam; answers and explanations are written by ARBS Academy. All past papers · Government IT officer posts guide