SYBCA Sem-3
Object Oriented Programming and Data Structure
Theory Assignment
1.Difference between Procedural Programming and OOPS.
2.Detail notes of access control specifier(public, private and protected).
3.Explain data hiding, abstraction and encapsulation with example.
4.Explain Inheritance and types of inheritance with example.
5.Explain constructor and destructor with example.
6.Difference between compile-time polymorphism and run-time
polymorphism.
7.Explain overloading and overriding with example.
8.Explain friend function with example.
9.Difference between virtual function and pure virtual function.
10.Explain Infix to postfix and Infix to prefix with example.
11.Explain stack with algorithm.
12.Detail notes about queue with algorithm.
,1.Difference between procedural programming and OOPS.
Procedure Oriented Object-Oriented Programming
Feature
Programming (POP) (OOP)
Program is divided into small Program is divided into parts
Division
parts called functions. called objects.
Approach Follows Top-Down approach. Follows Bottom-Up approach.
Access POP does not have any OOP has access specifiers named
Specifiers access specifier. public, private, protected.
Adding new data and Easy to add new data and
Expansion
functions is difficult. functions.
Examples C, Pascal, FORTRAN, VB. C++, Java, Python, C#, VB.NET.
High reusability through
Reusability Code reusability is less.
inheritance and polymorphism.
Complexity Suitable for large and complex
Suitable for small programs.
Handling programs.
Inheritance No inheritance support. Inheritance is a key feature.
2.Detail notes of access control specifier(public, private and protected).
🔑 Access Control Specifiers in OOP
Access control specifiers are keywords used in Object-Oriented
Programming (OOP) to define the scope and visibility of class members
(data members & methods).
, They control who can access the variables, methods, and functions of a
class.
There are mainly three types:
1. Public
2. Private
3. Protected
1. Public
Definition:
Members declared as public are accessible from anywhere in the program
(inside or outside the class).
They are available inside the class,
outside the class, and
in derived classes.
Scope:
Global scope means a variable or function is accessible from any class,
function, or object in the program.
Use:
When you want to allow free access to methods or variables.
Example:
#include <iostream.h>
#include <conio.h>
class Student {
public:
int rollNo;
void display() {
cout << "Roll No: " << rollNo;
}
};
, void main() {
Student s;
s.rollNo = 10;
s.display();
getch();
}
2. Private
Definition:
Members declared as private are accessible only within the same class.
They cannot be accessed from outside the class or by derived classes.
Used for data hiding and security.
<<
Scope:
Not accessible outside the class or by derived (child) classes.
Use:
For data hiding and ensuring security (sensitive information).
Example:
#include <iostream.h>
#include <conio.h>
class Student {
private:
int marks;
public:
void setMarks(int m) { // ✅ Access via public method
marks = m;
}
Object Oriented Programming and Data Structure
Theory Assignment
1.Difference between Procedural Programming and OOPS.
2.Detail notes of access control specifier(public, private and protected).
3.Explain data hiding, abstraction and encapsulation with example.
4.Explain Inheritance and types of inheritance with example.
5.Explain constructor and destructor with example.
6.Difference between compile-time polymorphism and run-time
polymorphism.
7.Explain overloading and overriding with example.
8.Explain friend function with example.
9.Difference between virtual function and pure virtual function.
10.Explain Infix to postfix and Infix to prefix with example.
11.Explain stack with algorithm.
12.Detail notes about queue with algorithm.
,1.Difference between procedural programming and OOPS.
Procedure Oriented Object-Oriented Programming
Feature
Programming (POP) (OOP)
Program is divided into small Program is divided into parts
Division
parts called functions. called objects.
Approach Follows Top-Down approach. Follows Bottom-Up approach.
Access POP does not have any OOP has access specifiers named
Specifiers access specifier. public, private, protected.
Adding new data and Easy to add new data and
Expansion
functions is difficult. functions.
Examples C, Pascal, FORTRAN, VB. C++, Java, Python, C#, VB.NET.
High reusability through
Reusability Code reusability is less.
inheritance and polymorphism.
Complexity Suitable for large and complex
Suitable for small programs.
Handling programs.
Inheritance No inheritance support. Inheritance is a key feature.
2.Detail notes of access control specifier(public, private and protected).
🔑 Access Control Specifiers in OOP
Access control specifiers are keywords used in Object-Oriented
Programming (OOP) to define the scope and visibility of class members
(data members & methods).
, They control who can access the variables, methods, and functions of a
class.
There are mainly three types:
1. Public
2. Private
3. Protected
1. Public
Definition:
Members declared as public are accessible from anywhere in the program
(inside or outside the class).
They are available inside the class,
outside the class, and
in derived classes.
Scope:
Global scope means a variable or function is accessible from any class,
function, or object in the program.
Use:
When you want to allow free access to methods or variables.
Example:
#include <iostream.h>
#include <conio.h>
class Student {
public:
int rollNo;
void display() {
cout << "Roll No: " << rollNo;
}
};
, void main() {
Student s;
s.rollNo = 10;
s.display();
getch();
}
2. Private
Definition:
Members declared as private are accessible only within the same class.
They cannot be accessed from outside the class or by derived classes.
Used for data hiding and security.
<<
Scope:
Not accessible outside the class or by derived (child) classes.
Use:
For data hiding and ensuring security (sensitive information).
Example:
#include <iostream.h>
#include <conio.h>
class Student {
private:
int marks;
public:
void setMarks(int m) { // ✅ Access via public method
marks = m;
}