Probability Engine · CSC161

Object-Oriented Programming (BSc CSIT, CSC161): the questions likely to come

80 analyzed questions from 7 past papers (2074-2081), grouped by syllabus unit — each with its probability, how often it's been asked, and where to study the answer.

7
Papers analyzed
2074-2081
80
Analyzed questions
across 8 syllabus units
3
Very likely units
high-probability topics
6
Units = 80% of marks
study these first
Model answers for this subject are being written. Every question links to its original paper so you can study from the source meanwhile.
Pick a unit
U8 · Q1/18 · 208110 marks
Working with Files and Templates

What are class templates? Write a C++ program to implement a generic 'Stack' class using templates with push and pop operations.

20%
Occasional to appearAppeared in 1 of the last 1 board papers
Seen in
How well do you know this?rating moves you on
MODEL ANSWERU8 · 10 marks

Class Templates

A class template is a blueprint that lets a single class definition work with any data type. The actual type is supplied as a parameter when an object is created, so the compiler generates a type-specific class on demand. This achieves generic programming and avoids code duplication.

General syntax:

template <class T>
class ClassName { /* T used as a type */ };

Generic Stack Using Templates

#include <iostream>
using namespace std;

template <class T>
class Stack {
    static const int MAX = 100;
    T arr[MAX];
    int top;
public:
    Stack() { top = -1; }

    bool isEmpty() { return top == -1; }
    bool isFull()  { return top == MAX - 1; }

    void push(T value) {
        if (isFull()) { cout << "Stack Overflow\n"; return; }
        arr[++top] = value;
    }

    T pop() {
        if (isEmpty()) { cout << "Stack Underflow\n"; return T(); }
        return arr[top--];
    }
};

int main() {
    Stack<int> s;          // stack of int
    s.push(10);
    s.push(20);
    cout << s.pop() << endl;   // 20
    cout << s.pop() << endl;   // 10

    Stack<char> cs;        // same class, different type
    cs.push('A');
    cout << cs.pop() << endl;  // A
    return 0;
}

Output:

20
10
A

The same Stack template is instantiated as Stack<int> and Stack<char> without rewriting the class, demonstrating the reusability of class templates.

AI-generated answer · unverifiedView in 2081 paper →
U8 · Question 1 of 18
Question Priority · U8ranked by appearance likelihood — study top-down

Working with Files and Templates

Analyzed next20%
1
★ TOP PICK

What are class templates? Write a C++ program to implement a generic 'Stack' class using templates with push and pop operations.

10 marksSEEN IN
20%
2

Explain stream classes in C++. Write a program to demonstrate formatted I/O using manipulators (setw, setprecision, setfill).

10 marksSEEN IN
18%
3

What are templates in C++? Explain function templates and class templates with a program for each.

10 marksSEEN IN
14%
4

Explain file handling in C++. Write a program to write records to a file and read them back using ifstream and ofstream.

10 marksSEEN IN
14%
5

Explain exception handling in C++. Write a program using try, catch and throw to handle division by zero.

10 marksSEEN IN
13%
6

Explain the syntax of a class template.

5 marksSEEN IN
20%
7

What is the difference between throw and rethrow?

5 marksSEEN IN
20%
8

What is the catch(...) handler used for?

5 marksSEEN IN
18%
9

Explain the difference between ifstream and ofstream.

5 marksSEEN IN
18%
10

Explain the throw keyword in C++.

5 marksSEEN IN
16%
11

Differentiate between text files and binary files.

5 marksSEEN IN
16%
12

What is a generic class?

5 marksSEEN IN
16%
13

Explain the seekg() and seekp() functions.

5 marksSEEN IN
16%
14

What is the role of the catch block in exception handling?

5 marksSEEN IN
14%
15

Explain the get() and put() functions in file handling.

5 marksSEEN IN
14%
16

Explain the cin and cout objects.

5 marksSEEN IN
14%
17

What is a template function?

5 marksSEEN IN
13%
18

What is a manipulator? Name any two.

5 marksSEEN IN
11%
03The mock

Sit a probable paper

A full mock exam built from the most likely questions, mirroring the real paper's structure. Every slot is a real past question.

Most Probable Paper

Mirrors the real structure · 60 marks · based on 7 past papers

Section A: Long Answer QuestionsAttempt any TWO questions.
  1. 1.

    What are class templates? Write a C++ program to implement a generic 'Stack' class using templates with push and pop operations.

    [10 marks]
    Working with Files and TemplatesVery likelyfrom 2081 paper →

    Asked once (2081); so far only in internal assessments, not the board; and its topic (Working with Files and Templates) appears in 86% of years.

  2. 2.

    Explain stream classes in C++. Write a program to demonstrate formatted I/O using manipulators (setw, setprecision, setfill).

    [10 marks]
    Working with Files and TemplatesVery likelyfrom 2080 paper →

    Asked once (2080); so far only in internal assessments, not the board; and its topic (Working with Files and Templates) appears in 86% of years.

  3. 3.

    What are templates in C++? Explain function templates and class templates with a program for each.

    [10 marks]
    Working with Files and TemplatesVery likelyfrom 2078 paper →

    Asked once (2078); so far only in internal assessments, not the board; and its topic (Working with Files and Templates) appears in 86% of years.

Section B: Short Answer QuestionsAttempt any EIGHT questions.
  1. 1.

    Explain the role of the access specifier in inheritance.

    [5 marks]
    Inheritance: Extending ClassesVery likelyfrom 2081 paper →

    This question has recurred in 3 of 7 years; so far only in internal assessments, not the board; and its topic (Inheritance: Extending Classes) appears in 86% of years.

  2. 2.

    What are the benefits of object-oriented programming over procedural programming?

    [5 marks]
    IntroductionLikelyfrom 2081 paper →

    This question has recurred in 2 of 7 years; so far only in internal assessments, not the board; and its topic recurs in 5 of 7 years.

  3. 3.

    Explain the syntax of a class template.

    [5 marks]
    Working with Files and TemplatesVery likelyfrom 2081 paper →

    Asked once (2081); so far only in internal assessments, not the board; and its topic (Working with Files and Templates) appears in 86% of years.

  4. 4.

    What is the difference between throw and rethrow?

    [5 marks]
    Working with Files and TemplatesVery likelyfrom 2081 paper →

    Asked once (2081); so far only in internal assessments, not the board; and its topic (Working with Files and Templates) appears in 86% of years.

  5. 5.

    What is the catch(...) handler used for?

    [5 marks]
    Working with Files and TemplatesVery likelyfrom 2080 paper →

    Asked once (2080); so far only in internal assessments, not the board; and its topic (Working with Files and Templates) appears in 86% of years.

  6. 6.

    Explain the difference between ifstream and ofstream.

    [5 marks]
    Working with Files and TemplatesVery likelyfrom 2080 paper →

    Asked once (2080); so far only in internal assessments, not the board; and its topic (Working with Files and Templates) appears in 86% of years.

  7. 7.

    Explain the throw keyword in C++.

    [5 marks]
    Working with Files and TemplatesVery likelyfrom 2079 paper →

    Asked once (2079); so far only in internal assessments, not the board; and its topic (Working with Files and Templates) appears in 86% of years.

  8. 8.

    Differentiate between text files and binary files.

    [5 marks]
    Working with Files and TemplatesVery likelyfrom 2079 paper →

    Asked once (2079); so far only in internal assessments, not the board; and its topic (Working with Files and Templates) appears in 86% of years.

  9. 9.

    What is a generic class?

    [5 marks]
    Working with Files and TemplatesVery likelyfrom 2079 paper →

    Asked once (2079); so far only in internal assessments, not the board; and its topic (Working with Files and Templates) appears in 86% of years.

04The receipts

Behind the numbers

The raw evidence the predictions are computed from: marks per unit per year, syllabus weights, trends, and coverage.

Show the heatmap, topic table and coverage analysis

The receipt: marks per unit, per year

Each row is a syllabus unit, each column an exam year, each cell the marks that unit earned that year. Click any cell to see the actual questions behind it.

Marks:nonefew → many
2074
2075
2077
2078
2079
2080
2081
Total
U8Working with Files and Templates
115
U6Inheritance: Extending Classes
75
U3Classes and Objects
85
U4Constructors and Destructors
60
U2Programming Basics and Functions
65
U1Introduction
40
U7Pointers, Virtual Functions and Polymorphism
50
U5Operator Overloading and Type Conversions
35
#Syllabus unitProbabilityAppearedAvg marksSyllabus weightExam vs syllabusTrendQuestions
1U8Working with Files and TemplatesVery likely86%19.211%5 lecture hrsOver-examinedexam 22% · syllabus 11%Risingnone repeat18 total
2U6Inheritance: Extending ClassesVery likely86%12.513%6 lecture hrsBalancedexam 14% · syllabus 13%Rising1 recurring9 total
3U3Classes and ObjectsLikely71%1718%8 lecture hrsBalancedexam 16% · syllabus 18%Risingnone repeat13 total
4U4Constructors and DestructorsVery likely86%1011%5 lecture hrsBalancedexam 11% · syllabus 11%Steadynone repeat10 total
5U2Programming Basics and FunctionsLikely57%16.213%6 lecture hrsBalancedexam 12% · syllabus 13%Fadingnone repeat12 total
6U1IntroductionLikely71%89%4 lecture hrsBalancedexam 8% · syllabus 9%Fading1 recurring6 total
7U7Pointers, Virtual Functions and PolymorphismLikely57%12.511%5 lecture hrsBalancedexam 10% · syllabus 11%Steady1 recurring7 total
8U5Operator Overloading and Type ConversionsLikely57%8.813%6 lecture hrsUnder-examinedexam 7% · syllabus 13%Steadynone repeat5 total

Study smart, not hard

Drag the slider: studying the top 6 units in priority order covers ~84% of all observed marks.

  1. ~80% line

Lecture time vs exam marks

Where the exam pays more than the curriculum spends: ● lectures vs ● exam marks, as a share of the whole course. A long teal-leading bar = high-yield unit.

U8Working with Files and Templates
11% of lectures → 22% of markshigh yield
U6Inheritance: Extending Classes
13% of lectures → 14% of marks
U3Classes and Objects
18% of lectures → 16% of marks
U4Constructors and Destructors
11% of lectures → 11% of marks
U2Programming Basics and Functions
13% of lectures → 12% of marks
U1Introduction
9% of lectures → 8% of marks
U7Pointers, Virtual Functions and Polymorphism
11% of lectures → 10% of marks
U5Operator Overloading and Type Conversions
13% of lectures → 7% of markslow yield

Topics are the official CSC161 syllabus units. Predictions are data-driven probabilities computed from 7 past papers (2074-2081) by mapping each real question to its syllabus unit. They indicate what has historically been likely, not guaranteed questions. Always study the full syllabus.