dkescape commited on
Commit
9160cd4
·
verified ·
1 Parent(s): 09c5912

Create index2.html

Browse files
Files changed (1) hide show
  1. index2.html +947 -365
index2.html CHANGED
@@ -3,7 +3,7 @@
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>OOP Exam Revision Guide</title>
7
  <script src="https://cdn.tailwindcss.com"></script>
8
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
9
  <script>
@@ -23,55 +23,61 @@
23
  </script>
24
  <style>
25
  @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');
26
-
27
  body {
28
  font-family: 'Poppins', sans-serif;
29
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
30
  background-attachment: fixed;
31
  }
32
-
33
  .unit-card {
34
  transition: transform 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
35
  }
36
-
37
  .unit-card:hover {
38
  transform: translateY(-5px);
39
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
40
  }
41
-
42
  .choice-chip {
43
  cursor: pointer;
44
  transition: all 0.2s ease;
45
  }
46
-
47
  .choice-chip:hover {
48
  transform: scale(1.05);
49
  }
50
-
51
  .question-card {
52
  overflow: hidden;
53
  transition: all 0.3s ease;
54
  }
55
-
56
  .highlighted {
57
  background: linear-gradient(90deg, #dbeafe 0%, transparent 100%);
58
  border-left: 4px solid #3b82f6;
59
  }
60
-
61
  .exam-tip {
62
  animation: pulse 2s infinite;
63
  }
64
-
65
  @keyframes pulse {
66
  0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4); }
67
  70% { box-shadow: 0 0 0 10px rgba(59, 130, 246, 0); }
68
  100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
69
  }
70
-
71
  mark {
72
  background-color: #fef3c7;
73
  padding: 0 2px;
74
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  </style>
76
  </head>
77
  <body>
@@ -82,24 +88,24 @@
82
  <div>
83
  <h1 class="text-3xl md:text-4xl font-bold flex items-center gap-3">
84
  <i class="fas fa-laptop-code"></i>
85
- OOP with C++ Exam Revision Guide
86
  </h1>
87
  <p class="mt-2 text-blue-200">
88
- Comprehensive preparation material for Object Oriented Programming exam
89
  </p>
90
  </div>
91
  <div class="inline-flex gap-2">
92
  <button class="bg-accent hover:bg-blue-500 text-white px-4 py-2 rounded-full flex items-center">
93
- <i class="fas fa-book mr-2"></i> Study Notes
94
  </button>
95
- <button class="bg-primary hover:bg-blue-600 text-white px-4 py-2 rounded-full flex items-center">
96
- <i class="fas fa-download mr-2"></i> PDF Version
97
  </button>
98
  </div>
99
  </div>
100
  </div>
101
  </header>
102
-
103
  <!-- Exam Tips -->
104
  <section class="py-6 bg-gradient-to-r from-blue-50 to-indigo-50 border-b border-blue-100">
105
  <div class="container mx-auto px-4">
@@ -110,7 +116,7 @@
110
  <div>
111
  <h3 class="font-bold text-lg text-secondary mb-1">Quick Tips for Your Exam</h3>
112
  <ul class="list-disc pl-5 space-y-1 text-gray-700">
113
- <li>Write neatly, underline keywords: <mark>private</mark>, <mark>friend</mark>, <mark>inline</mark>, <mark>::</mark></li>
114
  <li><strong>Draw tables</strong> for comparisons (OOP vs POP, access specifiers)</li>
115
  <li>Write small code snippets — even 4 lines with comments can get full marks</li>
116
  <li>Spend ~1 minute per 2 marks — don't over-write answers</li>
@@ -120,13 +126,13 @@
120
  </div>
121
  </div>
122
  </section>
123
-
124
  <main class="container mx-auto px-4 py-8">
125
  <!-- Unit Navigation -->
126
  <section class="mb-12">
127
  <h2 class="text-2xl font-bold text-center text-secondary mb-8">Exam Units</h2>
128
  <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
129
- <button data-unit="1" class="unit-card bg-gradient-to-br from-blue-100 to-blue-200 border border-blue-300 rounded-2xl p-6 text-center hover:border-blue-500 shadow-md">
130
  <h3 class="text-xl font-bold text-secondary flex justify-center items-center">
131
  <i class="fas fa-cube mr-2 text-accent"></i>
132
  UNIT-1
@@ -135,9 +141,8 @@
135
  <div class="bg-primary/10 text-xs inline-block px-3 py-1 rounded-full mt-3 text-primary font-medium">
136
  12 Questions
137
  </div>
138
- </button>
139
-
140
- <button data-unit="2" class="unit-card bg-gradient-to-br from-indigo-100 to-indigo-200 border border-indigo-300 rounded-2xl p-6 text-center hover:border-indigo-500 shadow-md">
141
  <h3 class="text-xl font-bold text-secondary flex justify-center items-center">
142
  <i class="fas fa-cogs mr-2 text-indigo-500"></i>
143
  UNIT-2
@@ -146,9 +151,8 @@
146
  <div class="bg-indigo-500/10 text-xs inline-block px-3 py-1 rounded-full mt-3 text-indigo-700 font-medium">
147
  9 Questions
148
  </div>
149
- </button>
150
-
151
- <button data-unit="3" class="unit-card bg-gradient-to-br from-cyan-100 to-cyan-200 border border-cyan-300 rounded-2xl p-6 text-center hover:border-cyan-500 shadow-md">
152
  <h3 class="text-xl font-bold text-secondary flex justify-center items-center">
153
  <i class="fas fa-hat-wizard mr-2 text-cyan-500"></i>
154
  UNIT-3
@@ -157,10 +161,10 @@
157
  <div class="bg-cyan-500/10 text-xs inline-block px-3 py-1 rounded-full mt-3 text-cyan-700 font-medium">
158
  6 Questions
159
  </div>
160
- </button>
161
  </div>
162
  </section>
163
-
164
  <!-- Comparison Tables -->
165
  <section class="mb-12">
166
  <h2 class="text-2xl font-bold text-secondary mb-6 flex items-center gap-2">
@@ -186,34 +190,43 @@
186
  <tbody>
187
  <tr class="border-b">
188
  <td class="py-3 px-4 font-medium">Approach</td>
189
- <td class="py-3 px-4"><mark>Object-based</mark></td>
190
- <td class="py-3 px-4">Procedure-based</td>
191
  </tr>
192
  <tr class="border-b bg-blue-50">
193
- <td class="py-3 px-4 font-medium">Focus</td>
194
- <td class="py-3 px-4"><mark>Data & methods</mark></td>
195
- <td class="py-3 px-4">Algorithms</td>
196
  </tr>
197
  <tr class="border-b">
198
- <td class="py-3 px-4 font-medium">Data Security</td>
199
- <td class="py-3 px-4"><mark>Encapsulation</mark></td>
200
- <td class="py-3 px-4">Limited/no security</td>
201
  </tr>
202
  <tr class="border-b bg-blue-50">
203
- <td class="py-3 px-4 font-medium">Reusability</td>
204
- <td class="py-3 px-4"><mark>High</mark> (inheritance)</td>
205
- <td class="py-3 px-4"><mark>Low</mark></td>
 
 
 
 
 
 
 
 
 
 
206
  </tr>
207
  <tr class="border-b">
208
  <td class="py-3 px-4 font-medium">Examples</td>
209
  <td class="py-3 px-4">C++, Java, Python</td>
210
- <td class="py-3 px-4">C, Pascal, FORTRAN</td>
211
  </tr>
212
  </tbody>
213
  </table>
214
  </div>
215
  </div>
216
-
217
  <!-- Access Specifiers Table -->
218
  <div class="bg-white rounded-xl shadow-lg overflow-hidden">
219
  <div class="bg-indigo-500 text-white py-3 px-4">
@@ -262,363 +275,958 @@
262
  </div>
263
  </div>
264
  </section>
265
-
266
- <!-- Unit Content -->
267
- <div>
268
- <!-- Unit 1 -->
269
- <section id="unit-1" class="mb-12">
270
- <div class="flex items-center gap-3 mb-6">
271
- <div class="w-2 h-10 bg-primary rounded-lg"></div>
272
- <h2 class="text-2xl font-bold text-secondary flex items-center gap-2">
273
- <i class="fas fa-cube text-accent"></i> UNIT-1: Principles Of OOP
274
- </h2>
275
- </div>
276
-
277
- <div class="grid grid-cols-1 gap-4">
278
- <!-- Question 1 -->
279
- <div class="question-card bg-white rounded-lg shadow-md p-5">
280
- <div class="flex flex-wrap gap-3 items-start justify-between">
281
- <div>
282
- <span class="font-bold text-secondary text-lg">Q1.</span>
283
- <span class="text-gray-800 font-medium">Define OOP.</span>
284
- <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">2 MARKS</span>
285
- </div>
286
- <div class="flex gap-2">
287
- <button class="choice-chip bg-red-100 text-red-700 px-3 py-1 rounded-full text-sm font-medium">
288
- Easy
289
- </button>
290
- <button class="choice-chip bg-green-100 text-green-700 px-3 py-1 rounded-full text-sm font-medium highlighted">
291
- <i class="fas fa-check-circle mr-1"></i>Important
292
- </button>
293
- </div>
294
- </div>
295
- </div>
296
-
297
- <!-- Question 2 with Top Tip -->
298
- <div class="relative">
299
- <div class="question-card bg-white rounded-lg shadow-md p-5">
300
- <div class="flex flex-wrap gap-3 items-start justify-between">
301
- <div>
302
- <span class="font-bold text-secondary text-lg">Q2.</span>
303
- <span class="text-gray-800 font-medium">List applications of OOP.</span>
304
- <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">2 MARKS</span>
305
- </div>
306
- </div>
307
- </div>
308
- <div class="absolute -top-2 -right-2 bg-amber-500 text-white text-xs font-bold px-2 py-1 rounded-lg shadow-lg">
309
- <i class="fas fa-star mr-1"></i> Top Application Areas
310
- </div>
311
- </div>
312
-
313
- <!-- Question 3 -->
314
- <div class="question-card bg-white rounded-lg shadow-md p-5">
315
- <div class="flex flex-wrap gap-3 items-start justify-between">
316
- <div>
317
- <span class="font-bold text-secondary text-lg">Q3.</span>
318
- <span class="text-gray-800 font-medium">List advantages & disadvantages of OOP.</span>
319
- <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">3 MARKS</span>
320
- </div>
321
- <div class="flex gap-2">
322
- <button class="choice-chip bg-blue-100 text-blue-700 px-3 py-1 rounded-full text-sm font-medium">
323
- Theory
324
- </button>
325
- </div>
326
- </div>
327
- </div>
328
-
329
- <!-- Question 4 -->
330
- <div class="question-card bg-white rounded-lg shadow-md p-5 highlighted">
331
- <div class="flex flex-wrap gap-3 items-start justify-between">
332
- <div>
333
- <span class="font-bold text-secondary text-lg">Q4.</span>
334
- <span class="text-gray-800 font-medium">Differentiate OOP & POP.</span>
335
- <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">3 MARKS</span>
336
- </div>
337
- <div class="flex gap-2">
338
- <button class="choice-chip bg-indigo-100 text-indigo-700 px-3 py-1 rounded-full text-sm font-medium">
339
- <i class="fas fa-table mr-1"></i> Tabular Form
340
- </button>
341
- </div>
342
- </div>
343
- <div class="mt-4 bg-blue-50 border border-blue-200 rounded-lg p-4">
344
- <p class="text-sm text-gray-700 font-medium">
345
- <i class="fas fa-lightbulb text-blue-500 mr-2"></i>
346
- Refer to OOP vs POP table for structured comparisons
347
- </p>
348
- </div>
349
- </div>
350
-
351
- <!-- Question 5 -->
352
- <div class="question-card bg-white rounded-lg shadow-md p-5">
353
- <div class="flex flex-wrap gap-3 items-start justify-between">
354
- <div>
355
- <span class="font-bold text-secondary text-lg">Q5.</span>
356
- <span class="text-gray-800 font-medium">Explain the basic concepts of C++.</span>
357
- <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">4 MARKS</span>
358
- </div>
359
- <div class="flex gap-2">
360
- <button class="choice-chip bg-purple-100 text-purple-700 px-3 py-1 rounded-full text-sm font-medium">
361
- Core Concepts
362
- </button>
363
- </div>
364
- </div>
365
- </div>
366
-
367
- <!-- Question 6 with Code Example -->
368
- <div class="question-card bg-white rounded-lg shadow-md p-5">
369
- <div class="flex flex-wrap gap-3 items-start justify-between">
370
- <div>
371
- <span class="font-bold text-secondary text-lg">Q6.</span>
372
- <span class="text-gray-800 font-medium">Explain the structure of C++ with example.</span>
373
- <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">4 MARKS</span>
374
- </div>
375
- <div class="flex gap-2">
376
- <button class="choice-chip bg-red-100 text-red-700 px-3 py-1 rounded-full text-sm font-medium" data-toggle="code">
377
- <i class="fas fa-code mr-1"></i> Show Example Code
378
- </button>
379
- </div>
380
- </div>
381
- <div class="hidden mt-4" id="code-example">
382
- <pre class="bg-gray-800 text-green-300 p-4 rounded-lg text-sm overflow-x-auto">
383
- #include &lt;iostream&gt;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
384
  using namespace std;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
385
 
386
  int main() {
387
- cout << "Hello, OOP in C++!" << endl;
 
 
388
  return 0;
389
  }</pre>
390
- <div class="mt-2 text-sm text-gray-600">
391
- Basic structure of a C++ program with necessary components
392
- </div>
393
- </div>
394
- </div>
395
-
396
- <!-- Additional Questions (Collapsed for brevity) -->
397
- <div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
398
- <!-- Question 7 -->
399
- <div class="question-card bg-white rounded-lg shadow-md p-5">
400
- <div>
401
- <span class="font-bold text-secondary text-lg">Q7.</span>
402
- <span class="text-gray-800 font-medium">List & explain user-defined data types & derived data types with example.</span>
403
- <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">3 MARKS</span>
404
- </div>
405
- </div>
406
-
407
- <!-- Question 8 -->
408
- <div class="question-card bg-white rounded-lg shadow-md p-5">
409
- <div>
410
- <span class="font-bold text-secondary text-lg">Q8.</span>
411
- <span class="text-gray-800 font-medium">Define variable.</span>
412
- <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">2 MARKS</span>
413
- </div>
414
- </div>
415
-
416
- <!-- Question 9 -->
417
- <div class="question-card bg-white rounded-lg shadow-md p-5">
418
- <div>
419
- <span class="font-bold text-secondary text-lg">Q9.</span>
420
- <span class="text-gray-800 font-medium">What is a reference variable in C++?</span>
421
- <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">3 MARKS</span>
422
- </div>
423
- </div>
424
-
425
- <!-- Question 10 -->
426
- <div class="question-card bg-white rounded-lg shadow-md p-5">
427
- <div>
428
- <span class="font-bold text-secondary text-lg">Q10.</span>
429
- <span class="text-gray-800 font-medium">Describe variable declaration & dynamic initialization in C++.</span>
430
- <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">3 MARKS</span>
431
- </div>
432
- </div>
433
-
434
- <!-- Question 11 -->
435
- <div class="question-card bg-white rounded-lg shadow-md p-5">
436
- <div>
437
- <span class="font-bold text-secondary text-lg">Q11.</span>
438
- <span class="text-gray-800 font-medium">Explain Scope Resolution.</span>
439
- <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">3 MARKS</span>
440
- </div>
441
- </div>
442
-
443
- <!-- Question 12 with Access Specifier Tip -->
444
- <div class="question-card bg-white rounded-lg shadow-md p-5 highlighted">
445
- <div class="flex flex-wrap gap-3 items-start justify-between">
446
- <div>
447
- <span class="font-bold text-secondary text-lg">Q12.</span>
448
- <span class="text-gray-800 font-medium">Explain access specifiers (public, private, protected).</span>
449
- <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">4 MARKS</span>
450
- </div>
451
- <div class="flex gap-2">
452
- <button class="choice-chip bg-indigo-100 text-indigo-700 px-3 py-1 rounded-full text-sm font-medium">
453
- <i class="fas fa-table mr-1"></i> Use Table Above
454
- </button>
455
- </div>
456
- </div>
457
- </div>
458
- </div>
459
- </div>
460
- </section>
461
-
462
- <!-- Unit 2 -->
463
- <section id="unit-2" class="mb-12">
464
- <div class="flex items-center gap-3 mb-6">
465
- <div class="w-2 h-10 bg-indigo-500 rounded-lg"></div>
466
- <h2 class="text-2xl font-bold text-secondary flex items-center gap-2">
467
- <i class="fas fa-cogs text-indigo-500"></i> UNIT-2: Function, Class & Objects
468
- </h2>
469
- </div>
470
-
471
- <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
472
- <!-- Unit 2 questions (collapsed for brevity) -->
473
- <div class="question-card bg-white rounded-lg shadow-md p-5">
474
  <span class="font-bold text-secondary text-lg">Q13.</span>
475
  <span class="text-gray-800 font-medium">Define function with function prototype, function declaration & function calling.</span>
476
  <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">3 MARKS</span>
477
  </div>
478
-
479
- <div class="question-card bg-white rounded-lg shadow-md p-5">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
480
  <span class="font-bold text-secondary text-lg">Q14.</span>
481
  <span class="text-gray-800 font-medium">Define an inline function & explain how to implement with example.</span>
482
  <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">4 MARKS</span>
483
- <div class="mt-3">
484
- <mark class="font-medium text-gray-700">Tip: Underline the keyword 'inline' in answer</mark>
485
- </div>
486
  </div>
487
-
488
- <div class="question-card bg-white rounded-lg shadow-md p-5 highlighted">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
489
  <span class="font-bold text-secondary text-lg">Q15.</span>
490
  <span class="text-gray-800 font-medium">Explain default and constant arguments with example.</span>
491
  <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">4 MARKS</span>
492
  </div>
493
-
494
- <div class="question-card bg-white rounded-lg shadow-md p-5">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
495
  <span class="font-bold text-secondary text-lg">Q16.</span>
496
  <span class="text-gray-800 font-medium">Explain Function Overloading with example.</span>
497
  <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">4 MARKS</span>
498
  </div>
499
-
500
- <div class="question-card bg-white rounded-lg shadow-md p-5">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
501
  <span class="font-bold text-secondary text-lg">Q17.</span>
502
  <span class="text-gray-800 font-medium">Define class & object.</span>
503
  <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">2 MARKS</span>
504
  </div>
505
-
506
- <div class="question-card bg-white rounded-lg shadow-md p-5">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
507
  <span class="font-bold text-secondary text-lg">Q18.</span>
508
  <span class="text-gray-800 font-medium">What is an instance of a class?</span>
509
  <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">2 MARKS</span>
510
  </div>
511
-
512
- <div class="question-card bg-white rounded-lg shadow-md p-5">
 
 
 
 
 
 
 
 
 
 
 
513
  <span class="font-bold text-secondary text-lg">Q19.</span>
514
  <span class="text-gray-800 font-medium">Define Member Function & Nesting of Member Function.</span>
515
  <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">3 MARKS</span>
516
  </div>
517
-
518
- <div class="question-card bg-white rounded-lg shadow-md p-5">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
519
  <span class="font-bold text-secondary text-lg">Q20.</span>
520
  <span class="text-gray-800 font-medium">Define Private Member Function.</span>
521
  <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">3 MARKS</span>
522
  </div>
523
-
524
- <div class="question-card bg-white rounded-lg shadow-md p-5">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
525
  <span class="font-bold text-secondary text-lg">Q21.</span>
526
  <span class="text-gray-800 font-medium">What is a Friend Function? Explain with example.</span>
527
  <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">3 MARKS</span>
528
- <div class="mt-3">
529
- <mark class="font-medium text-gray-700">Underline 'friend' in answer</mark>
530
- </div>
531
- </div>
532
- </div>
533
- </section>
534
-
535
- <!-- Unit 3 -->
536
- <section id="unit-3" class="mb-12">
537
- <div class="flex items-center gap-3 mb-6">
538
- <div class="w-2 h-10 bg-cyan-500 rounded-lg"></div>
539
- <h2 class="text-2xl font-bold text-secondary flex items-center gap-2">
540
- <i class="fas fa-hat-wizard text-cyan-500"></i> UNIT-3: Constructor & Destructor
541
- </h2>
542
- </div>
543
-
544
- <div class="grid grid-cols-1 gap-4">
545
- <div class="question-card bg-white rounded-lg shadow-md p-5">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
546
  <span class="font-bold text-secondary text-lg">Q22.</span>
547
  <span class="text-gray-800 font-medium">What is a constructor? Explain in brief with example.</span>
548
  <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">3 MARKS</span>
549
  </div>
550
-
551
- <div class="question-card bg-white rounded-lg shadow-md p-5">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
552
  <span class="font-bold text-secondary text-lg">Q23.</span>
553
  <span class="text-gray-800 font-medium">Explain default constructor with program.</span>
554
  <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">3 MARKS</span>
555
- <div class="mt-3 text-sm text-gray-600">
556
- <i class="fas fa-code text-blue-500 mr-2"></i> Write a simple program showing a default constructor
557
- </div>
558
  </div>
559
-
560
- <div class="question-card bg-white rounded-lg shadow-md p-5">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
561
  <span class="font-bold text-secondary text-lg">Q24.</span>
562
  <span class="text-gray-800 font-medium">How to test a copy constructor? Justify with program.</span>
563
  <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">3 MARKS</span>
564
  </div>
565
-
566
- <div class="question-card bg-white rounded-lg shadow-md p-5">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
567
  <span class="font-bold text-secondary text-lg">Q25.</span>
568
  <span class="text-gray-800 font-medium">Explain parameterized constructor with example.</span>
569
  <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">4 MARKS</span>
570
  </div>
571
-
572
- <div class="question-card bg-white rounded-lg shadow-md p-5">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
573
  <span class="font-bold text-secondary text-lg">Q26.</span>
574
  <span class="text-gray-800 font-medium">Explain Characteristics of Constructor.</span>
575
  <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">3 MARKS</span>
576
  </div>
577
-
578
- <div class="question-card bg-white rounded-lg shadow-md p-5 highlighted">
579
- <div class="flex flex-wrap gap-3 items-start justify-between">
580
- <div>
581
- <span class="font-bold text-secondary text-lg">Q27.</span>
582
- <span class="text-gray-800 font-medium">Write a C++ program to enter student details by passing parameters to constructors.</span>
583
- <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">3 MARKS</span>
584
- </div>
585
- <div class="flex gap-2">
586
- <button class="choice-chip bg-red-100 text-red-700 px-3 py-1 rounded-full text-sm font-medium" data-toggle="code2">
587
- <i class="fas fa-code mr-1"></i> Example Program
588
- </button>
589
- </div>
590
- </div>
591
- <div class="hidden mt-4" id="code-example2">
592
- <pre class="bg-gray-800 text-green-300 p-4 rounded-lg text-sm overflow-x-auto">
593
- #include &lt;iostream&gt;
594
- #include &lt;string&gt;
 
 
 
 
 
 
 
 
 
 
 
 
 
595
  using namespace std;
596
 
597
  class Student {
598
- string name;
599
- int roll;
600
  public:
601
- Student(string n, int r) { // Constructor with parameters
 
 
 
 
 
 
602
  name = n;
603
- roll = r;
604
  }
 
605
  void display() {
606
- cout << "Name: " << name << "\nRoll: " << roll;
607
  }
608
  };
609
 
610
  int main() {
611
- Student s1("John", 101);
612
- s1.display();
 
 
 
 
 
613
  return 0;
614
- }</pre>
615
- </div>
616
- </div>
 
617
  </div>
618
- </section>
619
- </div>
620
-
621
- <!-- Key Concepts Review-->
622
  <section class="mb-12 bg-gradient-to-br from-blue-50 to-white p-6 rounded-xl shadow-lg border border-blue-100">
623
  <h2 class="text-2xl font-bold text-secondary mb-6">Key Concepts Cheatsheet</h2>
624
  <div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-4 gap-4">
@@ -629,7 +1237,6 @@ int main() {
629
  <h3 class="font-bold text-secondary">Encapsulation</h3>
630
  <p class="text-sm text-gray-600 mt-1">Bundling data with methods operating on that data</p>
631
  </div>
632
-
633
  <div class="bg-white rounded-lg p-4 border border-indigo-200 shadow-sm flex flex-col items-center text-center">
634
  <div class="bg-indigo-100 p-3 rounded-full mb-3">
635
  <i class="fas fa-sitemap text-indigo-600 text-xl"></i>
@@ -637,7 +1244,6 @@ int main() {
637
  <h3 class="font-bold text-secondary">Inheritance</h3>
638
  <p class="text-sm text-gray-600 mt-1">Creating hierarchical relationships between classes</p>
639
  </div>
640
-
641
  <div class="bg-white rounded-lg p-4 border border-purple-200 shadow-sm flex flex-col items-center text-center">
642
  <div class="bg-purple-100 p-3 rounded-full mb-3">
643
  <i class="fas fa-bolt text-purple-600 text-xl"></i>
@@ -645,7 +1251,6 @@ int main() {
645
  <h3 class="font-bold text-secondary">Polymorphism</h3>
646
  <p class="text-sm text-gray-600 mt-1">Same methods performing different actions</p>
647
  </div>
648
-
649
  <div class="bg-white rounded-lg p-4 border border-cyan-200 shadow-sm flex flex-col items-center text-center">
650
  <div class="bg-cyan-100 p-3 rounded-full mb-3">
651
  <i class="fas fa-puzzle-piece text-cyan-600 text-xl"></i>
@@ -656,17 +1261,17 @@ int main() {
656
  </div>
657
  </section>
658
  </main>
659
-
660
  <!-- Footer -->
661
  <footer class="bg-secondary text-blue-100 py-8">
662
  <div class="container mx-auto px-4">
663
  <div class="flex flex-col md:flex-row justify-between items-center">
664
  <div class="mb-4 md:mb-0">
665
- <h3 class="text-xl font-bold text-white">OOP Exam Revision Guide</h3>
666
- <p class="mt-1">Comprehensive preparation material for your Object Oriented Programming exam</p>
667
  </div>
668
  <div class="flex space-x-4">
669
- <button class="bg-blue-600 hover:bg-blue-700 text-white py-2 px-4 rounded-lg flex items-center">
670
  <i class="fas fa-print mr-2"></i> Print Summary
671
  </button>
672
  <button class="bg-cyan-500 hover:bg-cyan-600 text-white py-2 px-4 rounded-lg flex items-center">
@@ -675,46 +1280,23 @@ int main() {
675
  </div>
676
  </div>
677
  <div class="mt-8 pt-8 border-t border-blue-800 text-center text-sm text-blue-200">
678
- <p>This study guide covers essential OOP concepts as presented in standard curriculum and exam patterns.</p>
679
- <p class="mt-2">Important keywords: <mark>private</mark>, <mark>friend</mark>, <mark>inline</mark>, <mark>::</mark>, <mark>using</mark>, <mark>namespace</mark>, <mark>class</mark>, <mark>object</mark>, <mark>constructor</mark>, <mark>destructor</mark></p>
680
  </div>
681
  </div>
682
  </footer>
683
-
684
  <script>
685
  document.addEventListener('DOMContentLoaded', function() {
686
- // Code toggle functionality
687
- const codeButtons = document.querySelectorAll('[data-toggle="code"]');
688
- codeButtons.forEach(button => {
689
- button.addEventListener('click', () => {
690
- const codeExample = button.closest('.question-card').querySelector('#code-example');
691
- codeExample.classList.toggle('hidden');
 
692
  });
693
  });
694
-
695
- // Unit navigation hover effect
696
- const unitCards = document.querySelectorAll('.unit-card');
697
- unitCards.forEach(card => {
698
- card.addEventListener('click', () => {
699
- const unitId = card.dataset.unit;
700
- location.hash = `#unit-${unitId}`;
701
- // Highlight the unit section
702
- const unitSection = document.getElementById(`unit-${unitId}`);
703
- unitSection.classList.add('animate-pulse');
704
- setTimeout(() => {
705
- unitSection.classList.remove('animate-pulse');
706
- }, 1500);
707
- });
708
- });
709
-
710
- // Example shown in Unit 3
711
- const codeButton2 = document.querySelector('[data-toggle="code2"]');
712
- if(codeButton2) {
713
- codeButton2.addEventListener('click', () => {
714
- const codeExample = document.getElementById('code-example2');
715
- codeExample.classList.toggle('hidden');
716
- });
717
- }
718
  });
719
  </script>
720
  </body>
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>OOP with C++ Exam Guide - Complete Answers</title>
7
  <script src="https://cdn.tailwindcss.com"></script>
8
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
9
  <script>
 
23
  </script>
24
  <style>
25
  @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');
 
26
  body {
27
  font-family: 'Poppins', sans-serif;
28
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
29
  background-attachment: fixed;
30
  }
 
31
  .unit-card {
32
  transition: transform 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
33
  }
 
34
  .unit-card:hover {
35
  transform: translateY(-5px);
36
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
37
  }
 
38
  .choice-chip {
39
  cursor: pointer;
40
  transition: all 0.2s ease;
41
  }
 
42
  .choice-chip:hover {
43
  transform: scale(1.05);
44
  }
 
45
  .question-card {
46
  overflow: hidden;
47
  transition: all 0.3s ease;
48
  }
 
49
  .highlighted {
50
  background: linear-gradient(90deg, #dbeafe 0%, transparent 100%);
51
  border-left: 4px solid #3b82f6;
52
  }
 
53
  .exam-tip {
54
  animation: pulse 2s infinite;
55
  }
 
56
  @keyframes pulse {
57
  0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4); }
58
  70% { box-shadow: 0 0 0 10px rgba(59, 130, 246, 0); }
59
  100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
60
  }
 
61
  mark {
62
  background-color: #fef3c7;
63
  padding: 0 2px;
64
  }
65
+ pre {
66
+ font-size: 0.9rem !important;
67
+ line-height: 1.5;
68
+ }
69
+ .answer {
70
+ border-left: 4px solid #3b82f6;
71
+ background-color: #f8fafc;
72
+ padding: 1rem;
73
+ margin-top: 1rem;
74
+ border-radius: 0 0.5rem 0.5rem 0;
75
+ }
76
+ .answer-title {
77
+ font-weight: 600;
78
+ color: #1e40af;
79
+ margin-bottom: 0.5rem;
80
+ }
81
  </style>
82
  </head>
83
  <body>
 
88
  <div>
89
  <h1 class="text-3xl md:text-4xl font-bold flex items-center gap-3">
90
  <i class="fas fa-laptop-code"></i>
91
+ OOP with C++ Exam Guide
92
  </h1>
93
  <p class="mt-2 text-blue-200">
94
+ Complete answers to all questions from the official question bank
95
  </p>
96
  </div>
97
  <div class="inline-flex gap-2">
98
  <button class="bg-accent hover:bg-blue-500 text-white px-4 py-2 rounded-full flex items-center">
99
+ <i class="fas fa-book mr-2"></i> Study Guide
100
  </button>
101
+ <button onclick="window.print()" class="bg-primary hover:bg-blue-600 text-white px-4 py-2 rounded-full flex items-center">
102
+ <i class="fas fa-print mr-2"></i> Print
103
  </button>
104
  </div>
105
  </div>
106
  </div>
107
  </header>
108
+
109
  <!-- Exam Tips -->
110
  <section class="py-6 bg-gradient-to-r from-blue-50 to-indigo-50 border-b border-blue-100">
111
  <div class="container mx-auto px-4">
 
116
  <div>
117
  <h3 class="font-bold text-lg text-secondary mb-1">Quick Tips for Your Exam</h3>
118
  <ul class="list-disc pl-5 space-y-1 text-gray-700">
119
+ <li>Write neatly, <strong>underline keywords</strong>: <mark>private</mark>, <mark>friend</mark>, <mark>inline</mark>, <mark>::</mark></li>
120
  <li><strong>Draw tables</strong> for comparisons (OOP vs POP, access specifiers)</li>
121
  <li>Write small code snippets — even 4 lines with comments can get full marks</li>
122
  <li>Spend ~1 minute per 2 marks — don't over-write answers</li>
 
126
  </div>
127
  </div>
128
  </section>
129
+
130
  <main class="container mx-auto px-4 py-8">
131
  <!-- Unit Navigation -->
132
  <section class="mb-12">
133
  <h2 class="text-2xl font-bold text-center text-secondary mb-8">Exam Units</h2>
134
  <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
135
+ <div class="unit-card bg-gradient-to-br from-blue-100 to-blue-200 border border-blue-300 rounded-2xl p-6 text-center shadow-md">
136
  <h3 class="text-xl font-bold text-secondary flex justify-center items-center">
137
  <i class="fas fa-cube mr-2 text-accent"></i>
138
  UNIT-1
 
141
  <div class="bg-primary/10 text-xs inline-block px-3 py-1 rounded-full mt-3 text-primary font-medium">
142
  12 Questions
143
  </div>
144
+ </div>
145
+ <div class="unit-card bg-gradient-to-br from-indigo-100 to-indigo-200 border border-indigo-300 rounded-2xl p-6 text-center shadow-md">
 
146
  <h3 class="text-xl font-bold text-secondary flex justify-center items-center">
147
  <i class="fas fa-cogs mr-2 text-indigo-500"></i>
148
  UNIT-2
 
151
  <div class="bg-indigo-500/10 text-xs inline-block px-3 py-1 rounded-full mt-3 text-indigo-700 font-medium">
152
  9 Questions
153
  </div>
154
+ </div>
155
+ <div class="unit-card bg-gradient-to-br from-cyan-100 to-cyan-200 border border-cyan-300 rounded-2xl p-6 text-center shadow-md">
 
156
  <h3 class="text-xl font-bold text-secondary flex justify-center items-center">
157
  <i class="fas fa-hat-wizard mr-2 text-cyan-500"></i>
158
  UNIT-3
 
161
  <div class="bg-cyan-500/10 text-xs inline-block px-3 py-1 rounded-full mt-3 text-cyan-700 font-medium">
162
  6 Questions
163
  </div>
164
+ </div>
165
  </div>
166
  </section>
167
+
168
  <!-- Comparison Tables -->
169
  <section class="mb-12">
170
  <h2 class="text-2xl font-bold text-secondary mb-6 flex items-center gap-2">
 
190
  <tbody>
191
  <tr class="border-b">
192
  <td class="py-3 px-4 font-medium">Approach</td>
193
+ <td class="py-3 px-4"><mark>Bottom-up approach</mark></td>
194
+ <td class="py-3 px-4">Top-down approach</td>
195
  </tr>
196
  <tr class="border-b bg-blue-50">
197
+ <td class="py-3 px-4 font-medium">Program Structure</td>
198
+ <td class="py-3 px-4"><mark>Objects and interactions</mark></td>
199
+ <td class="py-3 px-4">Functions that interact</td>
200
  </tr>
201
  <tr class="border-b">
202
+ <td class="py-3 px-4 font-medium">Inheritance</td>
203
+ <td class="py-3 px-4"><mark>Supported</mark></td>
204
+ <td class="py-3 px-4">Not supported</td>
205
  </tr>
206
  <tr class="border-b bg-blue-50">
207
+ <td class="py-3 px-4 font-medium">Access Control</td>
208
+ <td class="py-3 px-4"><mark>Supported via access modifiers</mark></td>
209
+ <td class="py-3 px-4">Not supported</td>
210
+ </tr>
211
+ <tr class="border-b">
212
+ <td class="py-3 px-4 font-medium">Encapsulation</td>
213
+ <td class="py-3 px-4"><mark>Used to hide data</mark></td>
214
+ <td class="py-3 px-4">No data hiding; data is globally accessible</td>
215
+ </tr>
216
+ <tr class="border-b bg-blue-50">
217
+ <td class="py-3 px-4 font-medium">Security</td>
218
+ <td class="py-3 px-4"><mark>Secure</mark></td>
219
+ <td class="py-3 px-4">Not secure</td>
220
  </tr>
221
  <tr class="border-b">
222
  <td class="py-3 px-4 font-medium">Examples</td>
223
  <td class="py-3 px-4">C++, Java, Python</td>
224
+ <td class="py-3 px-4">C, BASIC, FORTRAN</td>
225
  </tr>
226
  </tbody>
227
  </table>
228
  </div>
229
  </div>
 
230
  <!-- Access Specifiers Table -->
231
  <div class="bg-white rounded-xl shadow-lg overflow-hidden">
232
  <div class="bg-indigo-500 text-white py-3 px-4">
 
275
  </div>
276
  </div>
277
  </section>
278
+
279
+ <!-- Unit 1 Content -->
280
+ <section id="unit-1" class="mb-12">
281
+ <div class="flex items-center gap-3 mb-6">
282
+ <div class="w-2 h-10 bg-primary rounded-lg"></div>
283
+ <h2 class="text-2xl font-bold text-secondary flex items-center gap-2">
284
+ <i class="fas fa-cube text-accent"></i> UNIT-1: Principles Of OOP
285
+ </h2>
286
+ </div>
287
+
288
+ <!-- Question 1 -->
289
+ <div class="question-card bg-white rounded-lg shadow-md p-5 mb-4">
290
+ <div class="flex flex-wrap gap-3 items-start justify-between">
291
+ <div>
292
+ <span class="font-bold text-secondary text-lg">Q1.</span>
293
+ <span class="text-gray-800 font-medium">Define OOP.</span>
294
+ <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">2 MARKS</span>
295
+ </div>
296
+ </div>
297
+ <div class="answer">
298
+ <div class="answer-title">Answer:</div>
299
+ <p>OOP stands for Object-Oriented Programming. It is a programming paradigm based on the concept of "objects", which are instances of classes. OOP emphasizes on objects rather than functions and makes the code flexible and modular. C++ is an object-oriented programming language that allows programmers to define their own data types and functions, called classes and objects respectively.</p>
300
+ </div>
301
+ </div>
302
+
303
+ <!-- Question 2 -->
304
+ <div class="question-card bg-white rounded-lg shadow-md p-5 mb-4">
305
+ <div class="flex flex-wrap gap-3 items-start justify-between">
306
+ <div>
307
+ <span class="font-bold text-secondary text-lg">Q2.</span>
308
+ <span class="text-gray-800 font-medium">List applications of OOP.</span>
309
+ <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">2 MARKS</span>
310
+ </div>
311
+ </div>
312
+ <div class="answer">
313
+ <div class="answer-title">Answer:</div>
314
+ <p>Applications of OOP include:</p>
315
+ <ul class="list-disc pl-5 mt-2">
316
+ <li>Real-Time System design</li>
317
+ <li>Hypertext and Hypermedia</li>
318
+ <li>AI Expert System</li>
319
+ <li>Office automation System</li>
320
+ <li>Neural networking and parallel programming</li>
321
+ <li>Stimulation and modeling system</li>
322
+ <li>CIM/CAD/CAM systems</li>
323
+ </ul>
324
+ </div>
325
+ </div>
326
+
327
+ <!-- Question 3 -->
328
+ <div class="question-card bg-white rounded-lg shadow-md p-5 mb-4">
329
+ <div class="flex flex-wrap gap-3 items-start justify-between">
330
+ <div>
331
+ <span class="font-bold text-secondary text-lg">Q3.</span>
332
+ <span class="text-gray-800 font-medium">List advantages & disadvantages of OOP.</span>
333
+ <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">3 MARKS</span>
334
+ </div>
335
+ </div>
336
+ <div class="answer">
337
+ <div class="answer-title">Answer:</div>
338
+ <p><strong>Advantages:</strong></p>
339
+ <ul class="list-disc pl-5 mt-2">
340
+ <li>Code can be reused multiple times using classes</li>
341
+ <li>Inherit classes to subclasses for data redundancy</li>
342
+ <li>Easy to maintain and modify</li>
343
+ <li>Maintains data security</li>
344
+ <li>Low-cost development</li>
345
+ </ul>
346
+ <p class="mt-3"><strong>Disadvantages:</strong></p>
347
+ <ul class="list-disc pl-5 mt-2">
348
+ <li>Size is larger than other programs</li>
349
+ <li>Slower than other programs</li>
350
+ <li>Not suitable for some sorts of problems</li>
351
+ </ul>
352
+ </div>
353
+ </div>
354
+
355
+ <!-- Question 4 -->
356
+ <div class="question-card bg-white rounded-lg shadow-md p-5 mb-4">
357
+ <div class="flex flex-wrap gap-3 items-start justify-between">
358
+ <div>
359
+ <span class="font-bold text-secondary text-lg">Q4.</span>
360
+ <span class="text-gray-800 font-medium">Differentiate OOP & POP.</span>
361
+ <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">3 MARKS</span>
362
+ </div>
363
+ </div>
364
+ <div class="answer">
365
+ <div class="answer-title">Answer:</div>
366
+ <p>The main differences between OOP and POP are:</p>
367
+ <table class="min-w-full mt-3 border border-gray-300">
368
+ <thead class="bg-gray-100">
369
+ <tr>
370
+ <th class="py-2 px-3 border-b">Feature</th>
371
+ <th class="py-2 px-3 border-b">OOP</th>
372
+ <th class="py-2 px-3 border-b">POP</th>
373
+ </tr>
374
+ </thead>
375
+ <tbody>
376
+ <tr>
377
+ <td class="py-2 px-3 border-b">Approach</td>
378
+ <td class="py-2 px-3">Bottom-up approach</td>
379
+ <td class="py-2 px-3">Top-down approach</td>
380
+ </tr>
381
+ <tr>
382
+ <td class="py-2 px-3 border-b">Program Structure</td>
383
+ <td class="py-2 px-3">Program divided into objects and their interactions</td>
384
+ <td class="py-2 px-3">Program divided into functions that interact</td>
385
+ </tr>
386
+ <tr>
387
+ <td class="py-2 px-3 border-b">Inheritance</td>
388
+ <td class="py-2 px-3">Supported</td>
389
+ <td class="py-2 px-3">Not supported</td>
390
+ </tr>
391
+ <tr>
392
+ <td class="py-2 px-3 border-b">Access Control</td>
393
+ <td class="py-2 px-3">Supported via access modifiers</td>
394
+ <td class="py-2 px-3">Not supported</td>
395
+ </tr>
396
+ <tr>
397
+ <td class="py-2 px-3 border-b">Examples</td>
398
+ <td class="py-2 px-3">C++, Java, Python</td>
399
+ <td class="py-2 px-3">C, BASIC, FORTRAN</td>
400
+ </tr>
401
+ </tbody>
402
+ </table>
403
+ </div>
404
+ </div>
405
+
406
+ <!-- Question 5 -->
407
+ <div class="question-card bg-white rounded-lg shadow-md p-5 mb-4">
408
+ <div class="flex flex-wrap gap-3 items-start justify-between">
409
+ <div>
410
+ <span class="font-bold text-secondary text-lg">Q5.</span>
411
+ <span class="text-gray-800 font-medium">Explain the basic concepts of C++.</span>
412
+ <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">4 MARKS</span>
413
+ </div>
414
+ </div>
415
+ <div class="answer">
416
+ <div class="answer-title">Answer:</div>
417
+ <p>The basic concepts of C++ are:</p>
418
+ <ol class="list-decimal pl-5 mt-2">
419
+ <li><strong>Object:</strong> Any entity that has state and behavior. In C++, an object is an instance of a class.</li>
420
+ <li><strong>Class:</strong> A user-defined data type that encapsulates data and functions into a single entity.</li>
421
+ <li><strong>Data Encapsulation:</strong> Binding code and data together into a single unit, providing data security.</li>
422
+ <li><strong>Data Abstraction:</strong> Hiding internal details and showing only functionality.</li>
423
+ <li><strong>Inheritance:</strong> When one object acquires all properties and behaviors of a parent object, providing code reusability.</li>
424
+ <li><strong>Polymorphism:</strong> One task performed in different ways (function overloading or operator overloading).</li>
425
+ <li><strong>Dynamic binding:</strong> Decision made at runtime regarding which code to run (late binding).</li>
426
+ <li><strong>Message passing:</strong> Objects communicate with each other by sending and receiving information through member functions.</li>
427
+ </ol>
428
+ </div>
429
+ </div>
430
+
431
+ <!-- Question 6 -->
432
+ <div class="question-card bg-white rounded-lg shadow-md p-5 mb-4">
433
+ <div class="flex flex-wrap gap-3 items-start justify-between">
434
+ <div>
435
+ <span class="font-bold text-secondary text-lg">Q6.</span>
436
+ <span class="text-gray-800 font-medium">Explain the structure of C++ with example.</span>
437
+ <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">4 MARKS</span>
438
+ </div>
439
+ </div>
440
+ <div class="answer">
441
+ <div class="answer-title">Answer:</div>
442
+ <p>The structure of a C++ program consists of the following sections:</p>
443
+ <ol class="list-decimal pl-5 mt-2">
444
+ <li><strong>Documentation Section:</strong> Contains comments about the program logic (optional).</li>
445
+ <li><strong>Link Section:</strong> Contains header files (#include) and namespaces (using namespace std;).</li>
446
+ <li><strong>Definition Section:</strong> Used to declare constants and define user-defined data types.</li>
447
+ <li><strong>Global Declaration Section:</strong> Variables and class definitions declared as global.</li>
448
+ <li><strong>Function Definition Section:</strong> Contains user-defined functions.</li>
449
+ <li><strong>Main Function:</strong> Starting point of program execution.</li>
450
+ </ol>
451
+ <p class="mt-3"><strong>Example:</strong></p>
452
+ <pre class="bg-gray-800 text-green-300 p-4 rounded-lg text-sm overflow-x-auto">
453
+ #include<iostream>
454
+ using namespace std;
455
+ int main(){
456
+ cout<<"Hello World!";
457
+ return 0;
458
+ }
459
+ // Output: Hello World!</pre>
460
+ </div>
461
+ </div>
462
+
463
+ <!-- Question 7 -->
464
+ <div class="question-card bg-white rounded-lg shadow-md p-5 mb-4">
465
+ <div class="flex flex-wrap gap-3 items-start justify-between">
466
+ <div>
467
+ <span class="font-bold text-secondary text-lg">Q7.</span>
468
+ <span class="text-gray-800 font-medium">List & explain user-defined data types & derived data types with example.</span>
469
+ <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">3 MARKS</span>
470
+ </div>
471
+ </div>
472
+ <div class="answer">
473
+ <div class="answer-title">Answer:</div>
474
+ <p><strong>User-Defined Data Types:</strong></p>
475
+ <ol class="list-decimal pl-5 mt-2">
476
+ <li><strong>Structure:</strong> Collection of logically related data items of different data types grouped together. Example: <code>struct Student { int id; char name[20]; };</code></li>
477
+ <li><strong>Class:</strong> Template that specifies fields and methods of objects. Example: <code>class Student { int id; string name; };</code></li>
478
+ <li><strong>Union:</strong> Like a structure, but elements share common memory.</li>
479
+ <li><strong>Enumeration:</strong> User-defined type with named constants. Example: <code>enum day {mon, tue, wed};</code></li>
480
+ </ol>
481
+ <p class="mt-3"><strong>Derived Data Types:</strong></p>
482
+ <ol class="list-decimal pl-5 mt-2">
483
+ <li><strong>Arrays:</strong> Fixed-size collection of elements of same type.</li>
484
+ <li><strong>Functions:</strong> Group of statements combined for a specific purpose.</li>
485
+ <li><strong>Pointers:</strong> Special variable containing address of another variable.</li>
486
+ </ol>
487
+ </div>
488
+ </div>
489
+
490
+ <!-- Question 8 -->
491
+ <div class="question-card bg-white rounded-lg shadow-md p-5 mb-4">
492
+ <div class="flex flex-wrap gap-3 items-start justify-between">
493
+ <div>
494
+ <span class="font-bold text-secondary text-lg">Q8.</span>
495
+ <span class="text-gray-800 font-medium">Define variable.</span>
496
+ <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">2 MARKS</span>
497
+ </div>
498
+ </div>
499
+ <div class="answer">
500
+ <div class="answer-title">Answer:</div>
501
+ <p>A variable is a name of a memory location used to store data. Its value can be changed and it can be reused many times. It is a way to represent memory location through a symbol so that it can be easily identified.</p>
502
+ <p class="mt-2"><strong>Syntax:</strong> <code>datatype variable_name;</code></p>
503
+ <p><strong>Example:</strong> <code>int a;</code></p>
504
+ </div>
505
+ </div>
506
+
507
+ <!-- Question 9 -->
508
+ <div class="question-card bg-white rounded-lg shadow-md p-5 mb-4">
509
+ <div class="flex flex-wrap gap-3 items-start justify-between">
510
+ <div>
511
+ <span class="font-bold text-secondary text-lg">Q9.</span>
512
+ <span class="text-gray-800 font-medium">What is a reference variable in C++?</span>
513
+ <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">3 MARKS</span>
514
+ </div>
515
+ </div>
516
+ <div class="answer">
517
+ <div class="answer-title">Answer:</div>
518
+ <p>A reference variable is an alias or second name for an existing variable. It refers to the address of another variable and represents the name of another variable, location, or value. Once initialized, the variable can be referred to using either the original name or the reference name.</p>
519
+ <p class="mt-2"><strong>Syntax:</strong> <code>data_type &amp;reference_name = existing_variable;</code></p>
520
+ <p><strong>Example:</strong></p>
521
+ <pre class="bg-gray-800 text-green-300 p-4 rounded-lg text-sm overflow-x-auto">
522
+ #include<iostream>
523
  using namespace std;
524
+ int main() {
525
+ int a = 10;
526
+ int &amp;value = a;
527
+ cout << value; // Output: 10
528
+ return 0;
529
+ }</pre>
530
+ </div>
531
+ </div>
532
+
533
+ <!-- Question 10 -->
534
+ <div class="question-card bg-white rounded-lg shadow-md p-5 mb-4">
535
+ <div class="flex flex-wrap gap-3 items-start justify-between">
536
+ <div>
537
+ <span class="font-bold text-secondary text-lg">Q10.</span>
538
+ <span class="text-gray-800 font-medium">Describe variable declaration & dynamic initialization in C++.</span>
539
+ <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">3 MARKS</span>
540
+ </div>
541
+ </div>
542
+ <div class="answer">
543
+ <div class="answer-title">Answer:</div>
544
+ <p><strong>Variable Declaration:</strong> Variables must be declared before use. It specifies the data type and name of the variable.</p>
545
+ <p class="mt-2"><strong>Syntax:</strong></p>
546
+ <ul class="list-disc pl-5">
547
+ <li>Single variable: <code>type variable_name;</code></li>
548
+ <li>Multiple variables: <code>type var1, var2, var3;</code></li>
549
+ </ul>
550
+ <p><strong>Examples:</strong></p>
551
+ <ul class="list-disc pl-5 mt-2">
552
+ <li><code>int a = 50, b = 100;</code></li>
553
+ <li><code>float f = 50.8;</code></li>
554
+ <li><code>char c = 'Z';</code></li>
555
+ </ul>
556
+ <p class="mt-3"><strong>Dynamic Initialization:</strong> Initializing a variable at runtime during its declaration.</p>
557
+ <p><strong>Example:</strong></p>
558
+ <pre class="bg-gray-800 text-green-300 p-4 rounded-lg text-sm overflow-x-auto">
559
+ #include<iostream>
560
+ using namespace std;
561
+ int main() {
562
+ int a;
563
+ cout << "Enter Value of a: ";
564
+ cin >> a;
565
+ int cube = a * a * a; // Dynamically initialized
566
+ return 0;
567
+ }</pre>
568
+ </div>
569
+ </div>
570
+
571
+ <!-- Question 11 -->
572
+ <div class="question-card bg-white rounded-lg shadow-md p-5 mb-4">
573
+ <div class="flex flex-wrap gap-3 items-start justify-between">
574
+ <div>
575
+ <span class="font-bold text-secondary text-lg">Q11.</span>
576
+ <span class="text-gray-800 font-medium">Explain Scope Resolution.</span>
577
+ <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">3 MARKS</span>
578
+ </div>
579
+ </div>
580
+ <div class="answer">
581
+ <div class="answer-title">Answer:</div>
582
+ <p>The scope resolution operator (::) is used to reference global variables or member functions that are out of scope. It accesses hidden variables or functions in a program.</p>
583
+ <p class="mt-2"><strong>Uses:</strong></p>
584
+ <ul class="list-disc pl-5">
585
+ <li>Access global variables when a local variable has the same name</li>
586
+ <li>Define member functions outside of a class</li>
587
+ <li>Access static variables and functions of a class</li>
588
+ <li>Override functions in inheritance</li>
589
+ </ul>
590
+ <p class="mt-3"><strong>Example:</strong></p>
591
+ <pre class="bg-gray-800 text-green-300 p-4 rounded-lg text-sm overflow-x-auto">
592
+ #include<iostream>
593
+ using namespace std;
594
+ int num = 50; // Global variable
595
+ int main() {
596
+ int num = 100; // Local variable
597
+ cout << "Local variable: " << num << endl;
598
+ cout << "Global variable: " << ::num; // Using scope resolution
599
+ return 0;
600
+ }
601
+ // Output: Local variable: 100
602
+ // Global variable: 50</pre>
603
+ </div>
604
+ </div>
605
+
606
+ <!-- Question 12 -->
607
+ <div class="question-card bg-white rounded-lg shadow-md p-5 mb-4">
608
+ <div class="flex flex-wrap gap-3 items-start justify-between">
609
+ <div>
610
+ <span class="font-bold text-secondary text-lg">Q12.</span>
611
+ <span class="text-gray-800 font-medium">Explain access specifiers (public, private, protected).</span>
612
+ <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">4 MARKS</span>
613
+ </div>
614
+ </div>
615
+ <div class="answer">
616
+ <div class="answer-title">Answer:</div>
617
+ <p>In C++, access specifiers determine the accessibility of class members:</p>
618
+ <ol class="list-decimal pl-5 mt-2">
619
+ <li><strong>Public:</strong> Members can be accessed from anywhere, both inside and outside the class. Used to represent the interface of the class.</li>
620
+ <li><strong>Private:</strong> Members can only be accessed from within the class. Used to represent the implementation and hide data from the outside world.</li>
621
+ <li><strong>Protected:</strong> Members can be accessed from within the class and its derived classes. Used when implementation should be accessible to derived classes.</li>
622
+ </ol>
623
+ <p class="mt-3"><strong>Example:</strong></p>
624
+ <pre class="bg-gray-800 text-green-300 p-4 rounded-lg text-sm overflow-x-auto">
625
+ class MyClass {
626
+ public:
627
+ int x; // Accessible anywhere
628
+ private:
629
+ int y; // Only accessible within class
630
+ protected:
631
+ int z; // Accessible in class and derived classes
632
+ };
633
 
634
  int main() {
635
+ MyClass myObj;
636
+ myObj.x = 25; // OK
637
+ myObj.y = 50; // Error: y is private
638
  return 0;
639
  }</pre>
640
+ </div>
641
+ </div>
642
+ </section>
643
+
644
+ <!-- Unit 2 Content -->
645
+ <section id="unit-2" class="mb-12">
646
+ <div class="flex items-center gap-3 mb-6">
647
+ <div class="w-2 h-10 bg-indigo-500 rounded-lg"></div>
648
+ <h2 class="text-2xl font-bold text-secondary flex items-center gap-2">
649
+ <i class="fas fa-cogs text-indigo-500"></i> UNIT-2: Function, Class & Objects
650
+ </h2>
651
+ </div>
652
+
653
+ <!-- Question 13 -->
654
+ <div class="question-card bg-white rounded-lg shadow-md p-5 mb-4">
655
+ <div class="flex flex-wrap gap-3 items-start justify-between">
656
+ <div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
657
  <span class="font-bold text-secondary text-lg">Q13.</span>
658
  <span class="text-gray-800 font-medium">Define function with function prototype, function declaration & function calling.</span>
659
  <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">3 MARKS</span>
660
  </div>
661
+ </div>
662
+ <div class="answer">
663
+ <div class="answer-title">Answer:</div>
664
+ <p>A function is a block of code that performs a specific operation. It can take input parameters and optionally return a value.</p>
665
+ <p class="mt-3"><strong>Function Prototype:</strong> Provides the compiler with a description of a function before it's defined. It includes return type, function name, and parameter types.</p>
666
+ <p><strong>Example:</strong> <code>int sum(int, int);</code></p>
667
+ <p class="mt-3"><strong>Function Declaration:</strong> Tells the compiler about a function name and how to call it. The actual body can be defined separately.</p>
668
+ <p><strong>Syntax:</strong> <code>return_type function_name(parameter list);</code></p>
669
+ <p class="mt-3"><strong>Function Calling:</strong> Invoking a function by its name with appropriate arguments. Control is passed to the function, which executes and may return a value.</p>
670
+ <p><strong>Syntax:</strong> <code>variable = function_name(arg1, arg2, ..., argn);</code></p>
671
+ <p><strong>Example:</strong> <code>result = sum(num1, num2);</code></p>
672
+ </div>
673
+ </div>
674
+
675
+ <!-- Question 14 -->
676
+ <div class="question-card bg-white rounded-lg shadow-md p-5 mb-4">
677
+ <div class="flex flex-wrap gap-3 items-start justify-between">
678
+ <div>
679
  <span class="font-bold text-secondary text-lg">Q14.</span>
680
  <span class="text-gray-800 font-medium">Define an inline function & explain how to implement with example.</span>
681
  <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">4 MARKS</span>
 
 
 
682
  </div>
683
+ </div>
684
+ <div class="answer">
685
+ <div class="answer-title">Answer:</div>
686
+ <p>An inline function is a function that is expanded in line when called. The entire code of the inline function is inserted at the point of the function call during compilation, which can increase efficiency for small functions.</p>
687
+ <p class="mt-3"><strong>Syntax:</strong></p>
688
+ <pre class="bg-gray-800 text-green-300 p-4 rounded-lg text-sm overflow-x-auto">
689
+ inline return-type function-name(parameters)
690
+ {
691
+ // function code
692
+ }</pre>
693
+ <p class="mt-3"><strong>Implementation:</strong></p>
694
+ <p>If a function is defined entirely within the class specification (typically in the header file), it is automatically considered inline.</p>
695
+ <p><strong>Example:</strong></p>
696
+ <pre class="bg-gray-800 text-green-300 p-4 rounded-lg text-sm overflow-x-auto">
697
+ #include<iostream>
698
+ using namespace std;
699
+
700
+ inline int cube(int s) {
701
+ return s * s * s;
702
+ }
703
+
704
+ int main() {
705
+ cout << "The cube of 2 is: " << cube(2);
706
+ return 0;
707
+ }
708
+ // Output: The cube of 2 is: 8</pre>
709
+ </div>
710
+ </div>
711
+
712
+ <!-- Question 15 -->
713
+ <div class="question-card bg-white rounded-lg shadow-md p-5 mb-4">
714
+ <div class="flex flex-wrap gap-3 items-start justify-between">
715
+ <div>
716
  <span class="font-bold text-secondary text-lg">Q15.</span>
717
  <span class="text-gray-800 font-medium">Explain default and constant arguments with example.</span>
718
  <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">4 MARKS</span>
719
  </div>
720
+ </div>
721
+ <div class="answer">
722
+ <div class="answer-title">Answer:</div>
723
+ <p><strong>Default Arguments:</strong> Values provided in a function declaration that are automatically assigned by the compiler if the calling function doesn't provide a value for that argument. If a value is passed, the default value is overridden.</p>
724
+ <p><strong>Example:</strong></p>
725
+ <pre class="bg-gray-800 text-green-300 p-4 rounded-lg text-sm overflow-x-auto">
726
+ #include<iostream>
727
+ using namespace std;
728
+
729
+ int sum(int x, int y, int z = 0, int w = 0) {
730
+ return (x + y + z + w);
731
+ }
732
+
733
+ int main() {
734
+ cout << sum(10, 20) << endl; // Output: 30
735
+ cout << sum(10, 20, 30) << endl; // Output: 60
736
+ cout << sum(10, 20, 30, 50) << endl; // Output: 110
737
+ return 0;
738
+ }</pre>
739
+ <p class="mt-3"><strong>Constant Arguments:</strong> Arguments that cannot be modified by the function. Useful when passing by reference to prevent accidental modification.</p>
740
+ <p><strong>Example:</strong></p>
741
+ <pre class="bg-gray-800 text-green-300 p-4 rounded-lg text-sm overflow-x-auto">
742
+ #include<iostream>
743
+ using namespace std;
744
+
745
+ class Test {
746
+ int value;
747
+ public:
748
+ Test(int v = 0) {
749
+ value = v;
750
+ }
751
+ int get() const { // const member function
752
+ return value;
753
+ }
754
+ };
755
+
756
+ int main() {
757
+ Test t(20);
758
+ cout << t.get();
759
+ return 0;
760
+ }
761
+ // Output: 20</pre>
762
+ </div>
763
+ </div>
764
+
765
+ <!-- Question 16 -->
766
+ <div class="question-card bg-white rounded-lg shadow-md p-5 mb-4">
767
+ <div class="flex flex-wrap gap-3 items-start justify-between">
768
+ <div>
769
  <span class="font-bold text-secondary text-lg">Q16.</span>
770
  <span class="text-gray-800 font-medium">Explain Function Overloading with example.</span>
771
  <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">4 MARKS</span>
772
  </div>
773
+ </div>
774
+ <div class="answer">
775
+ <div class="answer-title">Answer:</div>
776
+ <p>Function overloading is a feature where two or more functions have the same name but different parameters (different types or number of arguments). The compiler differentiates between overloaded functions based on their parameters.</p>
777
+ <p class="mt-2"><strong>Rules:</strong></p>
778
+ <ul class="list-disc pl-5">
779
+ <li>Function name must be the same</li>
780
+ <li>Parameters must be different (type or number)</li>
781
+ <li>Return type alone cannot differentiate functions</li>
782
+ </ul>
783
+ <p class="mt-3"><strong>Advantage:</strong> Increases code readability as you can use the same name for similar operations.</p>
784
+ <p><strong>Example:</strong></p>
785
+ <pre class="bg-gray-800 text-green-300 p-4 rounded-lg text-sm overflow-x-auto">
786
+ #include<iostream>
787
+ using namespace std;
788
+
789
+ class Cal {
790
+ public:
791
+ int add(int a, int b) {
792
+ return a + b;
793
+ }
794
+ int add(int a, int b, int c) {
795
+ return a + b + c;
796
+ }
797
+ };
798
+
799
+ int main() {
800
+ Cal c;
801
+ cout << c.add(10, 20) << endl; // Output: 30
802
+ cout << c.add(12, 20, 23) << endl; // Output: 55
803
+ return 0;
804
+ }</pre>
805
+ </div>
806
+ </div>
807
+
808
+ <!-- Question 17 -->
809
+ <div class="question-card bg-white rounded-lg shadow-md p-5 mb-4">
810
+ <div class="flex flex-wrap gap-3 items-start justify-between">
811
+ <div>
812
  <span class="font-bold text-secondary text-lg">Q17.</span>
813
  <span class="text-gray-800 font-medium">Define class & object.</span>
814
  <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">2 MARKS</span>
815
  </div>
816
+ </div>
817
+ <div class="answer">
818
+ <div class="answer-title">Answer:</div>
819
+ <p><strong>Class:</strong> A class is a user-defined data type that acts as a blueprint for creating objects. It combines data representation and methods for manipulating that data into a single package. A class specifies the form of an object and can have fields, methods, constructors, etc.</p>
820
+ <p><strong>Syntax:</strong></p>
821
+ <pre class="bg-gray-800 text-green-300 p-4 rounded-lg text-sm overflow-x-auto">
822
+ class className
823
+ {
824
+ // data members and member functions
825
+ };</pre>
826
+ <p><strong>Object:</strong> An object is a single instance of a class. When a class is defined, only the specification is created; memory is allocated when an object is created. Objects can access the data and functions defined in the class.</p>
827
+ <p><strong>Syntax:</strong> <code>className objectVariableName;</code></p>
828
+ </div>
829
+ </div>
830
+
831
+ <!-- Question 18 -->
832
+ <div class="question-card bg-white rounded-lg shadow-md p-5 mb-4">
833
+ <div class="flex flex-wrap gap-3 items-start justify-between">
834
+ <div>
835
  <span class="font-bold text-secondary text-lg">Q18.</span>
836
  <span class="text-gray-800 font-medium">What is an instance of a class?</span>
837
  <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">2 MARKS</span>
838
  </div>
839
+ </div>
840
+ <div class="answer">
841
+ <div class="answer-title">Answer:</div>
842
+ <p>An instance of a class is an object created from that class at runtime using one of the available constructors. It represents a specific realization of the class with its own set of attribute values and state.</p>
843
+ <p>When you create an instance of a class, you are creating a unique object that has its own data values and can perform the actions defined by the class's methods. Each instance is independent and can have different attribute values.</p>
844
+ <p><strong>Example:</strong> If "Car" is a class with attributes like color, model, and year, then "myCar" would be an instance of the Car class with specific values for these attributes.</p>
845
+ </div>
846
+ </div>
847
+
848
+ <!-- Question 19 -->
849
+ <div class="question-card bg-white rounded-lg shadow-md p-5 mb-4">
850
+ <div class="flex flex-wrap gap-3 items-start justify-between">
851
+ <div>
852
  <span class="font-bold text-secondary text-lg">Q19.</span>
853
  <span class="text-gray-800 font-medium">Define Member Function & Nesting of Member Function.</span>
854
  <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">3 MARKS</span>
855
  </div>
856
+ </div>
857
+ <div class="answer">
858
+ <div class="answer-title">Answer:</div>
859
+ <p><strong>Member Function:</strong> A member function of a class is a function that has its definition or prototype within the class definition. It operates on objects of the class and has access to all members of the class for that object. Member functions are also known as methods and encapsulate the behaviors that objects of the class can perform.</p>
860
+ <p><strong>Nesting of Member Functions:</strong> When a member function calls another member function of the same class, it is referred to as nesting of member functions. This allows for modular code organization within a class.</p>
861
+ <p><strong>Example:</strong></p>
862
+ <pre class="bg-gray-800 text-green-300 p-4 rounded-lg text-sm overflow-x-auto">
863
+ #include<iostream>
864
+ using namespace std;
865
+
866
+ class Average {
867
+ int a, b;
868
+ public:
869
+ void read() {
870
+ cout << "Enter a and b: ";
871
+ cin >> a >> b;
872
+ }
873
+ void print() {
874
+ cout << "Value of a: " << a << endl;
875
+ cout << "Value of b: " << b << endl;
876
+ cout << "Average is: " << avg() << endl;
877
+ }
878
+ int avg() {
879
+ return (a + b) / 2;
880
+ }
881
+ };
882
+
883
+ int main() {
884
+ Average a;
885
+ a.read();
886
+ a.print();
887
+ return 0;
888
+ }</pre>
889
+ </div>
890
+ </div>
891
+
892
+ <!-- Question 20 -->
893
+ <div class="question-card bg-white rounded-lg shadow-md p-5 mb-4">
894
+ <div class="flex flex-wrap gap-3 items-start justify-between">
895
+ <div>
896
  <span class="font-bold text-secondary text-lg">Q20.</span>
897
  <span class="text-gray-800 font-medium">Define Private Member Function.</span>
898
  <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">3 MARKS</span>
899
  </div>
900
+ </div>
901
+ <div class="answer">
902
+ <div class="answer-title">Answer:</div>
903
+ <p>A private member function is a function declared in the private section of a class. It can only be accessed and called from within the class itself, typically through public member functions.</p>
904
+ <p>Private member functions are used for internal operations or helper functions that should not be directly accessible from outside the class. They help encapsulate implementation details, hide complexity, and ensure proper data protection.</p>
905
+ <p><strong>Characteristics:</strong></p>
906
+ <ul class="list-disc pl-5 mt-2">
907
+ <li>Accessible only within the class</li>
908
+ <li>Cannot be called from outside the class or by other objects</li>
909
+ <li>Used for internal processing and helper operations</li>
910
+ <li>Contributes to data security and encapsulation</li>
911
+ </ul>
912
+ </div>
913
+ </div>
914
+
915
+ <!-- Question 21 -->
916
+ <div class="question-card bg-white rounded-lg shadow-md p-5 mb-4">
917
+ <div class="flex flex-wrap gap-3 items-start justify-between">
918
+ <div>
919
  <span class="font-bold text-secondary text-lg">Q21.</span>
920
  <span class="text-gray-800 font-medium">What is a Friend Function? Explain with example.</span>
921
  <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">3 MARKS</span>
922
+ </div>
923
+ </div>
924
+ <div class="answer">
925
+ <div class="answer-title">Answer:</div>
926
+ <p>A friend function in C++ is a function that is not a member of a class but has access to the class's private and protected data members. It is declared inside the class with the <code>friend</code> keyword, but defined outside the class scope.</p>
927
+ <p><strong>Properties:</strong></p>
928
+ <ul class="list-disc pl-5 mt-2">
929
+ <li>Not a member function of the class</li>
930
+ <li>Can access private and protected members of the class</li>
931
+ <li>Declared with <code>friend</code> keyword inside the class</li>
932
+ <li>Defined outside the class like a normal function</li>
933
+ </ul>
934
+ <p><strong>Example:</strong></p>
935
+ <pre class="bg-gray-800 text-green-300 p-4 rounded-lg text-sm overflow-x-auto">
936
+ #include<iostream>
937
+ using namespace std;
938
+
939
+ class Test {
940
+ private:
941
+ int a;
942
+ public:
943
+ friend void show(Test t);
944
+ };
945
+
946
+ void show(Test t) {
947
+ cout << "Enter a: ";
948
+ cin >> t.a;
949
+ cout << "Value of a: " << t.a;
950
+ }
951
+
952
+ int main() {
953
+ Test t1;
954
+ show(t1);
955
+ return 0;
956
+ }</pre>
957
+ </div>
958
+ </div>
959
+ </section>
960
+
961
+ <!-- Unit 3 Content -->
962
+ <section id="unit-3" class="mb-12">
963
+ <div class="flex items-center gap-3 mb-6">
964
+ <div class="w-2 h-10 bg-cyan-500 rounded-lg"></div>
965
+ <h2 class="text-2xl font-bold text-secondary flex items-center gap-2">
966
+ <i class="fas fa-hat-wizard text-cyan-500"></i> UNIT-3: Constructor & Destructor
967
+ </h2>
968
+ </div>
969
+
970
+ <!-- Question 22 -->
971
+ <div class="question-card bg-white rounded-lg shadow-md p-5 mb-4">
972
+ <div class="flex flex-wrap gap-3 items-start justify-between">
973
+ <div>
974
  <span class="font-bold text-secondary text-lg">Q22.</span>
975
  <span class="text-gray-800 font-medium">What is a constructor? Explain in brief with example.</span>
976
  <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">3 MARKS</span>
977
  </div>
978
+ </div>
979
+ <div class="answer">
980
+ <div class="answer-title">Answer:</div>
981
+ <p>A constructor is a special member function in C++ that is automatically invoked when an object is created. It has the same name as the class and is used to initialize the data members of the object.</p>
982
+ <p><strong>Properties:</strong></p>
983
+ <ul class="list-disc pl-5 mt-2">
984
+ <li>Same name as the class</li>
985
+ <li>No return type (not even void)</li>
986
+ <li>Automatically called when object is created</li>
987
+ <li>Can be overloaded</li>
988
+ <li>Cannot be inherited</li>
989
+ </ul>
990
+ <p><strong>Example:</strong></p>
991
+ <pre class="bg-gray-800 text-green-300 p-4 rounded-lg text-sm overflow-x-auto">
992
+ #include<iostream>
993
+ using namespace std;
994
+
995
+ class Person {
996
+ string name;
997
+ int age;
998
+ public:
999
+ Person() { // Default constructor
1000
+ name = "Unknown";
1001
+ age = 0;
1002
+ cout << "Default constructor called." << endl;
1003
+ }
1004
+
1005
+ void displayInfo() {
1006
+ cout << "Name: " << name << endl;
1007
+ cout << "Age: " << age << endl;
1008
+ }
1009
+ };
1010
+
1011
+ int main() {
1012
+ Person person1; // Constructor called automatically
1013
+ person1.displayInfo();
1014
+ return 0;
1015
+ }</pre>
1016
+ </div>
1017
+ </div>
1018
+
1019
+ <!-- Question 23 -->
1020
+ <div class="question-card bg-white rounded-lg shadow-md p-5 mb-4">
1021
+ <div class="flex flex-wrap gap-3 items-start justify-between">
1022
+ <div>
1023
  <span class="font-bold text-secondary text-lg">Q23.</span>
1024
  <span class="text-gray-800 font-medium">Explain default constructor with program.</span>
1025
  <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">3 MARKS</span>
 
 
 
1026
  </div>
1027
+ </div>
1028
+ <div class="answer">
1029
+ <div class="answer-title">Answer:</div>
1030
+ <p>A default constructor is a constructor that has no parameters. It is invoked automatically when an object is created without any arguments. If the programmer does not define a default constructor, the compiler provides an implicit default constructor.</p>
1031
+ <p><strong>Example:</strong></p>
1032
+ <pre class="bg-gray-800 text-green-300 p-4 rounded-lg text-sm overflow-x-auto">
1033
+ #include<iostream>
1034
+ using namespace std;
1035
+
1036
+ class Employee {
1037
+ public:
1038
+ Employee() {
1039
+ cout << "Default Constructor Invoked" << endl;
1040
+ }
1041
+ };
1042
+
1043
+ int main() {
1044
+ Employee e1; // Calls default constructor
1045
+ Employee e2; // Calls default constructor
1046
+ return 0;
1047
+ }
1048
+ // Output:
1049
+ // Default Constructor Invoked
1050
+ // Default Constructor Invoked</pre>
1051
+ </div>
1052
+ </div>
1053
+
1054
+ <!-- Question 24 -->
1055
+ <div class="question-card bg-white rounded-lg shadow-md p-5 mb-4">
1056
+ <div class="flex flex-wrap gap-3 items-start justify-between">
1057
+ <div>
1058
  <span class="font-bold text-secondary text-lg">Q24.</span>
1059
  <span class="text-gray-800 font-medium">How to test a copy constructor? Justify with program.</span>
1060
  <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">3 MARKS</span>
1061
  </div>
1062
+ </div>
1063
+ <div class="answer">
1064
+ <div class="answer-title">Answer:</div>
1065
+ <p>A copy constructor initializes an object using another object of the same class. It is used to:</p>
1066
+ <ul class="list-disc pl-5 mt-2">
1067
+ <li>Initialize one object from another of the same type</li>
1068
+ <li>Copy an object to pass it as an argument to a function</li>
1069
+ <li>Copy an object to return it from a function</li>
1070
+ </ul>
1071
+ <p>If not defined, the compiler provides a default copy constructor. However, for classes with pointer variables or dynamic memory, a user-defined copy constructor is necessary.</p>
1072
+ <p><strong>Testing Copy Constructor:</strong></p>
1073
+ <pre class="bg-gray-800 text-green-300 p-4 rounded-lg text-sm overflow-x-auto">
1074
+ #include<iostream>
1075
+ using namespace std;
1076
+
1077
+ class A {
1078
+ public:
1079
+ int x;
1080
+
1081
+ A(int a) { // Parameterized constructor
1082
+ x = a;
1083
+ }
1084
+
1085
+ A(A&amp; i) { // Copy constructor
1086
+ x = i.x;
1087
+ }
1088
+ };
1089
+
1090
+ int main() {
1091
+ A a1(20); // Calls parameterized constructor
1092
+ A a2(a1); // Calls copy constructor
1093
+ cout << a2.x; // Output: 20
1094
+ return 0;
1095
+ }</pre>
1096
+ </div>
1097
+ </div>
1098
+
1099
+ <!-- Question 25 -->
1100
+ <div class="question-card bg-white rounded-lg shadow-md p-5 mb-4">
1101
+ <div class="flex flex-wrap gap-3 items-start justify-between">
1102
+ <div>
1103
  <span class="font-bold text-secondary text-lg">Q25.</span>
1104
  <span class="text-gray-800 font-medium">Explain parameterized constructor with example.</span>
1105
  <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">4 MARKS</span>
1106
  </div>
1107
+ </div>
1108
+ <div class="answer">
1109
+ <div class="answer-title">Answer:</div>
1110
+ <p>A parameterized constructor is a constructor that accepts parameters. It is used to initialize objects with specific values provided during object creation, allowing for flexible and customized object initialization.</p>
1111
+ <p><strong>Key Points:</strong></p>
1112
+ <ul class="list-disc pl-5 mt-2">
1113
+ <li>Has parameters in its declaration</li>
1114
+ <li>Allows initialization with specific values</li>
1115
+ <li>Provides flexibility in object creation</li>
1116
+ <li>Can be overloaded with different parameter sets</li>
1117
+ </ul>
1118
+ <p><strong>Example:</strong></p>
1119
+ <pre class="bg-gray-800 text-green-300 p-4 rounded-lg text-sm overflow-x-auto">
1120
+ #include<iostream>
1121
+ using namespace std;
1122
+
1123
+ class Employee {
1124
+ public:
1125
+ int id;
1126
+ string name;
1127
+ float salary;
1128
+
1129
+ Employee(int i, string n, float s) {
1130
+ id = i;
1131
+ name = n;
1132
+ salary = s;
1133
+ }
1134
+
1135
+ void display() {
1136
+ cout << id << " " << name << " " << salary << endl;
1137
+ }
1138
+ };
1139
+
1140
+ int main() {
1141
+ Employee e1(101, "Sonoo", 890000);
1142
+ Employee e2(102, "Nakul", 59000);
1143
+ e1.display();
1144
+ e2.display();
1145
+ return 0;
1146
+ }
1147
+ // Output:
1148
+ // 101 Sonoo 890000
1149
+ // 102 Nakul 59000</pre>
1150
+ </div>
1151
+ </div>
1152
+
1153
+ <!-- Question 26 -->
1154
+ <div class="question-card bg-white rounded-lg shadow-md p-5 mb-4">
1155
+ <div class="flex flex-wrap gap-3 items-start justify-between">
1156
+ <div>
1157
  <span class="font-bold text-secondary text-lg">Q26.</span>
1158
  <span class="text-gray-800 font-medium">Explain Characteristics of Constructor.</span>
1159
  <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">3 MARKS</span>
1160
  </div>
1161
+ </div>
1162
+ <div class="answer">
1163
+ <div class="answer-title">Answer:</div>
1164
+ <p>The characteristics of constructors are:</p>
1165
+ <ol class="list-decimal pl-5 mt-2">
1166
+ <li>The name of the constructor is the same as its class name.</li>
1167
+ <li>Constructors are mostly declared in the public section of the class (though they can be in private).</li>
1168
+ <li>Constructors do not return values; hence they do not have a return type.</li>
1169
+ <li>A constructor gets called automatically when we create an object of the class.</li>
1170
+ <li>Constructors can be overloaded (multiple constructors with different parameters).</li>
1171
+ <li>Constructor cannot be declared virtual.</li>
1172
+ <li>Constructor cannot be inherited by derived classes.</li>
1173
+ <li>Addresses of constructors cannot be referred (no pointer to constructor).</li>
1174
+ <li>Constructors make implicit calls to new and delete operators during memory allocation.</li>
1175
+ </ol>
1176
+ </div>
1177
+ </div>
1178
+
1179
+ <!-- Question 27 -->
1180
+ <div class="question-card bg-white rounded-lg shadow-md p-5 mb-4">
1181
+ <div class="flex flex-wrap gap-3 items-start justify-between">
1182
+ <div>
1183
+ <span class="font-bold text-secondary text-lg">Q27.</span>
1184
+ <span class="text-gray-800 font-medium">Write a C++ program to enter student details by passing parameters to constructors.</span>
1185
+ <span class="text-sm bg-blue-100 text-primary px-2 py-0.5 rounded-full">3 MARKS</span>
1186
+ </div>
1187
+ </div>
1188
+ <div class="answer">
1189
+ <div class="answer-title">Answer:</div>
1190
+ <pre class="bg-gray-800 text-green-300 p-4 rounded-lg text-sm overflow-x-auto">
1191
+ #include<iostream>
1192
  using namespace std;
1193
 
1194
  class Student {
 
 
1195
  public:
1196
+ int id;
1197
+ string name;
1198
+ float salary;
1199
+
1200
+ // Parameterized constructor
1201
+ Student(int i, string n, float s) {
1202
+ id = i;
1203
  name = n;
1204
+ salary = s;
1205
  }
1206
+
1207
  void display() {
1208
+ cout << "ID: " << id << ", Name: " << name << ", Salary: " << salary << endl;
1209
  }
1210
  };
1211
 
1212
  int main() {
1213
+ // Creating objects with parameters passed to constructor
1214
+ Student e1(101, "Sonoo", 890000);
1215
+ Student e2(102, "Nakul", 59000);
1216
+
1217
+ e1.display();
1218
+ e2.display();
1219
+
1220
  return 0;
1221
+ }
1222
+ // Output:
1223
+ // ID: 101, Name: Sonoo, Salary: 890000
1224
+ // ID: 102, Name: Nakul, Salary: 59000</pre>
1225
  </div>
1226
+ </div>
1227
+ </section>
1228
+
1229
+ <!-- Key Concepts Review -->
1230
  <section class="mb-12 bg-gradient-to-br from-blue-50 to-white p-6 rounded-xl shadow-lg border border-blue-100">
1231
  <h2 class="text-2xl font-bold text-secondary mb-6">Key Concepts Cheatsheet</h2>
1232
  <div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-4 gap-4">
 
1237
  <h3 class="font-bold text-secondary">Encapsulation</h3>
1238
  <p class="text-sm text-gray-600 mt-1">Bundling data with methods operating on that data</p>
1239
  </div>
 
1240
  <div class="bg-white rounded-lg p-4 border border-indigo-200 shadow-sm flex flex-col items-center text-center">
1241
  <div class="bg-indigo-100 p-3 rounded-full mb-3">
1242
  <i class="fas fa-sitemap text-indigo-600 text-xl"></i>
 
1244
  <h3 class="font-bold text-secondary">Inheritance</h3>
1245
  <p class="text-sm text-gray-600 mt-1">Creating hierarchical relationships between classes</p>
1246
  </div>
 
1247
  <div class="bg-white rounded-lg p-4 border border-purple-200 shadow-sm flex flex-col items-center text-center">
1248
  <div class="bg-purple-100 p-3 rounded-full mb-3">
1249
  <i class="fas fa-bolt text-purple-600 text-xl"></i>
 
1251
  <h3 class="font-bold text-secondary">Polymorphism</h3>
1252
  <p class="text-sm text-gray-600 mt-1">Same methods performing different actions</p>
1253
  </div>
 
1254
  <div class="bg-white rounded-lg p-4 border border-cyan-200 shadow-sm flex flex-col items-center text-center">
1255
  <div class="bg-cyan-100 p-3 rounded-full mb-3">
1256
  <i class="fas fa-puzzle-piece text-cyan-600 text-xl"></i>
 
1261
  </div>
1262
  </section>
1263
  </main>
1264
+
1265
  <!-- Footer -->
1266
  <footer class="bg-secondary text-blue-100 py-8">
1267
  <div class="container mx-auto px-4">
1268
  <div class="flex flex-col md:flex-row justify-between items-center">
1269
  <div class="mb-4 md:mb-0">
1270
+ <h3 class="text-xl font-bold text-white">OOP with C++ Exam Guide</h3>
1271
+ <p class="mt-1">Complete answers to all questions from the official question bank</p>
1272
  </div>
1273
  <div class="flex space-x-4">
1274
+ <button onclick="window.print()" class="bg-blue-600 hover:bg-blue-700 text-white py-2 px-4 rounded-lg flex items-center">
1275
  <i class="fas fa-print mr-2"></i> Print Summary
1276
  </button>
1277
  <button class="bg-cyan-500 hover:bg-cyan-600 text-white py-2 px-4 rounded-lg flex items-center">
 
1280
  </div>
1281
  </div>
1282
  <div class="mt-8 pt-8 border-t border-blue-800 text-center text-sm text-blue-200">
1283
+ <p>This comprehensive study guide covers all questions from the official C++ question bank for diploma students in computer engineering.</p>
1284
+ <p class="mt-2">Important keywords to remember: <mark>private</mark>, <mark>friend</mark>, <mark>inline</mark>, <mark>::</mark>, <mark>using</mark>, <mark>namespace</mark>, <mark>class</mark>, <mark>object</mark>, <mark>constructor</mark>, <mark>destructor</mark></p>
1285
  </div>
1286
  </div>
1287
  </footer>
1288
+
1289
  <script>
1290
  document.addEventListener('DOMContentLoaded', function() {
1291
+ // Add smooth scrolling for anchor links
1292
+ document.querySelectorAll('a[href^="#"]').forEach(anchor => {
1293
+ anchor.addEventListener('click', function (e) {
1294
+ e.preventDefault();
1295
+ document.querySelector(this.getAttribute('href')).scrollIntoView({
1296
+ behavior: 'smooth'
1297
+ });
1298
  });
1299
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1300
  });
1301
  </script>
1302
  </body>